home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / education / a / autopcb / !AutoPCB / c / PCBROUTE < prev    next >
Text File  |  1991-03-17  |  5KB  |  99 lines

  1. /*
  2. ** printed circuit board autorouter, Copyright (C) Randy Nevin 1989.
  3. **
  4. ** you may give this software to anyone, make as many copies as you like, and
  5. ** post it on public computer bulletin boards and file servers. you may not
  6. ** sell it or charge any fee for distribution (except for media and postage),
  7. ** remove this comment or the copyright notice from the code, or claim that
  8. ** you wrote this code or anything derived from it. you may modify the code as
  9. ** much as you want (please document clearly with comments, and maintain the
  10. ** coding style), but programs which are derived from this one are subject to
  11. ** the conditions stated here. i am providing this code so that people can
  12. ** learn from it, so if you distribute it, please include source code, not
  13. ** just executables. contact me to report bugs or suggest enhancements; i do
  14. ** not guarantee support, but i will make an effort in good faith to help you,
  15. ** and i want to act as a central clearing house for future versions. you
  16. ** should contact me before undertaking a significant development effort, to
  17. ** avoid reinventing the wheel. if you come up with an enhancement you
  18. ** consider particularly useful, i would appreciate being informed so that it
  19. ** can be incorporated in future versions. my address is: Randy Nevin,
  20. ** 1731 211th PL NE, Redmond, WA 98053. this code is available directly from
  21. ** the author; just send a floppy and a self-addressed floppy mailer with
  22. ** sufficient postage.
  23. **
  24. ** HISTORY
  25. ** (name                date            description)
  26. ** ----------------------------------------------------
  27. ** randy nevin          2/1/89          initial version
  28. ** randy nevin          2/4/89          made retrace table driven, instead of
  29. **                                      doubly-nested switch statements.
  30. ** randy nevin          2/4/89          changed dir from int to char (cut
  31. **                                      storage for it in half).
  32. ** randy nevin          2/8/89          changed SetQueue and ReSetQueue to
  33. **                                      give priority to goal nodes.
  34. ** randy nevin          2/11/89         don't output incremental search
  35. **                                      results if stdout is redirected.
  36. ** randy nevin          2/11/89         released version 1.00
  37. ** pete goodwin         17/3/91         adapted for Archimedes
  38. */
  39.  
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. /* #include <io.h> */
  43. #include <time.h>
  44. #include <string.h>
  45. #include "cell.h"
  46.  
  47. /*
  48. ** if you run out of memory while routing large boards, there are two things
  49. ** you can do: (1) go into your config.sys file and disable everything you
  50. ** don't need. getting rid of things like ansi.sys, ramdisks, disk caches, and
  51. ** other terminate and stay resident (tsr) programs can free a lot of memory.
  52. ** (2) link the router, inspect the .map file, relink with the /CPARMAXALLOC:n
  53. ** switch, where n is calculated to allow for a near heap of about 5k. read
  54. ** the linker documentation before you do this. for me, the route.map file
  55. ** says the program needs 81EFh bytes. to this i add 1400h (5k) for a near
  56. ** heap to get 95EFh bytes or 95Fh paragraphs, which is 2399 decimal.
  57. */
  58.  
  59. int justboard = 0; /* need all data structures, not just the board */
  60.  
  61. extern void Initialize( FILE * );
  62. extern void Solve( void );
  63. extern void Report( FILE * );
  64.  
  65. int main ( argc, argv ) /* input board, route traces, output routed board */
  66.         int argc;
  67.         char *argv[];
  68.         {
  69.         char *self, *p;
  70.         FILE *fin, *fout;
  71.         long start, stop;
  72.  
  73.         printf( "Copyright (C) Randy Nevin, 1989. Version 1.00\n" );
  74.         printf( "See source code for rights granted.\n\n" );
  75.         start = time( NULL );
  76.         self = argv[0];
  77.         /* get rid of initial part of path */
  78.         if ((p = strrchr( self, '\\' )) || (p = strrchr( self, ':' )))
  79.                 self = ++p;
  80.         if (argc != 3) { /* need infile and outfile */
  81.                 printf( "usage: %s infile outfile\n", self );
  82.                 exit( -1 );
  83.                 }
  84.         if (!(fin = fopen( argv[1], "r" ))) {
  85.                 printf( "can't open %s\n", argv[1] );
  86.                 exit( -1 );
  87.                 }
  88.         if (!(fout = fopen( argv[2], "wb" ))) {
  89.                 printf( "can't open %s\n", argv[2] );
  90.                 exit( -1 );
  91.                 }
  92.         Initialize( fin );
  93.         Solve();
  94.         Report( fout );
  95.         stop = time( NULL ) - start;
  96.         printf( "time = %ld second%s\n", stop, (stop == 1) ? "" : "s" );
  97.         exit( 0 );
  98.         }
  99.