home *** CD-ROM | disk | FTP | other *** search
- Uses crt;
-
- Type T3d=Record
- x : longint;
- y : longint;
- z : longint;
- end;
-
- T2d=Record
- x : longint;
- y : longint;
- end;
-
- Tpoint = Record
- map : T3d;
- coords : T3d;
- ScreenCoords : T2d;
- end;
-
- Const sorok=5;
- pointn=500;
- M=400;
- P=500;
- CENTX=160;
- CENTY=100;
- szoveg : array[1..sorok] of string=
- ('DEMO ROVAT',
- 'Hasonlít nem?',
- 'Nem olyan, mint az eredeti',
- 'De azért elmegy...',
- 'Blaa Blaa Blaaa');
- ztab : array[1..8] of integer=(8,6,3,2,2,3,6,8);
- mt : array[1..6,1..6] of byte=((0,0,4,4,0,0),
- (0,4,4,4,4,0),
- (4,4,4,4,4,4),
- (4,4,4,4,4,4),
- (0,4,4,4,4,0),
- (0,0,4,4,0,0));
- Var charset: array[1..2048] of byte;
- ScreenSeg: word;
- sint,cost: array[0..511] of longint;
- points: array[1..pointn] of Tpoint;
- text : array[1..1000] of Tpoint;
- rotmatr : array[1..3,1..3] of longint;
- tpoints,actsor : integer;
- a,b,c,g,t,db,dc,da,veg : integer;
-
- Procedure FillTables;
- var n : integer;
- begin
- for n:=0 to 511 do
- begin
- sint[n]:=round(256*sin(n*2*pi/512));
- cost[n]:=round(256*cos(n*2*pi/512));
- end;
- end;
-
- procedure fillpoints;
- var x,y,n : integer;
- begin
- randomize;
- points[1].map.x:=-160;points[2].map.x:=160;
- points[1].map.z:=0;points[2].map.z:=0;
- points[1].map.y:=40;points[2].map.y:=90;
- for n:=3 to pointn do
- begin
- points[n].map.x:=longint(random(300))-150;
- points[n].map.y:=longint(random(250))-125;
- points[n].map.z:=longint(random(50));
- end;
- end;
-
-
- Procedure GetCharSet(buffer : word); Assembler;
- asm
- push ds
- push es
- push bp
-
- mov ax,1130h
- mov bh,03h
- int 10h
- mov cx,2048
- mov si,bp
- pop bp
-
- push es
- push ds
- pop es
- pop ds
- mov di,buffer
- rep movsb
-
- pop es
- pop ds
- end;
-
- procedure initscreen;
- var p: pointer;
- begin
- getmem(p,65535);
- ScreenSeg:=seg(p^);
- asm
- push es
-
- xor ax,ax
- mov cx,32000
- mov es,screenseg
- mov di,0
- rep stosw
-
- mov ax,13h
- int 10h
-
- pop es
- end;
- end;
-
- procedure dopal(c,r,g,b:byte);assembler;
- asm
- mov dx,3c8h
- mov al,c
- out dx,al
- inc dx
- mov al,r
- out dx,al
- mov al,g
- out dx,al
- mov al,b
- out dx,al
- end;
-
- procedure setpal;
- var n: integer;
- begin
- for n:=0 to 255 do dopal(n,0,0,0);
- dopal(1,16,16,16);
- dopal(2,32,32,32);
- dopal(3,48,48,48);
- dopal(4,63,63,63);
- end;
-
- procedure blur; assembler;
- asm
- push ds
-
- mov ds, ScreenSeg
- xor si,si
- mov cx,64000
- mov al,0
- @cik:
- cmp [si],al
- jz @tov
- mov ah,[si]
- dec ah
- mov [si],ah
- @tov:
- inc si
- loop @cik
- @ki:
-
- pop ds
- end;
-
- procedure dump; assembler;
- asm
- push ds
- push es
-
- mov ds,ScreenSeg
- mov ax,0a000h
- mov es,ax
- xor si,si
- xor di,di
-
- mov cx,32000
- rep movsw
-
- pop es
- pop ds
- end;
-
- function bitset(d : byte; b : byte) : boolean;
- begin
- if (d and (1 shl b))<>0 then bitset:=true else bitset:=false;
- end;
-
- procedure buildtext;
- var cnx,cny,actchar : integer;
- chx,chy,tp :integer;
- begin
- cny:=4;
- cnx:=-160;
- tp:=1;
- for actchar:=1 to length(szoveg[actsor]) do
- begin
- for chx:=1 to 8 do
- for chy:=1 to 8 do
- begin
- if bitset(charset[8*word(szoveg[actsor][actchar])+chy],chx) then
- begin
- text[tp].map.x:=(actchar*8-chx)*5-cnx;
- text[tp].map.y:=(chy-1)*5-cny;
- text[tp].map.z:=ztab[chx];
- tp:=tp+1;
- end;
- end;
- end;
- tpoints:=tp-1;
- end;
-
- procedure pp(x : word; y : word; c : byte); assembler;
- asm
- push es
-
- cmp x,319
- ja @ki
- cmp y,200
- ja @ki
-
- mov ax,320
- mul y
- add ax,x
- mov di,ax
- mov es,screenseg
- mov al,4
- cmp es:[di],al
- jnl @ki
- mov al,c
- mov es:[di],al
-
- @ki:
- pop es
- end;
-
- procedure mugli(x: integer; y: integer);
- var n,m: integer;
- begin
- for n:=1 to 6 do
- for m:=1 to 6 do
- pp(x-3+n,y-3+m,mt[n,m]);
- end;
-
- procedure shifttext;
- var n: integer;
- begin
- veg:=1;
- for n:=1 to tpoints do
- begin
- dec(text[n].map.x);
- if text[n].map.x>-160 then veg:=0;
- end;
- end;
-
- procedure puttext;
- var n: integer;
- begin
- for n:=1 to tpoints do
- begin
- if (text[n].map.x>=points[1].map.x) and (text[n].map.x<=points[2].map.x) then
- mugli(text[n].screencoords.x,text[n].screencoords.y);
- end;
- end;
-
- procedure putpoints;
- var n : integer;
- begin
- for n:=1 to 100 do pp(points[n].screencoords.x,points[n].screencoords.y,4);
- end;
-
- procedure comp(a,b,c : integer);
- var n,i : integer;
- begin
- rotmatr[1,1]:=(cost[a]*cost[c]-((sint[a]*sint[b]) div 256)*sint[c]) div 256;
- rotmatr[1,2]:=(-cost[c]*sint[a]-((sint[b]*cost[a]) div 256)*sint[c]) div 256;
- rotmatr[1,3]:=(sint[c]*cost[b]) div 256;
- rotmatr[2,1]:=(sint[a]*cost[b]) div 256;
- rotmatr[2,2]:=(cost[b]*cost[a]) div 256;
- rotmatr[2,3]:=sint[b];
- rotmatr[3,1]:=(sint[c]*cost[a]+((cost[c]*sint[b]) div 256)*sint[a]) div 256;
- rotmatr[3,2]:=(((cost[c]*sint[b]) div 256)*cost[a]-sint[c]*sint[a]) div 256;
- rotmatr[3,3]:=-(cost[b]*cost[c]) div 256;
-
- for i:=1 to tpoints do
- begin
- text[i].coords.x:=(text[i].map.x*rotmatr[1,1]+text[i].map.y*rotmatr[1,2]-text[i].map.z*rotmatr[1,3]) div 256;
- text[i].coords.y:=(text[i].map.x*rotmatr[2,1]+text[i].map.y*rotmatr[2,2]-text[i].map.z*rotmatr[2,3]) div 256;
- text[i].coords.z:=(text[i].map.x*rotmatr[3,1]+text[i].map.y*rotmatr[3,2]-text[i].map.z*rotmatr[3,3]) div 256;
- end;
-
- for n:=1 to tpoints do
- begin
- if text[n].coords.z+p>0 then text[n].screencoords.x:=round((M*text[n].coords.x)/(text[n].coords.z+P))+CENTX
- else text[n].screencoords.x:=-10;
- if text[n].coords.z+P>0
- then text[n].screencoords.y:=round(M*(text[n].coords.y)/(text[n].coords.z+P))+CENTY
- +(sint[((text[n].screencoords.x shl 3)+40*t) and 511] div 64) else text[n].screencoords.x:=-10;
- end;
-
- for i:=1 to pointn do
- begin
- points[i].coords.x:=((points[i].map.x)*rotmatr[1,1]+points[i].map.y*rotmatr[1,2]-points[i].map.z*rotmatr[1,3]) div 256;
- points[i].coords.y:=((points[i].map.x)*rotmatr[2,1]+points[i].map.y*rotmatr[2,2]-points[i].map.z*rotmatr[2,3]) div 256;
- points[i].coords.z:=((points[i].map.x)*rotmatr[3,1]+points[i].map.y*rotmatr[3,2]-points[i].map.z*rotmatr[3,3]) div 256;
- end;
-
- for n:=1 to pointn do
- begin
- if points[n].coords.z+p>0 then points[n].screencoords.x:=round((M*points[n].coords.x)/(points[n].coords.z+P))+CENTX
- else points[n].screencoords.x:=-10;
- if points[n].coords.z+P>0
- then points[n].screencoords.y:=round(M*(points[n].coords.y)/(points[n].coords.z+P))+CENTY else points[n].screencoords.x:=-10;
- end;
- end;
-
- Begin
- FillTables;
- Fillpoints;
- GetCharSet(word(@CharSet));
- db:=4;dc:=3;da:=1;
- initscreen;
- SetPal;
- actsor:=1;
- buildtext;
- veg:=0;
- repeat
- blur;
- comp(a and 511,b and 511,c and 511);
- shifttext;
- puttext;
- putpoints;
- dump;
- if (a>111) or (a<-111) then da:=-da;
- if (b>111) or (b<-111) then db:=-db;
- if (c>111) or (c<-111) then dc:=-dc;
- a:=a+da;
- c:=c+dc;
- b:=b+db;
- t:=t+1;
- if veg=1 then
- begin
- if actsor<sorok then inc(actsor) else actsor:=1;
- buildtext;
- end;
- delay(100);
- until keypressed;
-
- asm
- mov ax,3
- int 10h
- end;
- End.