mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 10:45:08 +02:00
moved files
This commit is contained in:
parent
efb422174d
commit
8f74054daf
1170
install/demo/modex/Makefile
Normal file
1170
install/demo/modex/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
45
install/demo/modex/Makefile.fpc
Normal file
45
install/demo/modex/Makefile.fpc
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Makefile.fpc for FPC modex demos (part of FPC demo paackage)
|
||||
#
|
||||
|
||||
[targets]
|
||||
programs_go32v2=voxel
|
||||
|
||||
[require]
|
||||
# Not always necessary, but saves a lot of trouble
|
||||
packages=api
|
||||
|
||||
[install]
|
||||
|
||||
[defaults]
|
||||
defaultrule=all
|
||||
|
||||
[dirs]
|
||||
fpcdir=../..
|
||||
targetdir=.
|
||||
|
||||
[postsettings]
|
||||
|
||||
[rules]
|
||||
ifeq ($(OS_TARGET),win32)
|
||||
vpath %$(PASEXT) win32
|
||||
endif
|
||||
|
||||
clean : execlean fpc_cleanall
|
||||
|
||||
execlean:
|
||||
|
||||
#################################
|
||||
# Demo installation for linux
|
||||
#
|
||||
|
||||
.PHONY: installexamples
|
||||
|
||||
ifndef EXAMPLESINSTALLDIR
|
||||
EXAMPLESINSTALLDIR=$(DOCINSTALLDIR)/examples
|
||||
endif
|
||||
|
||||
installexamples:
|
||||
$(MKDIR) $(EXAMPLESINSTALLDIR)
|
||||
$(COPYTREE) * $(EXAMPLESINSTALLDIR)
|
||||
|
188
install/demo/modex/voxel.pp
Normal file
188
install/demo/modex/voxel.pp
Normal file
@ -0,0 +1,188 @@
|
||||
{
|
||||
$Id$
|
||||
|
||||
This program is part of the FPC demoes.
|
||||
Copyright (C) 1999 by Marco van de Voort
|
||||
|
||||
A port of a more "dirty" graphical program, to demonstrate
|
||||
some Go32 features. The program displays a landscape in which
|
||||
you can move with the cursorkeys
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
The sources for this game was found in SWAG, and was also posted to the
|
||||
International FIDO Pascal area.
|
||||
I assume that it is PD (both sources said nothing about the form of copyrights,
|
||||
but it was contributed to SWAG, which is generally PD)
|
||||
|
||||
If there is somebody that claims authorship of these programs,
|
||||
please mail marco@freepascal.org, and the sources will be removed from our
|
||||
websites.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
There was no real original, I reconstructed some from several versions.
|
||||
|
||||
A voxel source from Swag patched for FPC.
|
||||
|
||||
- The original author was unknown. I saw a different version which named
|
||||
"Borek" (Marcin Borkowski), 2:480/25 as author.
|
||||
- Bas van Gaalen donated it to SWAG.
|
||||
- I, Marco van de Voort made some small FPC adjustments.
|
||||
- However one problem remained (wrapping of arrays), and Jonas Maebe mailed me
|
||||
that glitch to me. This practically meant putting all those WORD()
|
||||
typecasts in the array-parameters.
|
||||
|
||||
Still BP compatible, Gameunit contains some BP alternatives for Go32
|
||||
procedures needed.}
|
||||
|
||||
PROGRAM voxel;
|
||||
|
||||
|
||||
USES Crt,Dos {$IFDEF FPC}, Go32{$ENDIF};
|
||||
|
||||
type lrgarr=array[0..65534] of byte;
|
||||
const
|
||||
pal:array[1..384] of byte=(
|
||||
0,0,0,48,48,48,1,0,43,1,3,43,2,5,44,2,7,44,3,9,45,4,11,46,5,13,47,6,15,48,
|
||||
7,17,49,8,19,50,9,21,51,10,22,52,11,24,52,12,26,54,13,28,54,14,30,56,15,32,
|
||||
56,16,34,58,17,34,58,17,36,58,18,38,60,19,40,60,20,42,62,21,44,62,10,31,0,
|
||||
11,31,0,11,31,1,11,32,1,12,32,1,12,32,2,12,33,2,13,33,2,14,33,3,15,33,3,15,
|
||||
34,3,15,34,4,15,35,4,16,35,4,16,35,5,16,36,5,17,36,5,17,36,6,18,37,6,18,38,
|
||||
7,19,38,8,20,39,8,20,40,9,21,40,10,22,41,10,22,42,11,23,42,12,24,43,12,24,
|
||||
44,13,25,44,14,25,45,14,26,46,15,27,46,16,27,47,17,28,47,18,28,48,19,29,49,
|
||||
19,30,49,20,30,50,21,31,51,21,32,51,22,32,52,23,33,53,23,34,53,24,34,54,25,
|
||||
35,55,25,36,55,26,36,56,27,37,57,27,38,57,27,39,57,27,41,57,27,42,57,27,43,
|
||||
57,27,44,57,27,45,57,27,46,57,27,47,57,27,49,57,27,50,57,27,51,57,27,52,57,
|
||||
27,53,57,27,55,57,27,56,57,27,57,57,27,58,57,27,58,57,26,58,57,25,58,57,24,
|
||||
58,56,23,58,55,22,58,54,20,58,53,19,58,51,18,58,50,17,58,50,16,58,49,15,58,
|
||||
48,14,58,47,13,58,46,12,58,45,11,58,44,11,58,44,10,58,43,10,58,42,9,57,41,
|
||||
8,57,40,8,56,39,7,56,38,6,55,37,5,55,35,4,54,33,4,54,31,2,32,32,32,63,63,63,
|
||||
63,63,63,63,63,63,63,63,63,48,48,48,63,63,63,63,63,63);
|
||||
|
||||
VAR
|
||||
MP,Scr : ^lrgarr;
|
||||
rng : array[0..320] of byte;
|
||||
dir,i,x,y : integer;
|
||||
|
||||
function ncol(mc,n,dvd:integer):integer;
|
||||
var loc:integer;
|
||||
begin
|
||||
loc:=(mc+n-random(2*n)) div dvd; ncol:=loc;
|
||||
if loc>250 then ncol:=250; if loc<5 then ncol:=5
|
||||
end;
|
||||
|
||||
procedure plasma(x1,y1,x2,y2:word);
|
||||
var xn,yn,dxy,p1,p2,p3,p4:word;
|
||||
begin
|
||||
if (x2-x1<2) and (y2-y1<2) then
|
||||
exit;
|
||||
p1:=mp^[WORD(256*y1+x1)]; p2:=mp^[WORD(256*y2+x1)]; p3:=mp^[WORD(256*y1+x2)];
|
||||
p4:=mp^[WORD(256*y2+x2)]; xn:=(x2+x1) shr 1; yn:=(y2+y1) shr 1;
|
||||
dxy:=5*(x2-x1+y2-y1) div 3;
|
||||
if mp^[WORD(256*y1+xn)]=0 then mp^[WORD(256*y1+xn)]:=ncol(p1+p3,dxy,2);
|
||||
if mp^[WORD(256*yn+x1)]=0 then mp^[WORD(256*yn+x1)]:=ncol(p1+p2,dxy,2);
|
||||
if mp^[WORD(256*yn+x2)]=0 then mp^[WORD(256*yn+x2)]:=ncol(p3+p4,dxy,2);
|
||||
if mp^[WORD(256*y2+xn)]=0 then mp^[WORD(256*y2+xn)]:=ncol(p2+p4,dxy,2);
|
||||
mp^[WORD(256*yn+xn)]:=ncol(p1+p2+p3+p4,dxy,4);
|
||||
plasma(x1,y1,xn,yn); plasma(xn,y1,x2,yn);
|
||||
plasma(x1,yn,xn,y2); plasma(xn,yn,x2,y2);
|
||||
end;
|
||||
|
||||
procedure draw(xp,yp,dir:integer);
|
||||
var z,zobs,ix,iy,iy1,iyp,ixp,x,y,s,csf,snf,mpc,i,j:integer;
|
||||
begin
|
||||
fillchar(rng,sizeof(rng),200); zobs:=100+mp^[WORD(256*yp+xp)];
|
||||
csf:=round(256*cos(Real(dir)/180*pi)); snf:=round(256*sin(Real(dir)/180*pi));
|
||||
fillchar(scr^,64000,0);
|
||||
for iy:=yp to yp+55 do
|
||||
begin
|
||||
iy1:=1+2*(iy-yp); s:=4+300 div iy1;
|
||||
for ix:=xp+yp-iy to xp-yp+iy do
|
||||
begin
|
||||
ixp:=xp+((ix-xp)*csf+(iy-yp)*snf) shr 8;
|
||||
iyp:=yp+((iy-yp)*csf-(ix-xp)*snf) shr 8;
|
||||
x:=160+360*(ix-xp) div iy1;
|
||||
if (x>=0) and (x+s<=318) then
|
||||
begin
|
||||
z:=mp^[WORD(iyp shl 8+ixp)]; mpc:=z shr 1;
|
||||
if z<47 then z:=46; y:=100+(zobs-z)*30 div iy1;
|
||||
if (y<=199) and (y>=0) then
|
||||
for j:=x to x+s do
|
||||
begin
|
||||
for i:=y to rng[j] do
|
||||
scr^[WORD(320*i+j)]:=mpc;
|
||||
if y<rng[WORD(j)] then rng[WORD(j)]:=y
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$IFDEF FPC}
|
||||
DosMemPut($A000,0,Scr^,64000);
|
||||
{$ELSE}
|
||||
Move(Scr^,mem[$A000:0],64000);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
VAR Reg : Registers;
|
||||
|
||||
begin
|
||||
writeln('creating landscape...');
|
||||
randomize; x:=0; y:=0; dir:=0; new(mp); fillchar(mp^,65535,0);
|
||||
new(scr); mp^[$0000]:=128; plasma(0,0,256,256);
|
||||
Reg.ax:=$13; Intr($10,Reg);
|
||||
{$IFDEF FPC}
|
||||
Outportb($3C8,0);
|
||||
for i:=1 to 384 do OutPortb($3c9,pal[i]);
|
||||
{$ELSE}
|
||||
Port[$3C8] := 0;
|
||||
for i:=1 to 384 do Port[$3c9] := pal[i];
|
||||
{$ENDIF}
|
||||
repeat
|
||||
dir:=dir mod 360;
|
||||
draw(x,y,dir);
|
||||
case readkey of
|
||||
#0:case readkey of
|
||||
#75:dec(dir,10);
|
||||
#77:inc(dir,10);
|
||||
#72:begin
|
||||
y:=y+round(5*cos(Real(dir)/180*pi));
|
||||
x:=x+round(5*sin(Real(dir)/180*pi));
|
||||
end;
|
||||
#80:begin
|
||||
y:=y-round(5*cos(Real(dir)/180*pi));
|
||||
x:=x-round(5*sin(Real(dir)/180*pi));
|
||||
end;
|
||||
end;
|
||||
#27: begin
|
||||
Reg.ax:=$3;
|
||||
Intr($10,Reg);
|
||||
halt
|
||||
end
|
||||
end
|
||||
until false;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:48:10 alex
|
||||
moved files
|
||||
|
||||
Revision 1.4 2000/03/08 22:20:04 alex
|
||||
fixed warnings about type conversion
|
||||
|
||||
Revision 1.3 2000/02/22 04:12:42 alex
|
||||
removed game unit reference for non fpc version
|
||||
|
||||
Revision 1.2 2000/01/03 13:51:08 marco
|
||||
* Fixed broken comment
|
||||
|
||||
Revision 1.1 2000/01/01 14:58:01 marco
|
||||
* initial version
|
||||
|
||||
}
|
1168
install/demo/text/Makefile
Normal file
1168
install/demo/text/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
43
install/demo/text/Makefile.fpc
Normal file
43
install/demo/text/Makefile.fpc
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# Makefile.fpc for FPC text demos (part of FPC demo package)
|
||||
#
|
||||
|
||||
[targets]
|
||||
programs=eratos qsort hello blackbox magic lines
|
||||
|
||||
[require]
|
||||
# Not always necessary, but saves a lot of trouble
|
||||
packages=api
|
||||
|
||||
[defaults]
|
||||
defaultrule=all
|
||||
|
||||
[dirs]
|
||||
fpcdir=../..
|
||||
targetdir=.
|
||||
|
||||
[postsettings]
|
||||
|
||||
[rules]
|
||||
ifeq ($(OS_TARGET),win32)
|
||||
vpath %$(PASEXT) win32
|
||||
endif
|
||||
|
||||
clean : execlean fpc_cleanall
|
||||
|
||||
execlean:
|
||||
|
||||
#################################
|
||||
# Demo installation for linux
|
||||
#
|
||||
|
||||
.PHONY: installexamples
|
||||
|
||||
ifndef EXAMPLESINSTALLDIR
|
||||
EXAMPLESINSTALLDIR=$(DOCINSTALLDIR)/examples
|
||||
endif
|
||||
|
||||
installexamples:
|
||||
$(MKDIR) $(EXAMPLESINSTALLDIR)
|
||||
$(COPYTREE) * $(EXAMPLESINSTALLDIR)
|
||||
|
201
install/demo/text/blackbox.pp
Normal file
201
install/demo/text/blackbox.pp
Normal file
@ -0,0 +1,201 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by Michael Van Canneyt
|
||||
|
||||
Blackbox Game Example
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
Program blackbox;
|
||||
|
||||
{
|
||||
The object of the game is simple : You have a box of 9x9x9 cells.
|
||||
you can enter a number of atoms that will be put in the box.
|
||||
Then you can start shooting in the box with a laser beam.
|
||||
You enter the coordinates where the beam enters the box.
|
||||
(this must be on the edges, this means that one of the coordinates
|
||||
must be 1 or 9...)
|
||||
The beam will bounce off the atoms (using normal bouncing), and you
|
||||
will be told where the beam exits.
|
||||
From this you must guess where the atoms are...
|
||||
}
|
||||
|
||||
Const MaxSize = 9;
|
||||
MaxAtom = 10;
|
||||
|
||||
Type TRow = Array [0..MaxSize+1] of byte;
|
||||
TPlane = Array [0..MaxSize+1] of TRow;
|
||||
TCube = Array [0..MaxSize+1] of TPlane;
|
||||
|
||||
Var
|
||||
Cube : TCube;
|
||||
Count,Guessed,x,y,z : Longint;
|
||||
ans : string;
|
||||
|
||||
Procedure FillCube;
|
||||
|
||||
var i,x,y,z : longint;
|
||||
|
||||
begin
|
||||
randomize;
|
||||
for x:=0 to maxsize+1 do
|
||||
for y:=0 to maxsize+1 do
|
||||
for z:=0 to maxsize+1 do
|
||||
Cube[x,y,z]:=0;
|
||||
repeat
|
||||
Write ('Enter number of atoms (1-',maxatom,') : ');
|
||||
readln (count);
|
||||
if (count<1) or (count>MaxAtom) then
|
||||
writeln ('Invalid value entered. Please try again.');
|
||||
until (count>0) and (count<=MaxAtom);
|
||||
for I:=1 to count do
|
||||
begin
|
||||
repeat
|
||||
x:=Random(MaxSize)+1;
|
||||
y:=Random(MaxSize)+1;
|
||||
z:=Random(MaxSize)+1;
|
||||
until Cube[x,y,z]=0;
|
||||
Cube[x,y,z]:=1;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure GetCoords (Var X,y,z : longint);
|
||||
|
||||
begin
|
||||
Write ('X : ');
|
||||
readln (x);
|
||||
write ('Y : ');
|
||||
readln (y);
|
||||
write ('z : ');
|
||||
readln (z);
|
||||
end;
|
||||
|
||||
Procedure GetStart (Var x,y,z : longint);
|
||||
|
||||
Var OK : boolean;
|
||||
|
||||
begin
|
||||
Writeln ('Please enter beam start coordinates : ');
|
||||
Repeat
|
||||
GetCoords (x,y,z);
|
||||
OK:=((X=1) or (X=MaxSize)) or ((y=1) or (Y=MaxSize)) or
|
||||
((Z=1) or (z=maxsize));
|
||||
if Not OK then
|
||||
writeln ('The beam should enter at an edge. Please try again');
|
||||
until OK;
|
||||
end;
|
||||
|
||||
Function GetGuess : boolean;
|
||||
|
||||
Var OK : boolean;
|
||||
x,y,z : longint;
|
||||
|
||||
begin
|
||||
Writeln ('Please enter atom coordinates : ');
|
||||
Repeat
|
||||
getcoords (x,y,z);
|
||||
OK:=((X>=1) or (X<=MaxSize)) or ((y>=1) or (Y<=MaxSize)) or
|
||||
((Z>=1) or (z<=maxsize));
|
||||
if Not OK then
|
||||
writeln ('These are not valid coordinates. Please try again');
|
||||
until OK;
|
||||
GetGuess:=False;
|
||||
If Cube[x,y,z]<0 then
|
||||
Writeln ('You already had this one ! Trying to be clever, eh ?')
|
||||
else if Cube[x,y,z]>0 then
|
||||
begin
|
||||
Writeln ('Correct guess !');
|
||||
Cube[x,y,z]:=-Cube[x,y,z];
|
||||
getguess:=true;
|
||||
end
|
||||
else
|
||||
Writeln ('Wrong guess !');
|
||||
end;
|
||||
|
||||
Procedure CalcExit (X,Y,Z : longint);
|
||||
|
||||
var tx,ty,tz,dx,dy,dz : longint;
|
||||
|
||||
begin
|
||||
dx:=0;dy:=0;dz:=0;
|
||||
if x=1 then dx:=1 else if x=MaxSize then dx:=-1;
|
||||
if y=1 then dy:=1 else if y=MaxSize then dy:=-1;
|
||||
if z=1 then dz:=1 else if z=MaxSize then dz:=-1;
|
||||
writeln ('Direction : ',dx,',',dy,',',dz);
|
||||
repeat
|
||||
for tx:=-1 to 1 do
|
||||
for ty:=-1 to 1 do
|
||||
for tz:=-1 to 1 do
|
||||
if Cube [X+tx,y+ty,z+tz]<>0 then
|
||||
begin
|
||||
dx:=dx-tx;
|
||||
dy:=dy-ty;
|
||||
dz:=dz-tz;
|
||||
end;
|
||||
if dx<>0 then dx:=dx div abs(dx);
|
||||
if dz<>0 then dz:=dz div abs(dz);
|
||||
if dy<>0 then dy:=dy div abs(dy);
|
||||
x:=x+dx;y:=y+dy;z:=z+dz;
|
||||
until ((x=0) or (x=MaxSize+1)) or ((y=0) or (y=maxsize+1)) or
|
||||
((z=0) or (z=maxsize+1));
|
||||
Writeln ('Beam exited at : (',x-dx,',',y-dy,',',z-dz,')');
|
||||
end;
|
||||
|
||||
{
|
||||
Procedure DumpCube ;
|
||||
|
||||
Var x,y,z : longint;
|
||||
|
||||
begin
|
||||
for x:=1 to MaxSize do
|
||||
for y:=1 to maxsize do
|
||||
for z:=1 to maxsize do
|
||||
if Cube[x,y,z]<>0 then
|
||||
writeln ('Atom at (',x,',',y,',',z,')');
|
||||
end;
|
||||
}
|
||||
|
||||
begin
|
||||
FillCube;
|
||||
Guessed:=0;
|
||||
Repeat
|
||||
repeat
|
||||
Write ('Shoot, guess or quit (s/g/q) : ');
|
||||
readln (ans);
|
||||
ans[1]:=Upcase(ans[1]);
|
||||
if not (ans[1] in ['S','G','Q']) then
|
||||
writeln ('Invalid entry. Please try again.');
|
||||
until ans[1] in ['S','G','Q'];
|
||||
Case ans[1] of
|
||||
'S' : begin
|
||||
getstart (x,y,z);
|
||||
calcexit (x,y,z);
|
||||
end;
|
||||
'G' : If GetGuess then Inc(Guessed);
|
||||
end;
|
||||
until (ans[1]='Q') or (guessed=count);
|
||||
If Guessed=count then
|
||||
Writeln ('Congratulations! All ',Count,' correct !')
|
||||
else
|
||||
Writeln ('Only ',guessed,' out of ',count,' correct...');
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:49:09 alex
|
||||
moved files
|
||||
|
||||
Revision 1.3 2000/02/22 03:14:17 alex
|
||||
fixed the warning
|
||||
|
||||
Revision 1.2 1998/09/11 10:55:20 peter
|
||||
+ header+log
|
||||
|
||||
}
|
66
install/demo/text/eratos.pp
Normal file
66
install/demo/text/eratos.pp
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by Florian Klaempfl
|
||||
|
||||
Eratos Example, Calculates all Prime Numbers from 1 to max
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
program eratosthenes;
|
||||
|
||||
const
|
||||
max = 1000000;
|
||||
var
|
||||
a : array[1..max] of boolean;
|
||||
|
||||
procedure eratos;
|
||||
|
||||
var
|
||||
i,j : longint;
|
||||
|
||||
begin
|
||||
a[1]:=false;
|
||||
for i:=1 to max do
|
||||
a[i]:=true;
|
||||
for i:=2 to max div 2 do
|
||||
if a[i] then
|
||||
for j:=2 to max div i do
|
||||
a[i*j]:=false;
|
||||
writeln;
|
||||
j:=0;
|
||||
for i:=1 to max do
|
||||
begin
|
||||
if a[i] then
|
||||
begin
|
||||
write(i:7);
|
||||
inc(j);
|
||||
if (j mod 10)=0 then
|
||||
writeln;
|
||||
end;
|
||||
end;
|
||||
writeln;
|
||||
end;
|
||||
|
||||
begin
|
||||
write('Calculating the Prime Numbers from 1 to ',max,'...');
|
||||
eratos;
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:49:09 alex
|
||||
moved files
|
||||
|
||||
Revision 1.5 1998/09/11 10:55:21 peter
|
||||
+ header+log
|
||||
|
||||
Revision 1.4 1998/09/04 17:38:15 pierre
|
||||
* the algorythm was wrong (unnecessary checks were made)
|
||||
}
|
22
install/demo/text/hello.pp
Normal file
22
install/demo/text/hello.pp
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by the Free Pascal Development Team
|
||||
|
||||
Hello World Example
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
program hello;
|
||||
|
||||
begin
|
||||
writeln('Hello world');
|
||||
end.
|
||||
|
85
install/demo/text/lines.pp
Normal file
85
install/demo/text/lines.pp
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by Florian Klaempfl
|
||||
|
||||
Line Counter Example
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
program count_lines;
|
||||
{
|
||||
Program that counts number of Lines in a file
|
||||
}
|
||||
|
||||
uses
|
||||
dos,crt;
|
||||
|
||||
type
|
||||
td = array[1..10000] of byte;
|
||||
|
||||
var
|
||||
lines : longint;
|
||||
s : searchrec;
|
||||
f : file;
|
||||
d : ^td;
|
||||
{$ifdef tp}
|
||||
count : word;
|
||||
i,z : integer;
|
||||
{$else}
|
||||
count,i,z : longint;
|
||||
{$endif}
|
||||
|
||||
begin
|
||||
lines:=0;
|
||||
new(d);
|
||||
if paramcount<1 then
|
||||
begin
|
||||
writeln('Usage: ',paramstr(0),' filename.ext [filename.ext] ...');
|
||||
writeln(' Multiple File Names and Wild Cards Allowed:');
|
||||
writeln(' Example: lines *.cpp stdio.h *.asm');
|
||||
halt(1);
|
||||
end;
|
||||
for i:=1 to paramcount do
|
||||
begin
|
||||
findfirst(paramstr(i),archive,s);
|
||||
while (doserror=0) do
|
||||
begin
|
||||
gotoxy(1,wherey);
|
||||
write(' ');
|
||||
gotoxy(1,wherey);
|
||||
write('Scanning: ',s.name);
|
||||
assign(f,s.name);
|
||||
reset(f,1);
|
||||
while not(eof(f)) do
|
||||
begin
|
||||
blockread(f,d^,10000,count);
|
||||
for z:=1 to count do
|
||||
if d^[z]=10 then inc(lines);
|
||||
end;
|
||||
close(f);
|
||||
findnext(s);
|
||||
end;
|
||||
end;
|
||||
dispose(d);
|
||||
gotoxy(1,wherey);
|
||||
write(' ');
|
||||
gotoxy(1,wherey);
|
||||
if lines=1 then writeln('1 Line') else writeln(lines,' Lines');
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:49:09 alex
|
||||
moved files
|
||||
|
||||
Revision 1.2 1998/09/11 10:55:23 peter
|
||||
+ header+log
|
||||
|
||||
}
|
||||
|
108
install/demo/text/magic.pp
Normal file
108
install/demo/text/magic.pp
Normal file
@ -0,0 +1,108 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by Florian Klaempfl
|
||||
|
||||
Magic Square Example
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
program magic;
|
||||
|
||||
{
|
||||
Calculate a magic square (sum of the row, colums and diagonals is equal
|
||||
}
|
||||
|
||||
const
|
||||
maxsize = 11;
|
||||
|
||||
type
|
||||
sqrtype = array[1..maxsize, 1..maxsize] of longint;
|
||||
|
||||
var
|
||||
square : sqrtype;
|
||||
size, row, sum : longint;
|
||||
|
||||
procedure makesquare(var sq : sqrtype;limit : longint);
|
||||
|
||||
var
|
||||
num,r,c : longint;
|
||||
|
||||
begin
|
||||
for r:=1 to limit do
|
||||
for c:=1 to limit do
|
||||
sq[r, c] := 0;
|
||||
if (limit and 1)<>0 then
|
||||
begin
|
||||
r:=(limit+1) div 2;
|
||||
c:=limit;
|
||||
for num:=1 to limit*limit do
|
||||
begin
|
||||
if sq[r,c]<>0 then
|
||||
begin
|
||||
dec(r);
|
||||
if r<1 then
|
||||
inc(r,limit);
|
||||
dec(c,2);
|
||||
if c<1 then
|
||||
inc(c,limit);
|
||||
end;
|
||||
sq[r,c]:=num;
|
||||
inc(r);
|
||||
if r>limit then
|
||||
dec(r,limit);
|
||||
inc(c);
|
||||
if c>limit then
|
||||
dec(c,limit);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure writesquare(var sq : sqrtype;limit : longint);
|
||||
|
||||
var
|
||||
row,col : longint;
|
||||
|
||||
begin
|
||||
for row:=1 to Limit do
|
||||
begin
|
||||
for col:=1 to (limit div 2) do
|
||||
write(sq[row,2*col-1]:4,' ',sq[row,2*col]:4,' ');
|
||||
writeln(sq[row,limit]:4);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
size:=3;
|
||||
while (size<=maxsize) do
|
||||
begin
|
||||
writeln('Magic Square with size ',size);
|
||||
writeln;
|
||||
makesquare(square,size);
|
||||
writesquare(square,size);
|
||||
writeln;
|
||||
sum:=0;
|
||||
for row:=1 to size do
|
||||
inc(sum,square[row,1]);
|
||||
writeln('Sum of the rows,columns and diagonals = ', sum);
|
||||
writeln;
|
||||
writeln;
|
||||
inc(size,2);
|
||||
end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:49:09 alex
|
||||
moved files
|
||||
|
||||
Revision 1.2 1998/09/11 10:55:24 peter
|
||||
+ header+log
|
||||
|
||||
}
|
||||
|
87
install/demo/text/qsort.pp
Normal file
87
install/demo/text/qsort.pp
Normal file
@ -0,0 +1,87 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1993-98 by the Free Pascal Development Team
|
||||
|
||||
QuickSort Example
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
program quicksort;
|
||||
|
||||
const
|
||||
max = 100000;
|
||||
|
||||
type
|
||||
tlist = array[1..max] of longint;
|
||||
|
||||
var
|
||||
data : tlist;
|
||||
|
||||
|
||||
procedure qsort(var a : tlist);
|
||||
|
||||
procedure sort(l,r: longint);
|
||||
var
|
||||
i,j,x,y: longint;
|
||||
begin
|
||||
i:=l;
|
||||
j:=r;
|
||||
x:=a[(l+r) div 2];
|
||||
repeat
|
||||
while a[i]<x do
|
||||
inc(i);
|
||||
while x<a[j] do
|
||||
dec(j);
|
||||
if not(i>j) then
|
||||
begin
|
||||
y:=a[i];
|
||||
a[i]:=a[j];
|
||||
a[j]:=y;
|
||||
inc(i);
|
||||
j:=j-1;
|
||||
end;
|
||||
until i>j;
|
||||
if l<j then
|
||||
sort(l,j);
|
||||
if i<r then
|
||||
sort(i,r);
|
||||
end;
|
||||
|
||||
begin
|
||||
sort(1,max);
|
||||
end;
|
||||
|
||||
var
|
||||
i : longint;
|
||||
begin
|
||||
write('Creating ',Max,' random numbers between 1 and 500000');
|
||||
randomize;
|
||||
for i:=1 to max do
|
||||
data[i]:=random(500000);
|
||||
writeln;
|
||||
writeln('Sorting...');
|
||||
qsort(data);
|
||||
writeln;
|
||||
for i:=1 to max do
|
||||
begin
|
||||
write(data[i]:7);
|
||||
if (i mod 10)=0 then
|
||||
writeln;
|
||||
end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-03-09 02:49:09 alex
|
||||
moved files
|
||||
|
||||
Revision 1.2 1998/09/11 10:55:26 peter
|
||||
+ header+log
|
||||
|
||||
}
|
1170
install/demo/win32/Makefile
Normal file
1170
install/demo/win32/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
45
install/demo/win32/Makefile.fpc
Normal file
45
install/demo/win32/Makefile.fpc
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Makefile.fpc for FPC win32 demos (part of FPC demo package)
|
||||
#
|
||||
|
||||
[targets]
|
||||
programs_win32=winhello menu dlltest testdll edit
|
||||
|
||||
[require]
|
||||
# Not always necessary, but saves a lot of trouble
|
||||
packages=api
|
||||
|
||||
[install]
|
||||
|
||||
[defaults]
|
||||
defaultrule=all
|
||||
|
||||
[dirs]
|
||||
fpcdir=../..
|
||||
targetdir=.
|
||||
|
||||
[postsettings]
|
||||
|
||||
[rules]
|
||||
ifeq ($(OS_TARGET),win32)
|
||||
vpath %$(PASEXT) win32
|
||||
endif
|
||||
|
||||
clean : execlean fpc_cleanall
|
||||
|
||||
execlean :
|
||||
|
||||
#################################
|
||||
# Demo installation for linux
|
||||
#
|
||||
|
||||
.PHONY: installexamples
|
||||
|
||||
ifndef EXAMPLESINSTALLDIR
|
||||
EXAMPLESINSTALLDIR=$(DOCINSTALLDIR)/examples
|
||||
endif
|
||||
|
||||
installexamples:
|
||||
$(MKDIR) $(EXAMPLESINSTALLDIR)
|
||||
$(COPYTREE) * $(EXAMPLESINSTALLDIR)
|
||||
|
Loading…
Reference in New Issue
Block a user