dreamphp기록과 추억이 머무는 곳
고전 기타

[소스] Dual Tetris - Pascal

Box.png
Dual Tetris
?
Park hoyong (박호영), Cho Heekyoung (조희경)
41.60 KiB

듀얼 테트리스 파스칼 소스입니다.

DTETRIS.PAS
{ Dual Tetris

by Park hoyong & Cho Heekyoung

}

program Dual_Tetris;

uses dos,crt;

label loop,loop1;

const
Pot1_x = 15;
Pot1_y = 1;
Pot2_x = 12;
Pot2_y = 1;
Next1_x = 4;
Next1_y = 21;
Next2_x = 33;
Next2_y = 21;
Level1_x = 2;
Level1_y = 3;
Level2_x = 31;
Level2_y = 3;
Fl1_x = 2;
Fl1_y = 8;
Fl2_x = 31;
Fl2_y = 8;
Score1_x = 2;
Score1_y = 14;
Score2_x = 31;
Score2_y = 14;

Esc = #27;
Logo_str : array[1..19] of string[79] = (
' WWWWWWWW WWW WWW WW WWW',
' WWW WW WWW WWW WWWW WWW',
' WWW WWW WWW WWW WWWW WWW',
' WWW WWW WWW WWW WW WW WWW',
' WWW WWW WWW WWW WWW WWW WWW',
' WWW WWW WWW WWW WWW WWW WWW',
' WWW WWW WWW WWW WWWWWWWWWWWW WWW',
' WWW WW WW WW WWWW WWWW WWW',
' WWWWWWWW WWWWWWW WWWW WWWW WWWWWWWWWW',
'',
' WWWWWWWWWWW WWWWWWWWWWW WWWWWWWWWWW WWWWWWWWWW WWWWW WWWWWWWWW ',
' WWW WWW WWW WWW WWW WWW WWW WWW',
' WWW WWW WWW WWW WWW WWW WWW ',
' WWW WWW WWW WWW WWW WWW WWW ',
' WWW WWWWWWWW WWW WWWWWWWWWW WWW WWWWWWWWW ',
' WWW WWW WWW WWWWWWW WWW WWW',
' WWW WWW WWW WWW WWWW WWW WWW WWW',
' WWW WWW WWW WWW WWWW WWW WWW WWW',
' WWW WWWWWWWWWWW WWW WWW WWWW WWWWW WWWWWWWWW '
);

Tcolor : array[1..8] of integer =
( 1,2,3,4,5,6,7,9 );

type
Result = record
case intcod:integer of
0 : (ax,bx,cx,dx,bp,si,di,ds,es,flags:word);
1 : (al,ah,bl,bh,cl,ch,dl,dh:byte);
end;
Scr_arr = array[1..8000] of byte;
Scr_pt = ^Scr_arr;
Scoreb = record
name : String[15];
lev : integer;
sco : real;
end;
Art = array[1..4] of integer;
Art1 = array[1..8] of integer;
Arx = Record
xxx : art;
yyy : art;
end;
Str80 = string[80];

var
Ch : char;
Crt_mode : boolean;
Scr_st : Scr_pt;
Scr_save : Scr_arr;
Xsave : byte;
Ysave : byte;
Cursm_s : integer;
Rot_pt : array[1..40] of integer;
Tet_shape : array[1..20] of arx;
Pot : array[0..17,0..21] of integer;
Time_fact : array[false..true] of integer;
Cur_tet : integer;
Cur_tc : integer;
Horz : integer;
Vert : integer;
Movok : boolean;
Lin_st : array[0..2,0..20] of integer;
Score : array[false..true] of integer;
Alm_pt : integer;
Level : array[false..true] of integer;
Ent_lev : array[false..true] of integer;
Next_t : array[false..true] of integer;
View_next : array[false..true] of boolean;
Fl_cnt : array[false..true] of integer;
Levup_pt : array[0..9] of integer;
Stat_tet : array[1..7] of integer;
Dp_tet_pt : array[0..7,1..2] of integer;
Resfile : file of scoreb;
Scor_arr : array[1..20] of Scoreb;
Str15 : string[15];
Run_count : integer;
Grade_mk : integer;
Gen_b : integer;
All_end : boolean;
Turn : boolean;
tb : boolean;
end_c : array[false..true] of boolean;
No_p : integer;
Px,Py,Pz : integer;
Mmark : array[1..20] of boolean;
keyp_flag : boolean;
Sound_flag : boolean;
rotris,scrol_flag,random_flag,full_flag : boolean;
cur_color,Next_color : integer;
scr_dir : boolean;
rLIn : integer;

procedure rotate; forward;

procedure Get_crtmod;

begin
Crt_mode := ( Mem[$0040:$0049] = 7 );
{ if Crt_mode = 80*25 b&w card then true else false }
end;

procedure Curs_off;
var x : Registers;
Begin
with x do
begin
ax := $100;
cx := $3030;
end;
intr ($10,x);
end;

procedure Curs_on;
var x : Registers;
begin
with x do
begin
ax := $100;
cx := $25a2;
end;
intr ($10,x);
end;

procedure Atxy ( x,y : byte);
begin
if Crt_mode then Gotoxy (x+x-1,y)
else Gotoxy (x,y);
end;

procedure Disp_str ( s : Str80; f : char);
var c : byte;
begin
if Crt_mode then
for c :=1 to length(s) do
write (s[c],f)
else write (s);
end;

procedure Set_crtmod ( mode : byte);

begin
if Crt_mode then Textmode(7) { 80*25 b&w card }
else Textmode(mode);
end;

procedure Set_color( color : byte);

begin
if Crt_mode then
begin
if color > 0 then Textcolor(7)
else Textcolor(0);
end
else Textcolor(color);
end;

procedure Set_back (back : byte);

begin
if Crt_mode then
begin
if back>0 then TextBackground (7)
else TextBackground (0);
end
else TextBackground (back);
end;

procedure Save_screen;

begin
if Crt_mode then Scr_st := ptr ($b000,$0)
else Scr_st := ptr ($b800,$0);
Scr_save := Scr_st^;
Xsave := Wherex;
Ysave := Wherey;
Cursm_s := memw[$0040:$0060];
Clrscr;
Set_crtmod (3);
Curs_off;
end;

procedure Load_screen;

begin
Curs_on;
Set_crtmod(3);
Scr_st^ := Scr_save;
Gotoxy (Xsave,Ysave);
Writeln;
Set_color (0);
Set_back (4);
Write (' ');
Set_back(0);
Writeln;
Set_back (4);
Write (' Play TETRIS ! ');
Set_back (0);
Writeln;
Set_back (4);
Write (' ');
Set_color(3);
Set_back (0);
Writeln;
Halt;
end;

procedure Logo;

var i,j,k : integer;
l : boolean;

begin
j := 1;
l := false;
Repeat
Set_color (0);
Set_back (j);
Gotoxy (1,1);
k := 1;
while ((k <= 19) and not(keypressed and l)) do
begin
for i:=1 to Length(Logo_str[k]) do
begin
if Logo_Str[k][i] <> ' ' then write (' ')
else Gotoxy (i+1,k);
end; { for }
Delay ($50);
k := k + 1;
end; { while }
if j < 7 then j := j + 1
else j := 1;
Set_back (0);
Set_color(7);
Gotoxy (13,21);
Write('origin by USSR Moscow, 1986 A. Pajitnov & V. Gerasimov ');
Set_color (13);
Gotoxy (13,23);
Write('modified by KOREA , 1988 Park hoyong & Cho Heekyoung');
l := true;
until Keypressed;
Ch := Readkey;
if ch = Esc then
if Keypressed then ch := Readkey
else Load_screen;
end;

procedure Write_scr;

var i : integer;

begin
Rewrite (Resfile);
for i:=1 to 20 do
write (Resfile,Scor_arr[i]);
Close (Resfile);
end ;

procedure Enter_name(p : boolean);

var i : integer;

procedure Get_line;

var j : integer;
k : boolean;

procedure SoundDn;
begin
if not sound_flag then exit;
Sound (200);
Delay (100);
Sound (400);
Delay (100);
Nosound;
end;

begin { Get_line }
Str15 := '';
j := 0;
k := false;
repeat
ch := Readkey;
case Ch of
#$20..#$FE :
if j < 15 then
begin
write (Ch:0);
j := j + 1;
Str15 := Str15 + Ch;
end
else SoundDn;
#$08 :
if j > 0 then
begin
Write (^H' '^H);
Delete (Str15,j,1);
j := j - 1;
end
else SoundDn;
#$0D : k := True;
Esc :
if Keypressed then
begin
Ch := Readkey;
SoundDn;
end
else Load_screen;
else SoundDn;
end; { case }
until k;
end; { Get_line }


begin { Enter_name }
Set_back (0);
Gotoxy (1,24);
Set_color (4);
if p then write ('Player 1 : ')
else write ('Player 2 : ');
Write ('Enter Your Name:');
Get_line;
if Str15 <> '' then
begin
i := 20;
while (i>1) and (score[p] > Scor_arr[i-1].sco) do
begin
if (score[p] > Scor_arr[i].sco) then
begin
Scor_arr[i] := Scor_arr[i-1];
i := i - 1;
end;
end; { while }
Grade_mk := i;
Scor_arr[i].name := Str15;
Scor_arr[i].lev := level[p];
Scor_arr[i].sco := score[p];
Write_scr;
end;
end; { Enter_name }

procedure Scoreb_main (Rf : boolean );

var v : array[1..20] of integer;
h : array[1..20] of integer;
c : array[1..20] of integer;

procedure Set_scrt;

var j : integer;

begin { Set_scrt }
if Rf then
begin
Set_crtmod (3);
Set_back (0);
Clrscr;
Gotoxy (26,1);
Set_color (6);
Write ('TETRIS Game 20 Highest Results');
end;
for j := 1 to 10 do
v[j] := j+4;
for j:=11 to 20 do
v[j] := (17 + (j-1) mod 5 );
for j :=1 to 10 do
h[j] := 25;
for j:=11 to 15 do
h[j] := 5;
for j:=16 to 20 do
h[j] := 45;
c[1] := 7;
c[2] := 4;
c[3] := 4;
for j:=4 to 6 do
c[j] := 2;
for j:=7 to 10 do
c[j] := 3;
for j:=11 to 15 do
c[j] := 1;
for j:=16 to 20 do
c[j] := 5;
end; { Set_scrt }

procedure Clear_scrb;

var j : integer;

begin { Clear_scrb }
for j :=1 to 20 do
begin
Scor_arr[j].name := ' ';
Scor_arr[j].lev := 0;
Scor_arr[j].sco := 0;
end;
Write_scr;
end; { Clear_scrb }

procedure Read_score;
var io : boolean;
k,j : integer;
rs,xs : string;

begin { Read_score }
xs := paramstr(0);
k := length(xs)+1;
repeat
k := k - 1;
until ( (k=1) or (xs[k]='\'));
rs := '';
for j :=1 to k do
rs := rs + xs[j];
rs := rs + 'dtet.res';
assign (Resfile,rs);
{$I-}
reset (Resfile);
{$I+}
io := (IOresult <> 0);
if io then
Clear_scrb
else
begin
for k:=1 to 20 do
read (Resfile,Scor_arr[k]);
close (Resfile);
end;
end; { Read_score }

procedure Prt_scorb;

var j : integer;
k : integer;

begin { Prt_scorb }
for j :=1 to 20 do
if Scor_arr[j].sco <> 0 then
begin
if j <> Grade_mk then
Gotoxy (h[j],v[j])
else begin
Gotoxy (h[j]-2,v[j]);
Set_color (6);
Write ('* ');
end;
Set_color (c[j]);
for k:=length(Scor_arr[j].name) to 15 do
Scor_arr[j].name := Scor_arr[j].name + ' ';
write ( j :2,'.',Scor_arr[j].name:0,
Scor_arr[j].lev:2,Scor_arr[j].sco:10:0);
end;
end; { Prt_scorb }

begin { Scoreb_main }

Set_scrt;
if not Rf then Read_score
else Prt_scorb;
end; { Scoreb_main }

procedure Wait_key;
begin
while Keypressed do
Ch := Readkey;
end;

procedure Init_tet ; { Init_tet }
var j,k : integer;
rx : arx;

procedure Rev_ts (px : arx); { Rev_ts }

var i : integer;
begin { Rev_ts }
rx.xxx := px.yyy;
for i:=1 to 4 do
rx.yyy[i] := -px.xxx[i];
end; { Rev_ts }

begin
for j:=1 to 4 do
begin
Tet_shape[1].yyy[j] := j div 3;
Tet_shape[1].xxx[j] := -(j mod 2)
end;
for k := 1 to 4 do
begin
with Tet_shape[k+3] do
begin
for j :=1 to 3 do
begin
yyy[j] := 0;
xxx[j] := j - 2;
end; { for j }
yyy[4] := 1;
xxx[4] := k-3;
end; { with }
end; {for k }
Tet_shape[4].yyy[4] := 0;
Tet_shape[2] := Tet_shape[6];
Tet_shape[2].yyy[1] := 1;
Tet_shape[3] := Tet_shape[6];
Tet_shape[3].yyy[3] := 1;
Rot_pt[1] := 1;
for j := 2 to 4 do
begin
Rev_ts ( Tet_shape[j]);
Tet_shape[j+6] := rx;
Rot_pt [j] := j + 6;
Rot_pt [j+6] := j;
end;
for j:=1 to 3 do
begin
rx := Tet_shape[j+4];
Rot_pt [j+4] := 3*j+8;
for k:=1 to 3 do
begin
Rev_ts (rx);
Tet_shape [ 7 + 3 * j + k] := rx;
Rot_pt [ 7 + 3 * j + k] := 8 + 3 * j + k;
end;
Rot_pt [ 10 + 3 * j] := j + 4;
end;
for j := 0 to 9 do
Levup_pt [j] := 10*(j + 1);
Dp_tet_pt[1,1] := 4;
Dp_tet_pt[1,2] := 10;
Dp_tet_pt[2,1] := 3;
Dp_tet_pt[2,2] := 6;
Dp_tet_pt[3,1] := 0;
Dp_tet_pt[3,2] := 8;
Dp_tet_pt[4,1] := 3;
Dp_tet_pt[4,2] := 2;
Dp_tet_pt[5,1] := 0;
Dp_tet_pt[5,2] := 0;
Dp_tet_pt[6,1] := 0;
Dp_tet_pt[6,2] := 4;
Dp_tet_pt[7,1] := 0;
Dp_tet_pt[7,2] :=12;
end;

procedure Draw_tet (x,y:integer);

var i : integer;

begin
Set_back (Cur_color);
for i:=1 to 4 do
begin
Set_color (0);
Atxy ( Px+(x+Tet_shape[20].xxx[i]) , Py+(y+Tet_shape[20].yyy[i]));
Disp_str (' ',' ');
end;
end; { Draw_tet }

procedure Erase_tet (x,y:integer);

var i,j : integer;

begin
Set_back (0);
Set_color (1);
for i:=1 to 4 do
begin
Atxy (Px+(x+Tet_shape[20].xxx[i]),Py+(y+Tet_shape[20].yyy[i]));
j := x+Tet_shape[20].xxx[i];
if (j in [7,10]) and (No_p=2)
then begin
if j=7 then Disp_str(#179,' ')
else if crt_mode then Disp_str('.',#179)
else disp_str(#179,' ');
end
else begin
if odd(j) then Disp_str (' ',' ')
else Disp_str ('.',' ');
end;
end;
end; { Erase_tet }

procedure Clr_nextt( P : boolean);
var i,lx,ly : integer;

begin

if p then begin
lx := Next1_x;
ly := Next1_y;
end
else begin
lx := Next2_x;
ly := Next2_y;
end;
Set_back (0);
Set_color (7);
for i := 0 to 1 do
begin
Atxy (lx-3,ly+i);
Disp_str (' ',' ');
end;
end;

procedure Disp_nextt (p : boolean);
var i,lx,ly : integer;
begin
if p then begin
lx := Next1_x;
ly := Next1_y;
end
else begin
lx := Next2_x;
ly := Next2_y;
end;
Clr_nextt(p);
Set_color (0);
if random_flag then Set_back (Next_color)
else Set_back (Tcolor[Next_t[p]]);
with Tet_shape[Next_t[p]] do
for i :=1 to 4 do
begin
Atxy (lx+xxx[i],ly + yyy[i]);
Disp_str (' ',' ');
end;
Score[p] := Score[p] - 5;
end;

procedure Rot;

begin
if random(50)+1 = 25 then rotate;
end;

procedure Set_rlin;

var i,j,k,s,t,c : integer;
begin
rlin := 20 - rlin;
for i:= rlin to 20 do
begin
if no_p = 1 then j := random(10)
else j := random(16);
c := 0;
for k :=1 to j do
begin
t := random(9) + 1;
if t = 1 then t := 8;
if no_p=1 then s := random(10)+ 1
else s := random(16)+ 1;
if Pot[s,i] = 255 then
begin
Pot[s,i] := t;
c := c + 1;
end;
end;
if no_p=1 then Lin_st[1,i] := c
else begin
if i in [1..6] then
Lin_st[1,i] := c;
if j in [7..10] then
Lin_st[0,i] := c;
if j in [11..16] then
Lin_st[2,i] := c;
end;

end;
end;

procedure Initialize;

var i,j : integer;
ib : boolean;

begin
for i:=1 to Pz do
for j:=1 to 20 do
Pot[i,j] := 255;
for i:=1 to Pz do
begin
Pot[i,0] := Tcolor[8];
Pot[i,21] := Tcolor[8];
end;
for j:=0 to 20 do
begin
Pot[0,j] := Tcolor[8];
Pot[Pz+1,j] := Tcolor[8];
end;
for j:= 0 to 20 do
for i:=0 to 2 do
Lin_st[i,j] := 0;
Alm_pt := 1000;
for ib := false to true do
begin
score[ib] := 0;
Next_t[ib] := Random (7) + 1;
Next_color := Random (9) + 1;
View_next[ib] := false;
Fl_cnt[ib] := 0;
End_c[ib] := True;
end;
if rotris then rot;
if random_flag then rot;
if rLin <> 0 then set_rLin;
Dp_tet_pt[0,1] := 0;
end; { Initialize }

procedure Disp_gameover(p : boolean);

var j : integer;
begin
if No_p = 1 then j := 18
else if p then j := 13 else j := 23;
Atxy (j,12);
Set_back (0);
Atxy (j,10);
Disp_str (' ',' ');
Atxy (j,11);
Disp_str (' ',' ');
Atxy (j,12);
Disp_str (' ',' ');
Atxy (j,13);
Disp_str (' ',' ');
Set_color (0);
Set_back (7);
Atxy (j+1,11);
Disp_str ('GAME',' ');
Atxy (j+1,12);
Disp_str ('OVER',' ');
Set_back (0);
end;

procedure Disp_pot (ix,iy:integer);
var i,j : integer;
ib : boolean;

begin
for j := ix to iy do
begin
Atxy(Px+1,Py+j);
for i := 1 to Pz do
begin
if Pot[i,j] <> 255 then
begin
Set_color (0);
Set_back (Pot[i,j]);
Disp_str (' ',' ');
end else
begin
Set_back (0);
Set_color (1);
if (i in [7,10]) and (No_p = 2)
then begin
if i=7 then Disp_str(#179,' ')
else if crt_mode then Disp_str('.',#179)
else disp_str(#179,' ');
end
else begin
if odd(i) then Disp_str (' ',' ')
else Disp_str ('.',' ');
end;
end;
end; { for i}
end; { for j}
for ib:=false to true do
if End_c[ib] = false then Disp_gameover(ib);
end;

procedure Make_GScr;

var i,j : integer;

begin
Set_back (0);
Set_color (9);
for i:=1 to 20 do
begin
Atxy (Px,Py+i);
Disp_str (#15,#15);
Atxy (Px+Pz+1,Py+i);
Disp_str (#15,#15);
end;
Atxy (Px,Py+21);
for i:= 0 to Pz+1 do
Disp_str (#15,#15);
Disp_pot (1,20);
Atxy (Next1_x-3,Next1_y-3);
Set_back (0);
Set_color (7);
Disp_str (' ',' ');
Atxy (Next1_x-3,Next1_y-2);
Disp_str (' Next:',' ');
Atxy (Next1_x-3,Next1_y-1);
Disp_str (' ',' ');
Clr_nextt(true);
Atxy (Next1_x-3,Next1_y+2);
Disp_str (' ',' ');
Atxy (Next2_x-3,Next2_y-3);
Set_back (0);
Set_color (7);
Disp_str (' ',' ');
Atxy (Next2_x-3,Next2_y-2);
if no_p = 2 then Disp_str (' Next:',' ');
Atxy (Next2_x-3,Next2_y-1);
Disp_str (' ',' ');
Clr_nextt(false);
Atxy (Next2_x-3,Next2_y+2);
Disp_str (' ',' ');
Atxy (15,24);
Set_back (0);
Set_color (4);
Disp_str ('Play TETRIS !',' ');
end; { Make_GScr }

function Check_can_move ( Cx,Cy : integer ) : boolean;
var i : integer;

begin
Check_can_move := true;
for i :=1 to 4 do
if Pot[
(Cx + Tet_shape[20].xxx[i]),(Cy + Tet_shape[20].yyy[i]) ] <> 255
then
begin
Check_can_move := false;
exit
end;
end;

function Check_endgame(p : boolean) : boolean;
var i : integer;

begin
Cur_tet := Next_t[p];
if random_flag then Cur_color := Next_color
else Cur_color := Tcolor[Cur_tet];
Next_t[p] := Random(7) + 1;
Next_color := Random(9) + 1;
Tet_shape[20] := Tet_shape[Cur_tet];
if p then Horz := 6 else Horz := 14;
Vert := 1;
Check_endgame := Check_can_move(Horz,Vert);
Cur_tc := Cur_tet;
Draw_tet (Horz,Vert);
if rotris then rot;
if random_flag then rot;
if View_next[p] then Disp_nextt(p);
Set_back (0);
Set_color (cur_color);
end;

procedure Move_tet(p : boolean); { Move_tet }

begin
if Check_can_move ( Horz,Vert+1) then
begin
Erase_tet (Horz,Vert);
Vert := Vert + 1;
Draw_tet (Horz,Vert);
end
else Movok := True;
Score[p] := Score[p] - 1;
end; { Move_tet }

procedure Left;

begin
if Check_can_move(horz-1,Vert) then
begin
Erase_tet (Horz,Vert);
Horz := Horz - 1;
Draw_tet (Horz,Vert);
Movok := false;
end;
end; { left }

procedure Right;

begin
if Check_can_move (Horz + 1,Vert) then
begin
Erase_tet (Horz,Vert);
Horz := Horz + 1;
Draw_tet (Horz,Vert);
Movok := false;
end;
end;

procedure Rotate; { Rotate }
var x : Arx;

begin
Erase_tet (Horz,Vert);
x := Tet_shape[20];
Tet_shape[20] := Tet_shape [ Rot_pt[Cur_tet] ];
if Check_can_move(Horz,Vert) then
begin
Cur_tet := Rot_pt[Cur_tet];
Draw_tet (Horz,Vert);
Movok := false;
end else
begin
Tet_shape[20] := x;
Draw_tet (Horz,Vert);
end;
end;

procedure Drop;

var i : integer;

begin
i := Vert;
while Check_can_move (Horz,Vert+1) do
Vert := Vert + 1;
Movok := True;
Erase_tet (Horz,i);
Draw_tet (Horz,Vert);
end; { Drop }

procedure Input_level(p : boolean);

var CC : char;
i : integer;

begin { Input_level }
Set_crtmod (3);
Clrscr;
Gotoxy (16,12);
if p then i:=1 else i:=2;
Write ('Player ',i,': Enter your level (0-9) [7] > ');
CC := Readkey;
if CC=Esc then
if Keypressed then
CC := Readkey
else Load_screen;
if cc in ['0'..'9']
then Ent_lev[p] := ord(cc) - (ord('0') )
else Ent_lev[p] := 7;
write (Ent_lev[p]);
Delay (50);
Set_crtmod (1);
Curs_off;
end; { Input_level }

procedure Input_mode;

var cc : char;
i : integer;

begin
rotris := false;
random_flag := false;
scrol_flag := false;
full_flag := false;
rLin := 0;
Set_crtmod (3);
Clrscr;
cc := #0;
repeat
Gotoxy (6,10);
Write ('Enter game mode (0-4) [0] > ');
gotoxy (6,12);
Write (' 0) - run');
gotoxy (6,13);
Write (' 1) - Rotris ');
if rotris then write('ON ')
else write('OFF');
gotoxy (6,14);
Write (' 2) - Scroll ');
if Scrol_flag then write('ON ')
else write('OFF');
gotoxy (6,15);
Write (' 3) - Random ');
if random_flag then write('ON ')
else write('OFF');
gotoxy (6,16);
Write (' 4) - full line/1000 ');
if full_flag then write('ON ')
else write('OFF');
gotoxy (6,17);
Write (' 5) - Line no : ',rLin);
gotoxy (35,10);
CC := Readkey;
if CC=Esc then
if Keypressed then
CC := Readkey
else Load_screen;
if cc in ['1'..'5']
then
case cc of
'1' : if no_p=1 then rotris := not rotris;
'2' : if no_p=1 then scrol_flag := not scrol_flag;
'3' : if no_p=1 then random_flag := not random_flag;
'4' : full_flag := not full_flag;
'5' : if (rLin < 15) then rlin := rlin + 1;
end;
until not (cc in ['1'..'5']);
Delay (50);
Set_crtmod (1);
Curs_off;
end; { Input_level }

procedure Set_pott(p : boolean);
var i,j,k : integer;

begin
for i:=1 to 4 do
begin
j := Horz+Tet_shape[20].xxx[i];
k := Vert+Tet_shape[20].yyy[i];
Pot[ j,k ] := Cur_color;
if No_p =2 then
begin
if j in [1..6] then
Lin_st[1, k] := Lin_st[1, k] + 1;
if j in [7..10] then
Lin_st[0,k] := Lin_st[0,k] + 1;
if j in [11..16] then
Lin_st[2, k] := Lin_st[2, k] + 1;
end else
Lin_st[1, k] := Lin_st[1, k] + 1;
end;
Score[p] := Score[p] + 25 + 3 * level[p] ;
end;

procedure lSide_scroll;

var i,j,t : integer;

begin
if no_p = 1 then
begin
for i:=1 to 20 do
begin
t := pot[10,i];
for j:=9 downto 1 do
pot[j+1,i] := pot[j,i];
pot[1,i] := t;
end;
end else
for i:=1 to 20 do
begin
t := pot[16,i];
if Pot[16,i] <> 255 then Lin_st[2,i] := Lin_st[2,i] - 1;
if Pot[10,i] <> 255 then Lin_st[0,i] := Lin_st[0,i] - 1;
if Pot[6,i] <> 255 then Lin_st[1,i] := lin_st[1,i] - 1;

for j:=15 downto 1 do
pot[j+1,i] := pot[j,i];
pot[1,i] := t;
if Pot[11,i] <> 255 then Lin_st[2,i] := Lin_st[2,i] + 1;
if Pot[7,i] <> 255 then Lin_st[0,i] := Lin_st[0,i] + 1;
if Pot[1,i] <> 255 then Lin_st[1,i] := lin_st[1,i] + 1;
end;
Disp_pot (1,20);
end;

procedure rSide_scroll;

var i,j,t : integer;

begin
if no_p = 1 then
begin
for i:=1 to 20 do
begin
t := pot[1,i];
for j:=1 to 9 do
pot[j,i] := pot[j+1,i];
pot[10,i] := t;
end;
end else
for i:=1 to 20 do
begin
t := pot[1,i];
if Pot[11,i] <> 255 then Lin_st[2,i] := Lin_st[2,i] - 1;
if Pot[7,i] <> 255 then Lin_st[0,i] := Lin_st[0,i] - 1;
if Pot[1,i] <> 255 then Lin_st[1,i] := lin_st[1,i] - 1;
for j:=1 to 15 do
pot[j,i] := pot[j+1,i];
pot[16,i] := t;
if Pot[16,i] <> 255 then Lin_st[2,i] := Lin_st[2,i] + 1;
if Pot[10,i] <> 255 then Lin_st[0,i] := Lin_st[0,i] + 1;
if Pot[6,i] <> 255 then Lin_st[1,i] := lin_st[1,i] + 1;
end;
Disp_pot (1,20);
end;

procedure Side_scroll;

begin
if scr_dir then lside_scroll
else rside_scroll;
end;

procedure Sound_full_line;

begin
if not sound_flag then exit;
Sound (300);
Delay (20);
Sound (200);
Delay (20);
Sound (400);
Delay (20);
Nosound;
end; { Sound_full_line }

procedure Check_full_line;

Label exitl,exitl1,exitl2,exitl3,exitl4,exitl5;

var i : integer;
Ed_l : integer;
ST_l : integer;
sed : integer;
j : integer;
Floc : integer;
k,l,sk,ek : integer;
Strt_l,End_l : integer;
gp : boolean;

begin
if no_p = 1 then
begin
Floc := 0;
for i := 20 downto 1 do
if Lin_st[1,i] = 10 then
begin
Floc := i;
goto exitl1;
end;
exitl1:
if Floc = 0 then goto exitl;
ST_l := Floc;
Ed_l := Floc;
while (Lin_st[1,Ed_l]<>0) and (Ed_l > 0 ) do
begin
if Lin_st[1,Ed_l] <> 10 then
begin
for k := 1 to 10 do
Pot[k,Floc] := Pot[k,Ed_l];
Lin_st[1,Floc] := Lin_st[1,Ed_l];
Floc := Floc -1;
end else
begin { else }
Fl_cnt[true] := Fl_cnt[true] + 1;
Atxy ( px + 1, py + Ed_l );
for i:=1 to 10 do
begin
Set_back (0);
if odd(i) then
Set_color (3)
else Set_color (19);
write (' ':0);
end; { for }
Sound_full_line;
end; { else }
Ed_l := Ed_l - 1;
end; { while }
for j := Ed_l + 1 to Floc do
begin
for k :=1 to 10 do
Pot[k,j] := 255;
Lin_st[1,j] := 0;
end;
Disp_pot ( Ed_l,ST_l );
if (Fl_cnt[true] > Levup_pt[Level[true]]) and (level[true] < 9 ) then
begin
level[true] := Level[true] + 1;
Time_fact[true] := Time_fact[true] - 5;
end;
end else{ if }
begin
Floc := 0;
Strt_l := 0;
sed := 20;
for i:= 1 to 20 do Mmark[i] := False;
for i := 20 downto 1 do
if (Lin_st[1,i]+Lin_st[0,i] = 10 )then
begin
Floc := i;
goto exitl2;
end;
exitl2:
if Floc = 0 then goto exitl3;
ST_l := Floc;
Ed_l := Floc;
while (Lin_st[1,Ed_l]+Lin_st[0,Ed_l]<>0) and (Ed_l > 0 ) do
begin
if Lin_st[1,Ed_l]+Lin_st[0,Ed_l] <> 10 then
begin
for k := 1 to 6 do
Pot[k,Floc] := Pot[k,Ed_l];
Lin_st[1,Floc] := Lin_st[1,Ed_l];
Floc := Floc -1;
end else
begin
Fl_cnt[true] := Fl_cnt[true] + 1;
Sound_full_line;
Mmark[Ed_l] := True;
end;
Ed_l := Ed_l - 1;
end; { while }
for j := Ed_l+1 to Floc do
begin
for k :=1 to 6 do
Pot[k,j] := 255;
Lin_st[1,j] := 0;
end;
strt_l := St_l;
sed := Ed_l;
exitl3:
Floc := 0;
for i := 20 downto 1 do
if (Lin_st[2,i]+Lin_st[0,i] = 10 ) then
begin
Floc := i;
goto exitl4;
end;
exitl4:
if Floc = 0 then goto exitl5;
ST_l := Floc;
Ed_l := Floc;
while (Lin_st[2,Ed_l]+Lin_st[0,Ed_l]<>0) and (Ed_l > 0 ) do
begin
if (Lin_st[2,Ed_l]+Lin_st[0,Ed_l] <> 10) then
begin
for k := 11 to 16 do
Pot[k,Floc] := Pot[k,Ed_l];
Lin_st[2,Floc] := Lin_st[2,Ed_l];
Floc := Floc -1;
end else
begin
Fl_cnt[false] := Fl_cnt[false] + 1;
Sound_full_line;
Mmark[Ed_l] := Mmark[Ed_l] or True;
end;
Ed_l := Ed_l - 1;
end; { while }
for j := Ed_l+1 to Floc do
begin
for k :=11 to 16 do
Pot[k,j] := 255;
Lin_st[2,j] := 0;
end;
if Strt_l < st_l then Strt_l := St_l;
if sed > Ed_l then sed := Ed_l;
Exitl5:
if Strt_l = 0 then goto exitl;
Floc := Strt_l;
End_l := Strt_l;
while (sed < End_l) and (End_l > 0 ) do
begin
if not Mmark[End_l] then
begin
for k:=7 to 10 do
Pot[k,Floc] := Pot[k,End_l];
Lin_st[0,Floc] := Lin_st[0,End_l];
Floc := Floc - 1;
end;
End_l := End_l - 1;
end;
for j := End_l+1 to Floc do
begin
for k :=7 to 10 do
Pot[k,j] := 255;
Lin_st[0,j] := 0;
end;
Disp_pot ( End_l,STrt_l );
for gp := false to true do
if (Fl_cnt[gp] > Levup_pt[Level[gp]]) and (level[gp] < 9 ) then
begin
level[gp] := Level[gp] + 1;
Time_fact[gp] := Time_fact[gp] - 5;
end;
end; { else }
exitl:
end; { Check_full_line }

procedure Prt_stat ( Sc_flag : boolean; p : boolean );
var lx,ly,i,j : integer;

begin
Set_back (0);
Set_color (4);
if p then begin
lx := 2;
ly := 1;
end
else begin
lx := 31;
ly := 1;
end;
atxy (lx,ly);
if p then write ('Player 1')
else write ('Player 2');
Set_color (7);
if p then begin
lx := level1_x;
ly := level1_y;
end
else begin
lx := level2_x;
ly := level2_y;
end;
Atxy (lx,ly);
Disp_str ('Level',' ');
Atxy (lx+2,ly+1);
write (level[p]:2);
if p then begin
lx := fl1_x;
ly := fl1_y;
end
else begin
lx := fl2_x;
ly := fl2_y;
end;
Atxy (lx,ly);
Disp_str ('Full',' ');
Atxy (lx,ly+1);
Disp_str ('Lines',' ');
Atxy (lx+2,ly+2);
write (Fl_cnt[p]:2);
if p then begin
lx := Score1_x;
ly := Score1_y;
end
else begin
lx := Score2_x;
ly := Score2_y;
end;
Atxy (lx,ly);
Disp_str ('SCORE',' ');
Atxy (lx+1,ly+1);
Set_color (6);
if Sc_flag then
write (Score[p]:5,' ');
if Score[p] >= Alm_pt then
begin
Alm_pt := Alm_pt + 1000;
scr_dir := not scr_dir;
if full_flag then
begin
if no_p = 1 then Lin_st[1,20] := 10
else begin
Lin_st[1,20] := 6;
Lin_st[2,20] := 6;
Lin_st[0,20] := 4;
end;
Check_full_line;
end;
if sound_flag then
begin
Sound (1000);
Delay (8);
Sound (500);
Delay (8);
Sound (1000);
Delay (8);
Sound (500);
Delay (8);
Nosound;
end;
end;
end; { Prt_stat }


procedure Key_proc(p:boolean);
var cc : char;

begin
cc := #$01;
if keypressed then
CC := Readkey;
CC := upcase(cc);
if cc = Esc then
if keypressed then CC := Readkey
else Load_screen;
if cc=^S then Sound_flag := not Sound_flag;
keyp_flag :=false;
if cc in [#67,#59,'Z',#79,'1',#77,'6',#75,#32,'4',#71,'7',#72,'8',#73
,'9',#13,#62,'A','Q','W','E'] then keyp_flag := true;
case cc of
#67 : if (level[true] < 9) and End_c[true]
then { level up }
begin
level[true] := level[true] + 1;
Time_fact[true] := Time_fact[true] - 5;
Prt_stat (false,true);
end;
#59,'Z' : if End_c[true] then
begin { view next }
View_next[true] := not (View_next[true]);
if View_next[true] then Disp_nextt(true)
else Clr_nextt(true);
end;
#79,'1' : if (no_p=2) and End_c[false] then
begin { view next }
View_next[false] := not (View_next[false]);
if View_next[false] then Disp_nextt(false)
else Clr_nextt(false);
end;
#77,'6' : if (no_p=2) and (level[false] < 9) and End_c[false]
then { level up }
begin
level[false] := level[false] + 1;
Time_fact[false] := Time_fact[false] - 5;
Prt_stat (false,false);
end;
end;
if no_p = 1 then
begin
case cc of
#75,#32,'4' : Drop; { drop }
#71,'7' : Left; { left }
#72,'8' : Rotate; { rotate }
#73,'9' : Right; { right }
#79,'1' : begin { view next }
View_next[p] := not (View_next[p]);
if View_next[p] then Disp_nextt(p)
else Clr_nextt(p);
end;
#77,'6' : if (level[p] < 9) and End_c[p]
then { level up }
begin
level[p] := level[p] + 1;
Time_fact[p] := Time_fact[p] - 5;
Prt_stat (false,p);
end;

end
end
else if not p then
case cc of
#75,#13,'4' : Drop; { drop }
#71,'7' : Left; { left }
#72,'8' : Rotate; { rotate }
#73,'9' : Right; { right }
end else
case cc of
'A',#62 : Drop; { drop }
'Q' : Left; { left }
'W' : Rotate; { rotate }
'E' : Right; { right }
end { case }
end; { Key_proc }

procedure End_game (p : boolean);

var j : integer;

begin
for j := 1 to 25 do
Begin
if sound_flag then
begin
Sound (j * 300 + 200);
Delay (4);
end;
end;
Nosound;
disp_gameover (p);
end;

procedure kdelay (cntd : integer; bd : boolean);
var i: integer;
begin
for i:=1 to cntd do
begin
delay(1);
if keypressed then
begin
key_proc(bd);
if keyp_flag then exit;
end;
end;
end;

Begin { main }
Get_crtmod;
Save_screen;
Init_tet;
Randomize;
Run_count := 1;
sound_flag := true;
Logo;
Scoreb_main (false);
loop:
loop1:
Set_crtmod (3);
Clrscr;
Gotoxy (16,12);
write ('How many Players (1-2) [1] > ');
Ch := Readkey;
if Ch=Esc then
if Keypressed then
Ch := Readkey
else Load_screen;
if ch in ['1'..'2']
then No_p := ord(ch) - (ord('0') )
else No_p := 1;
write (No_p);
if No_p = 1 then
begin
Input_level(True);
Level[True] := Ent_lev[True];
Time_fact[True] := 52 - (5 * level[True]);
Level[False] := 0;
Px := Pot1_x;
Py := Pot1_y;
Pz := 10;
end else
begin
for tb :=true downto false do
begin
Input_level(tb);
level[tb] := Ent_lev[tb];
Time_fact[tb] := 50 - (5 * level[tb]);
end;
Px := Pot2_x;
Py := Pot2_y;
Pz := 16;
end;
Input_mode;
Initialize;
scr_dir := true;
Clrscr;
Make_GScr;
if no_p=2 then Prt_stat (True,false);
Prt_stat (True,true);
Turn := true;
All_end := True;
while All_end do
begin
End_c[Turn] := Check_endgame(turn);
if End_c[turn] then
begin
while keypressed do
ch := readkey;
Movok := false;
repeat
kdelay (Time_fact[Turn] * 4,turn);
Key_proc(turn);
Move_tet(turn);
kdelay (Time_fact[Turn] * 4,turn);
Key_proc(turn);
if rotris then rot;
until Movok;
Set_pott(turn);
Check_full_line;
Prt_stat ( True,Turn);
if scrol_flag then Side_scroll;
end else End_game(turn);
if No_p = 1 then Turn := Turn
else if End_c[not turn] then Turn := not Turn
else Turn := Turn;
if No_p =1 then All_end := End_c[True]
else All_end := End_c[True] or End_c[False];
end; { while }
for Gen_B := 1 to 10 do
Begin
if sound_flag then
begin
Sound (Gen_B * 300 + 200);
Delay (4);
end;
end;
Nosound;
Wait_key;
Gen_B := 0;
while (Gen_B< 10000) and (not Keypressed) do
begin { while }
Delay (10);
Gen_B := Gen_B + 1;
end; { while }
Ch := Readkey;
case Upcase(Ch) of
Esc : if not keypressed then Load_screen;
'R' : Goto loop1;
end; { case }
Wait_key;
Clrscr;
Set_crtmod (3);
Grade_mk := 0;
for tb := true downto false do
if Score[tb] > Scor_arr[20].sco then
Enter_name(tb);
Scoreb_main (True);
Run_count := Run_count + 1;
gotoxy (1,25);
Wait_key;
Write ('Once more? (Y/N) > ');
Ch := Readkey;
if (ch=Esc) and (not Keypressed) then Load_screen;
if upcase(Ch) <> 'N' then
begin
Write ('Yes');
goto loop
end;
Write ('No');
Load_screen;
End. { main }
목록
내 글 수정·삭제

함께 나눈 이야기

댓글

댓글 남기기

이미지와 영상은 본문에 표시됩니다. 삭제한 첨부와 본문 연결은 수정 저장할 때 함께 반영됩니다.

취소

작성자 삭제 후에도 삭제 안내가 남으며 운영자는 원문을 확인할 수 있습니다.