소스 검색

+ initial implementation

michael 25 년 전
부모
커밋
acf278a3e5
6개의 변경된 파일222개의 추가작업 그리고 0개의 파일을 삭제
  1. 53 0
      docs/graphex/Makefile
  2. 2 0
      docs/graphex/foot.tex
  3. 3 0
      docs/graphex/head.tex
  4. 41 0
      docs/graphex/inigraph1.pp
  5. 59 0
      docs/graphex/inigraph2.pp
  6. 64 0
      docs/graphex/modrange.pp

+ 53 - 0
docs/graphex/Makefile

@@ -0,0 +1,53 @@
+#######################################################################
+#
+# Makefile to compile all examples and convert them to LaTeX
+# 
+#######################################################################
+
+# Compiler
+PP=ppc386
+
+# Unit directory
+# UNITDIR=/usr/lib/ppc/0.99.0/linuxunits
+
+
+# Any options you wish to pass.
+PPOPTS=
+
+# Script to convert the programs to LaTeX examples which can be included.
+PP2TEX=../pp2tex
+
+# Script to collect all examples in 1 file.
+MAKETEX=make1tex
+
+#######################################################################
+# No need to edit after this line.
+#######################################################################
+
+ifdef UNITDIR
+PPOPTS:=$(PPOPTS) -Up$(UNITDIR);
+endif
+
+.SUFFIXES: .pp .tex
+
+.PHONY: all tex clean
+
+OBJECTS=inigraph1 inigraph2 modrange
+
+TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
+
+all : $(OBJECTS)
+
+tex : $(TEXOBJECTS)
+
+onetex : tex
+	$(MAKETEX) $(TEXOBJECTS)
+
+clean : 
+	rm -f *.o *.s $(OBJECTS) $(TEXOBJECTS)
+ 
+$(OBJECTS): %: %.pp
+	$(PP) $(PPOPTS) $*
+
+$(TEXOBJECTS): %.tex: %.pp head.tex foot.tex
+	$(PP2TEX) $*

+ 2 - 0
docs/graphex/foot.tex

@@ -0,0 +1,2 @@
+\end{verbatim}
+\end{FPCList}

+ 3 - 0
docs/graphex/head.tex

@@ -0,0 +1,3 @@
+\begin{FPCList}
+\item[Example]
+\begin{verbatim}

+ 41 - 0
docs/graphex/inigraph1.pp

@@ -0,0 +1,41 @@
+Program inigraph1;
+
+{ Program to demonstrate static graphics mode selection }
+
+uses graph;
+
+
+const
+  TheLine = 'We are now in 640 x 480 x 256 colors!'+
+            ' (press <Return> to continue)';
+
+var
+  gd, gm, lo, hi, error,tw,th: integer;
+  found: boolean;
+
+begin
+  { We want an 8 bit mode }
+  gd := D8bit;
+  gm := m640x480;
+  initgraph(gd,gm,'');
+  { Make sure you always check graphresult! }
+  error := graphResult;
+  if (error <> grOk) Then
+    begin
+    writeln('640x480x256 is not supported!');
+    halt(1)
+    end;
+  { We are now in 640x480x256 }
+  setColor(cyan);
+  rectangle(0,0,getmaxx,getmaxy);
+  { Write a nice message in the center of the screen }
+  setTextStyle(defaultFont,horizDir,1);
+  tw:=TextWidth(TheLine);
+  th:=TextHeight(TheLine);  
+  outTextXY((getMaxX - TW) div 2,
+            (getMaxY - TH) div 2,TheLine);
+  { Wait for return }
+  readln;
+  { Back to text mode }
+  closegraph;
+end.

+ 59 - 0
docs/graphex/inigraph2.pp

@@ -0,0 +1,59 @@
+Program inigraph2;
+
+{ Program to demonstrate dynamic graphics mode selection }
+
+uses graph;
+
+const
+  TheLine = 'We are now in 640 x 480 x 256 colors!'+
+            ' (press <Return> to continue)';
+
+var
+  th,tw,gd, gm, lo, hi, error: integer;
+  found: boolean;
+
+begin
+  { We want an 8 bit mode }
+  gd := D8bit;
+  { Get all available resolutions for this bitdepth }
+  getmoderange(gd,lo,hi);
+  { If the highest available mode number is -1, 
+    no resolutions are supported for this bitdepth  }
+  if hi = -1 then
+    begin
+    writeln('no 8 bit modes supported!');
+    halt
+    end;
+  found := false;
+  { Search all resolutions for 640x480 }
+  for gm := lo to hi do
+    begin
+    initgraph(gd,gm,'');
+    { Make sure you always check graphresult! }
+    error := graphResult;
+    if (error = grOk) and
+       (getmaxx = 639) and (getmaxy = 479) then
+      begin
+      found := true;
+      break;
+      end;
+    end;  
+  if not found then
+    begin
+    writeln('640x480x256 is not supported!');
+    halt(1)
+    end;
+  { We are now in 640x480x256 }
+  setColor(cyan);
+  rectangle(0,0,getmaxx,getmaxy);
+  { Write a nice message in the center of the screen }
+  setTextStyle(defaultFont,horizDir,1);
+  TW:=TextWidth(TheLine);
+  TH:=TextHeight(TheLine);
+  outTextXY((getMaxX - TW) div 2,
+            (getMaxY - TH) div 2,TheLine);
+  { Wait for return }
+  readln;
+  { Back to text mode }
+  closegraph;
+end.

+ 64 - 0
docs/graphex/modrange.pp

@@ -0,0 +1,64 @@
+Program GetModeRange_Example;
+
+{ This program demonstrates how to find all available graph modes }
+
+uses graph;
+
+const
+  { Currently, only 4, 8, 15 and 16 bit modes are supported 
+    but this may  change in the future }
+  gdnames: array[D4bit..D16bit] of string[6] =
+    ('4 bit','6 bit','8 bit','12 bit','15 bit','16 bit');
+
+var
+  t: text;
+  gd, c, low, high, res: integer;
+begin
+  assign(t,'modes.txt');
+  rewrite(t);
+  close(t);
+  for gd := D4bit to D16bit do
+    begin
+    { Get the available mode numbers for this driver }
+    getModeRange(gd,low,high);
+    append(t);
+    write(t,gdnames[gd]);
+    Writeln(t,': low modenr = ',low,', high modenr = ',high);
+    close(t);
+    { If high is -1, 
+       no resolutions are supported for this bitdepth }
+    if high = -1 then
+      begin
+      append(t);
+      writeln(t,'  No modes supported!');
+      writeln(t);
+      close(t);
+      end
+    else
+      { Enter all supported resolutions for this bitdepth 
+        and write their characteristics to the file }
+      for c := low to high do
+        begin
+        append(t);
+        writeln(t,'  testing mode nr ',c);
+        close(t);
+        initgraph(gd,c,'');
+        res := graphresult;
+        append(t);
+        { An error occurred when entering the mode? }
+        if res <> grok then
+          writeln(t,grapherrormsg(res))
+        else
+          begin
+          write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
+          Writeln(t,', maxcolor: ',getmaxcolor);
+          closegraph;
+          end;
+        writeln(t);
+        close(t);
+        end;
+    append(t);
+    writeln(t);
+    close(t);
+    end;
+end.