modrange.pp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Program GetModeRange_Example;
  2. { This program demonstrates how to find all available graph modes }
  3. uses graph;
  4. const
  5. { Currently, only 4, 8, 15 and 16 bit modes are supported
  6. but this may change in the future }
  7. gdnames: array[D4bit..D16bit] of string[6] =
  8. ('4 bit','6 bit','8 bit','12 bit','15 bit','16 bit');
  9. var
  10. t: text;
  11. gd, c, low, high, res: integer;
  12. begin
  13. assign(t,'modes.txt');
  14. rewrite(t);
  15. close(t);
  16. for gd := D4bit to D16bit do
  17. begin
  18. { Get the available mode numbers for this driver }
  19. getModeRange(gd,low,high);
  20. append(t);
  21. write(t,gdnames[gd]);
  22. Writeln(t,': low modenr = ',low,', high modenr = ',high);
  23. close(t);
  24. { If high is -1,
  25. no resolutions are supported for this bitdepth }
  26. if high = -1 then
  27. begin
  28. append(t);
  29. writeln(t,' No modes supported!');
  30. writeln(t);
  31. close(t);
  32. end
  33. else
  34. { Enter all supported resolutions for this bitdepth
  35. and write their characteristics to the file }
  36. for c := low to high do
  37. begin
  38. append(t);
  39. writeln(t,' testing mode nr ',c);
  40. close(t);
  41. initgraph(gd,c,'');
  42. res := graphresult;
  43. append(t);
  44. { An error occurred when entering the mode? }
  45. if res <> grok then
  46. writeln(t,grapherrormsg(res))
  47. else
  48. begin
  49. write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
  50. Writeln(t,', maxcolor: ',getmaxcolor);
  51. closegraph;
  52. end;
  53. writeln(t);
  54. close(t);
  55. end;
  56. append(t);
  57. writeln(t);
  58. close(t);
  59. end;
  60. end.