home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume37 / mgiccube / part01 < prev    next >
Encoding:
Text File  |  1993-05-15  |  59.5 KB  |  1,762 lines

  1. Newsgroups: comp.sources.misc
  2. From: fleurant@hri.com (P.Fleurant)
  3. Subject: v37i038:  magiccube - a cube simulator for X11/Motif, Part01/05
  4. Message-ID: <csm-v37i038=magiccube.162752@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: ae469947ce34c680083cb5f03bd9a5b7
  6. Date: Mon, 10 May 1993 21:28:15 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: fleurant@hri.com (P.Fleurant)
  10. Posting-number: Volume 37, Issue 38
  11. Archive-name: magiccube/part01
  12. Environment: X11, Motif, ANSI-C
  13.  
  14. This is a R*b*ks' Cube Simulator with a solver by Don Taylor.
  15.  
  16. P.Fleurant                                          Horizon Research, Inc.
  17. fleurant@hri.com                                    Waltham, MA 
  18. -----------------------
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then feed it
  21. # into a shell via "sh file" or similar.  To overwrite existing files,
  22. # type "sh file -c".
  23. # Contents:  cube cube/LICENSE cube/cube.h cube/layer1corner.c cube/lib
  24. #   cube/lib/Makefile
  25. # Wrapped by kent@sparky on Mon May 10 16:15:40 1993
  26. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 1 (of 5)."'
  29. if test ! -d 'cube' ; then
  30.     echo shar: Creating directory \"'cube'\"
  31.     mkdir 'cube'
  32. fi
  33. if test -f 'cube/LICENSE' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'cube/LICENSE'\"
  35. else
  36.   echo shar: Extracting \"'cube/LICENSE'\" \(17982 characters\)
  37.   sed "s/^X//" >'cube/LICENSE' <<'END_OF_FILE'
  38. X            GNU GENERAL PUBLIC LICENSE
  39. X               Version 2, June 1991
  40. X
  41. X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  42. X                          675 Mass Ave, Cambridge, MA 02139, USA
  43. X Everyone is permitted to copy and distribute verbatim copies
  44. X of this license document, but changing it is not allowed.
  45. X
  46. X                Preamble
  47. X
  48. X  The licenses for most software are designed to take away your
  49. Xfreedom to share and change it.  By contrast, the GNU General Public
  50. XLicense is intended to guarantee your freedom to share and change free
  51. Xsoftware--to make sure the software is free for all its users.  This
  52. XGeneral Public License applies to most of the Free Software
  53. XFoundation's software and to any other program whose authors commit to
  54. Xusing it.  (Some other Free Software Foundation software is covered by
  55. Xthe GNU Library General Public License instead.)  You can apply it to
  56. Xyour programs, too.
  57. X
  58. X  When we speak of free software, we are referring to freedom, not
  59. Xprice.  Our General Public Licenses are designed to make sure that you
  60. Xhave the freedom to distribute copies of free software (and charge for
  61. Xthis service if you wish), that you receive source code or can get it
  62. Xif you want it, that you can change the software or use pieces of it
  63. Xin new free programs; and that you know you can do these things.
  64. X
  65. X  To protect your rights, we need to make restrictions that forbid
  66. Xanyone to deny you these rights or to ask you to surrender the rights.
  67. XThese restrictions translate to certain responsibilities for you if you
  68. Xdistribute copies of the software, or if you modify it.
  69. X
  70. X  For example, if you distribute copies of such a program, whether
  71. Xgratis or for a fee, you must give the recipients all the rights that
  72. Xyou have.  You must make sure that they, too, receive or can get the
  73. Xsource code.  And you must show them these terms so they know their
  74. Xrights.
  75. X
  76. X  We protect your rights with two steps: (1) copyright the software, and
  77. X(2) offer you this license which gives you legal permission to copy,
  78. Xdistribute and/or modify the software.
  79. X
  80. X  Also, for each author's protection and ours, we want to make certain
  81. Xthat everyone understands that there is no warranty for this free
  82. Xsoftware.  If the software is modified by someone else and passed on, we
  83. Xwant its recipients to know that what they have is not the original, so
  84. Xthat any problems introduced by others will not reflect on the original
  85. Xauthors' reputations.
  86. X
  87. X  Finally, any free program is threatened constantly by software
  88. Xpatents.  We wish to avoid the danger that redistributors of a free
  89. Xprogram will individually obtain patent licenses, in effect making the
  90. Xprogram proprietary.  To prevent this, we have made it clear that any
  91. Xpatent must be licensed for everyone's free use or not licensed at all.
  92. X
  93. X  The precise terms and conditions for copying, distribution and
  94. Xmodification follow.
  95. X
  96. X            GNU GENERAL PUBLIC LICENSE
  97. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  98. X
  99. X  0. This License applies to any program or other work which contains
  100. Xa notice placed by the copyright holder saying it may be distributed
  101. Xunder the terms of this General Public License.  The "Program", below,
  102. Xrefers to any such program or work, and a "work based on the Program"
  103. Xmeans either the Program or any derivative work under copyright law:
  104. Xthat is to say, a work containing the Program or a portion of it,
  105. Xeither verbatim or with modifications and/or translated into another
  106. Xlanguage.  (Hereinafter, translation is included without limitation in
  107. Xthe term "modification".)  Each licensee is addressed as "you".
  108. X
  109. XActivities other than copying, distribution and modification are not
  110. Xcovered by this License; they are outside its scope.  The act of
  111. Xrunning the Program is not restricted, and the output from the Program
  112. Xis covered only if its contents constitute a work based on the
  113. XProgram (independent of having been made by running the Program).
  114. XWhether that is true depends on what the Program does.
  115. X
  116. X  1. You may copy and distribute verbatim copies of the Program's
  117. Xsource code as you receive it, in any medium, provided that you
  118. Xconspicuously and appropriately publish on each copy an appropriate
  119. Xcopyright notice and disclaimer of warranty; keep intact all the
  120. Xnotices that refer to this License and to the absence of any warranty;
  121. Xand give any other recipients of the Program a copy of this License
  122. Xalong with the Program.
  123. X
  124. XYou may charge a fee for the physical act of transferring a copy, and
  125. Xyou may at your option offer warranty protection in exchange for a fee.
  126. X
  127. X  2. You may modify your copy or copies of the Program or any portion
  128. Xof it, thus forming a work based on the Program, and copy and
  129. Xdistribute such modifications or work under the terms of Section 1
  130. Xabove, provided that you also meet all of these conditions:
  131. X
  132. X    a) You must cause the modified files to carry prominent notices
  133. X    stating that you changed the files and the date of any change.
  134. X
  135. X    b) You must cause any work that you distribute or publish, that in
  136. X    whole or in part contains or is derived from the Program or any
  137. X    part thereof, to be licensed as a whole at no charge to all third
  138. X    parties under the terms of this License.
  139. X
  140. X    c) If the modified program normally reads commands interactively
  141. X    when run, you must cause it, when started running for such
  142. X    interactive use in the most ordinary way, to print or display an
  143. X    announcement including an appropriate copyright notice and a
  144. X    notice that there is no warranty (or else, saying that you provide
  145. X    a warranty) and that users may redistribute the program under
  146. X    these conditions, and telling the user how to view a copy of this
  147. X    License.  (Exception: if the Program itself is interactive but
  148. X    does not normally print such an announcement, your work based on
  149. X    the Program is not required to print an announcement.)
  150. X
  151. XThese requirements apply to the modified work as a whole.  If
  152. Xidentifiable sections of that work are not derived from the Program,
  153. Xand can be reasonably considered independent and separate works in
  154. Xthemselves, then this License, and its terms, do not apply to those
  155. Xsections when you distribute them as separate works.  But when you
  156. Xdistribute the same sections as part of a whole which is a work based
  157. Xon the Program, the distribution of the whole must be on the terms of
  158. Xthis License, whose permissions for other licensees extend to the
  159. Xentire whole, and thus to each and every part regardless of who wrote it.
  160. X
  161. XThus, it is not the intent of this section to claim rights or contest
  162. Xyour rights to work written entirely by you; rather, the intent is to
  163. Xexercise the right to control the distribution of derivative or
  164. Xcollective works based on the Program.
  165. X
  166. XIn addition, mere aggregation of another work not based on the Program
  167. Xwith the Program (or with a work based on the Program) on a volume of
  168. Xa storage or distribution medium does not bring the other work under
  169. Xthe scope of this License.
  170. X
  171. X  3. You may copy and distribute the Program (or a work based on it,
  172. Xunder Section 2) in object code or executable form under the terms of
  173. XSections 1 and 2 above provided that you also do one of the following:
  174. X
  175. X    a) Accompany it with the complete corresponding machine-readable
  176. X    source code, which must be distributed under the terms of Sections
  177. X    1 and 2 above on a medium customarily used for software interchange; or,
  178. X
  179. X    b) Accompany it with a written offer, valid for at least three
  180. X    years, to give any third party, for a charge no more than your
  181. X    cost of physically performing source distribution, a complete
  182. X    machine-readable copy of the corresponding source code, to be
  183. X    distributed under the terms of Sections 1 and 2 above on a medium
  184. X    customarily used for software interchange; or,
  185. X
  186. X    c) Accompany it with the information you received as to the offer
  187. X    to distribute corresponding source code.  (This alternative is
  188. X    allowed only for noncommercial distribution and only if you
  189. X    received the program in object code or executable form with such
  190. X    an offer, in accord with Subsection b above.)
  191. X
  192. XThe source code for a work means the preferred form of the work for
  193. Xmaking modifications to it.  For an executable work, complete source
  194. Xcode means all the source code for all modules it contains, plus any
  195. Xassociated interface definition files, plus the scripts used to
  196. Xcontrol compilation and installation of the executable.  However, as a
  197. Xspecial exception, the source code distributed need not include
  198. Xanything that is normally distributed (in either source or binary
  199. Xform) with the major components (compiler, kernel, and so on) of the
  200. Xoperating system on which the executable runs, unless that component
  201. Xitself accompanies the executable.
  202. X
  203. XIf distribution of executable or object code is made by offering
  204. Xaccess to copy from a designated place, then offering equivalent
  205. Xaccess to copy the source code from the same place counts as
  206. Xdistribution of the source code, even though third parties are not
  207. Xcompelled to copy the source along with the object code.
  208. X
  209. X  4. You may not copy, modify, sublicense, or distribute the Program
  210. Xexcept as expressly provided under this License.  Any attempt
  211. Xotherwise to copy, modify, sublicense or distribute the Program is
  212. Xvoid, and will automatically terminate your rights under this License.
  213. XHowever, parties who have received copies, or rights, from you under
  214. Xthis License will not have their licenses terminated so long as such
  215. Xparties remain in full compliance.
  216. X
  217. X  5. You are not required to accept this License, since you have not
  218. Xsigned it.  However, nothing else grants you permission to modify or
  219. Xdistribute the Program or its derivative works.  These actions are
  220. Xprohibited by law if you do not accept this License.  Therefore, by
  221. Xmodifying or distributing the Program (or any work based on the
  222. XProgram), you indicate your acceptance of this License to do so, and
  223. Xall its terms and conditions for copying, distributing or modifying
  224. Xthe Program or works based on it.
  225. X
  226. X  6. Each time you redistribute the Program (or any work based on the
  227. XProgram), the recipient automatically receives a license from the
  228. Xoriginal licensor to copy, distribute or modify the Program subject to
  229. Xthese terms and conditions.  You may not impose any further
  230. Xrestrictions on the recipients' exercise of the rights granted herein.
  231. XYou are not responsible for enforcing compliance by third parties to
  232. Xthis License.
  233. X
  234. X  7. If, as a consequence of a court judgment or allegation of patent
  235. Xinfringement or for any other reason (not limited to patent issues),
  236. Xconditions are imposed on you (whether by court order, agreement or
  237. Xotherwise) that contradict the conditions of this License, they do not
  238. Xexcuse you from the conditions of this License.  If you cannot
  239. Xdistribute so as to satisfy simultaneously your obligations under this
  240. XLicense and any other pertinent obligations, then as a consequence you
  241. Xmay not distribute the Program at all.  For example, if a patent
  242. Xlicense would not permit royalty-free redistribution of the Program by
  243. Xall those who receive copies directly or indirectly through you, then
  244. Xthe only way you could satisfy both it and this License would be to
  245. Xrefrain entirely from distribution of the Program.
  246. X
  247. XIf any portion of this section is held invalid or unenforceable under
  248. Xany particular circumstance, the balance of the section is intended to
  249. Xapply and the section as a whole is intended to apply in other
  250. Xcircumstances.
  251. X
  252. XIt is not the purpose of this section to induce you to infringe any
  253. Xpatents or other property right claims or to contest validity of any
  254. Xsuch claims; this section has the sole purpose of protecting the
  255. Xintegrity of the free software distribution system, which is
  256. Ximplemented by public license practices.  Many people have made
  257. Xgenerous contributions to the wide range of software distributed
  258. Xthrough that system in reliance on consistent application of that
  259. Xsystem; it is up to the author/donor to decide if he or she is willing
  260. Xto distribute software through any other system and a licensee cannot
  261. Ximpose that choice.
  262. X
  263. XThis section is intended to make thoroughly clear what is believed to
  264. Xbe a consequence of the rest of this License.
  265. X
  266. X  8. If the distribution and/or use of the Program is restricted in
  267. Xcertain countries either by patents or by copyrighted interfaces, the
  268. Xoriginal copyright holder who places the Program under this License
  269. Xmay add an explicit geographical distribution limitation excluding
  270. Xthose countries, so that distribution is permitted only in or among
  271. Xcountries not thus excluded.  In such case, this License incorporates
  272. Xthe limitation as if written in the body of this License.
  273. X
  274. X  9. The Free Software Foundation may publish revised and/or new versions
  275. Xof the General Public License from time to time.  Such new versions will
  276. Xbe similar in spirit to the present version, but may differ in detail to
  277. Xaddress new problems or concerns.
  278. X
  279. XEach version is given a distinguishing version number.  If the Program
  280. Xspecifies a version number of this License which applies to it and "any
  281. Xlater version", you have the option of following the terms and conditions
  282. Xeither of that version or of any later version published by the Free
  283. XSoftware Foundation.  If the Program does not specify a version number of
  284. Xthis License, you may choose any version ever published by the Free Software
  285. XFoundation.
  286. X
  287. X  10. If you wish to incorporate parts of the Program into other free
  288. Xprograms whose distribution conditions are different, write to the author
  289. Xto ask for permission.  For software which is copyrighted by the Free
  290. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  291. Xmake exceptions for this.  Our decision will be guided by the two goals
  292. Xof preserving the free status of all derivatives of our free software and
  293. Xof promoting the sharing and reuse of software generally.
  294. X
  295. X                NO WARRANTY
  296. X
  297. X  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  298. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  299. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  300. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  301. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  302. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  303. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  304. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  305. XREPAIR OR CORRECTION.
  306. X
  307. X  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  308. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  309. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  310. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  311. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  312. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  313. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  314. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  315. XPOSSIBILITY OF SUCH DAMAGES.
  316. X
  317. X             END OF TERMS AND CONDITIONS
  318. X
  319. X    Appendix: How to Apply These Terms to Your New Programs
  320. X
  321. X  If you develop a new program, and you want it to be of the greatest
  322. Xpossible use to the public, the best way to achieve this is to make it
  323. Xfree software which everyone can redistribute and change under these terms.
  324. X
  325. X  To do so, attach the following notices to the program.  It is safest
  326. Xto attach them to the start of each source file to most effectively
  327. Xconvey the exclusion of warranty; and each file should have at least
  328. Xthe "copyright" line and a pointer to where the full notice is found.
  329. X
  330. X    <one line to give the program's name and a brief idea of what it does.>
  331. X    Copyright (C) 19yy  <name of author>
  332. X
  333. X    This program is free software; you can redistribute it and/or modify
  334. X    it under the terms of the GNU General Public License as published by
  335. X    the Free Software Foundation; either version 2 of the License, or
  336. X    (at your option) any later version.
  337. X
  338. X    This program is distributed in the hope that it will be useful,
  339. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  340. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  341. X    GNU General Public License for more details.
  342. X
  343. X    You should have received a copy of the GNU General Public License
  344. X    along with this program; if not, write to the Free Software
  345. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  346. X
  347. XAlso add information on how to contact you by electronic and paper mail.
  348. X
  349. XIf the program is interactive, make it output a short notice like this
  350. Xwhen it starts in an interactive mode:
  351. X
  352. X    Gnomovision version 69, Copyright (C) 19yy name of author
  353. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  354. X    This is free software, and you are welcome to redistribute it
  355. X    under certain conditions; type `show c' for details.
  356. X
  357. XThe hypothetical commands `show w' and `show c' should show the appropriate
  358. Xparts of the General Public License.  Of course, the commands you use may
  359. Xbe called something other than `show w' and `show c'; they could even be
  360. Xmouse-clicks or menu items--whatever suits your program.
  361. X
  362. XYou should also get your employer (if you work as a programmer) or your
  363. Xschool, if any, to sign a "copyright disclaimer" for the program, if
  364. Xnecessary.  Here is a sample; alter the names:
  365. X
  366. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  367. X  `Gnomovision' (which makes passes at compilers) written by James Hacker.
  368. X
  369. X  <signature of Ty Coon>, 1 April 1989
  370. X  Ty Coon, President of Vice
  371. X
  372. XThis General Public License does not permit incorporating your program into
  373. Xproprietary programs.  If your program is a subroutine library, you may
  374. Xconsider it more useful to permit linking proprietary applications with the
  375. Xlibrary.  If this is what you want to do, use the GNU Library General
  376. XPublic License instead of this License.
  377. END_OF_FILE
  378.   if test 17982 -ne `wc -c <'cube/LICENSE'`; then
  379.     echo shar: \"'cube/LICENSE'\" unpacked with wrong size!
  380.   fi
  381.   # end of 'cube/LICENSE'
  382. fi
  383. if test -f 'cube/cube.h' -a "${1}" != "-c" ; then 
  384.   echo shar: Will not clobber existing file \"'cube/cube.h'\"
  385. else
  386.   echo shar: Extracting \"'cube/cube.h'\" \(14880 characters\)
  387.   sed "s/^X//" >'cube/cube.h' <<'END_OF_FILE'
  388. X/**********************************************************************************
  389. X * cube.h: declarations for the cube program
  390. X *The following references were used:
  391. X   "The X Window System Programming And Applications with Xt
  392. X   OSF/MOTIF EDITION"
  393. X   by Douglas A Young 
  394. X   Prentice-Hall, 1990.
  395. X   ISBN 0-13-642786-3
  396. X
  397. X   "Mastering Rubik's Cube"
  398. X   by Don Taylor
  399. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  400. X   ISBN 0-03-059941-5
  401. X
  402. X-------------------------------------------------------------------
  403. XCopyright (C) 1993 by Pierre A. Fleurant
  404. XPermission is granted to copy and distribute this program
  405. Xwithout charge, provided this copyright notice is included
  406. Xin the copy.
  407. XThis Software is distributed on an as-is basis. There will be
  408. XABSOLUTELY NO WARRANTY for any part of this software to work
  409. Xcorrect. In no case will the author be liable to you for damages
  410. Xcaused by the usage of this software.
  411. X-------------------------------------------------------------------
  412. X */
  413. X
  414. X#include <X11/StringDefs.h>
  415. X#include <X11/cursorfont.h>
  416. X#include <X11/Intrinsic.h> 
  417. X#include <X11/Xutil.h>
  418. X#include <Xm/Xm.h>
  419. X#include <Xm/DrawingA.h>
  420. X#include <Xm/RowColumn.h>
  421. X#include <Xm/Form.h>
  422. X#include <Xm/PushB.h>
  423. X#include <Xm/ToggleB.h>
  424. X#include <Xm/Label.h>
  425. X#include <math.h>
  426. X#include "libXs.h"
  427. X
  428. X#define DEFAULT_DELTA_ANGLE 30
  429. X
  430. X/* application context, display */
  431. XXtAppContext appContext;
  432. XDisplay *xDisplay;
  433. X
  434. X/* #define MotifBC YES */
  435. X
  436. XBoolean Draw_Enable           = TRUE; 
  437. XBoolean Cube_Side_Chosen      = FALSE;
  438. XBoolean Fill_Pattern_Chosen   = FALSE;
  439. X
  440. X/* Used for cornermap array. See align_subfaces in cube.c */
  441. Xtypedef struct {
  442. X  int a;
  443. X  int b;
  444. X  int c;
  445. X} Corner;
  446. X
  447. X/* Used for edge array. See align_subfaces in cube.c */
  448. Xtypedef struct {
  449. X  int a;
  450. X  int b;
  451. X} Edge;
  452. X
  453. X/*  help information */
  454. X
  455. Xchar *tophelp_str[] = {
  456. X  "Init Cube: init cube to pattern desired",
  457. X  "Pristine: to start with a pristine cube",
  458. X  "Quit: exit",
  459. X  "rotate,spin,flip: turns whole cube",
  460. X  "!front, !left, !right,...: operates on 1/3 of cube",
  461. X  "  ",
  462. X  "  ",
  463. X  "",""};
  464. X
  465. Xstatic unsigned char fg_bitmap[32] = {
  466. X      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* solid foreground  */
  467. X      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  468. X      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  469. X      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  
  470. X};
  471. X#define fg_width  16
  472. X#define fg_height 16
  473. X
  474. X/* the initial colors of the 6 sides of the cube */
  475. Xchar *seed_color[] = {
  476. X/*  0      1        2         3             4        5     
  477. X    front  left     right     back          top      bottom  
  478. X */
  479. X   "red", "yellow", "orange", "light grey", "blue", "green"
  480. X};
  481. X
  482. X/* the names of the 6 sides of the cube */
  483. Xchar *side_names[] = {
  484. X  "front", "left", "right", "back", "top", "bottom"  
  485. X};
  486. X
  487. X/* Menu bar data */
  488. Xextern void spin_it();
  489. Xextern void rot_it();
  490. Xextern void flip_it();
  491. Xextern void quit_it();
  492. Xextern void init_cube();
  493. Xextern void clear_draw();
  494. Xextern void cubik_front();
  495. Xextern void cubik_left();
  496. Xextern void cubik_right();
  497. Xextern void cubik_back();
  498. Xextern void cubik_top();
  499. Xextern void cubik_bottom();
  500. X
  501. X/*
  502. X * Create the list of menu items for a sub menu pane.
  503. X */
  504. Xstatic xs_menu_struct OpData[] = {
  505. X  {"rotate", rot_it, "ignore", NULL, 0, NULL},
  506. X  {"spin", spin_it, "ignore", NULL, 0, NULL},
  507. X  {"flip", flip_it, "ignore", NULL, 0 ,NULL},
  508. X  {"!front", cubik_front, "ignore", NULL, 0, NULL},
  509. X  {"!left",  cubik_left, "ignore", NULL, 0, NULL},
  510. X  {"!right", cubik_right, "ignore", NULL, 0, NULL},
  511. X  {"!back",  cubik_back, "ignore", NULL, 0, NULL},
  512. X  {"!top",   cubik_top, "ignore", NULL, 0, NULL},
  513. X  {"!bottom",cubik_bottom, "ignore", NULL, 0, NULL}
  514. X};
  515. X
  516. X/*
  517. X * Describe the menu bar, giving only the names to appear in
  518. X * the menu bar and pointers to each pulldown pane.
  519. X */
  520. Xstatic xs_menu_struct PulldownData[] = {
  521. X  {"Operate" , NULL,  NULL,  
  522. X    OpData, XtNumber(OpData), NULL}
  523. X};
  524. X
  525. X/* Old cube0 values. 
  526. X   #define MR_X  150
  527. X   #define MR_Y  125
  528. X   #define Z_DEPTH 0
  529. X*/
  530. X/* With following values cube is centered about (0,0,0) */
  531. X#define MR_X  (-75)
  532. X#define MR_Y  (-75)
  533. X#define Z_DEPTH (-75)
  534. X
  535. X#define WINDOW_CENTER_X 225
  536. X#define WINDOW_CENTER_Y 200
  537. X
  538. X#define PROJECTION_DEPTH 500
  539. X#define FACE0_WIDTH  50
  540. X#define FACE0_HEIGHT 50
  541. X#define NUM_SUBPLANES 54
  542. X#define NUM_CUBIKPLANES 21 /* number of planes moved in cubikked op; 1/3 of cube moved */
  543. X
  544. X/* Double_XPoint arrays are used for all double calculations so that rotated, flipped,
  545. X   or spin'ed face does not look bad after many small increments of rotation. 
  546. X   The z coordnate is used to preserve info when spin`ed or flipped. The routine 
  547. X   shortface() converts the double_XPoint array to the regular XPoint array for drawing */
  548. Xtypedef struct {
  549. X  double x;
  550. X  double y;
  551. X  double z;
  552. X}double_XPoint;
  553. X
  554. X/* seed_face coordinates use mode=CoordModePrevious. They are converted to mode=CoordModeOrigin later. */
  555. Xdouble_XPoint rot_face[NUM_SUBPLANES][5];   /* the last spin'ed, flipped, or rotated face */
  556. Xdouble_XPoint cubik_face[NUM_SUBPLANES][5]; /* the cubikked face, a face that is turned only-1/3 of cube */
  557. Xdouble_XPoint seed_face[][5] = {
  558. X
  559. X  /* Side 0 (front)*/
  560. X  {MR_X, MR_Y, Z_DEPTH},
  561. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  562. X  {MR_X+FACE0_WIDTH, MR_Y, Z_DEPTH},
  563. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  564. X  {MR_X+2*FACE0_WIDTH, MR_Y, Z_DEPTH},
  565. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  566. X
  567. X  {MR_X, MR_Y+FACE0_HEIGHT, Z_DEPTH},
  568. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  569. X  {MR_X+FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH},
  570. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  571. X  {MR_X+2*FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH},
  572. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  573. X
  574. X  {MR_X, MR_Y+2*FACE0_HEIGHT, Z_DEPTH},
  575. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  576. X  {MR_X+FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH},
  577. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  578. X  {MR_X+2*FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH},
  579. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  580. X
  581. X  /* Side 1 (left) */
  582. X  {MR_X, MR_Y, Z_DEPTH},
  583. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  584. X  {MR_X, MR_Y, Z_DEPTH+FACE0_WIDTH},
  585. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  586. X  {MR_X, MR_Y, Z_DEPTH+2*FACE0_WIDTH},
  587. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  588. X
  589. X  {MR_X, MR_Y+FACE0_HEIGHT, Z_DEPTH},
  590. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  591. X  {MR_X, MR_Y+FACE0_HEIGHT, Z_DEPTH+FACE0_WIDTH},
  592. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  593. X  {MR_X, MR_Y+FACE0_HEIGHT, Z_DEPTH+2*FACE0_WIDTH},
  594. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  595. X
  596. X  {MR_X, MR_Y+2*FACE0_HEIGHT, Z_DEPTH},
  597. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  598. X  {MR_X, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+FACE0_WIDTH},
  599. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  600. X  {MR_X, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+2*FACE0_WIDTH},
  601. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  602. X
  603. X  /* Side 2 (right) */
  604. X  {MR_X+3*FACE0_WIDTH, MR_Y, Z_DEPTH},
  605. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  606. X  {MR_X+3*FACE0_WIDTH, MR_Y, Z_DEPTH+FACE0_WIDTH},
  607. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  608. X  {MR_X+3*FACE0_WIDTH, MR_Y, Z_DEPTH+2*FACE0_WIDTH},
  609. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  610. X
  611. X  {MR_X+3*FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH},
  612. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  613. X  {MR_X+3*FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH+FACE0_WIDTH},
  614. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  615. X  {MR_X+3*FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH+2*FACE0_WIDTH},
  616. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  617. X
  618. X  {MR_X+3*FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH},
  619. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  620. X  {MR_X+3*FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+FACE0_WIDTH},
  621. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  622. X  {MR_X+3*FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+2*FACE0_WIDTH},
  623. X              {0,0,FACE0_WIDTH},{0,FACE0_HEIGHT,0},{0,0,-FACE0_WIDTH},{0,-FACE0_HEIGHT,0},
  624. X
  625. X  /* Side 3 (back) */
  626. X  {MR_X, MR_Y, Z_DEPTH+3*FACE0_WIDTH},
  627. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  628. X  {MR_X+FACE0_WIDTH, MR_Y, Z_DEPTH+3*FACE0_WIDTH},
  629. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  630. X  {MR_X+2*FACE0_WIDTH, MR_Y, Z_DEPTH+3*FACE0_WIDTH},
  631. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  632. X
  633. X  {MR_X, MR_Y+FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  634. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  635. X  {MR_X+FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  636. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  637. X  {MR_X+2*FACE0_WIDTH, MR_Y+FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  638. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  639. X
  640. X  {MR_X, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  641. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  642. X  {MR_X+FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  643. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  644. X  {MR_X+2*FACE0_WIDTH, MR_Y+2*FACE0_HEIGHT, Z_DEPTH+3*FACE0_WIDTH},
  645. X              {FACE0_WIDTH,0,0},{0,FACE0_HEIGHT,0},{-FACE0_WIDTH,0,0},{0,-FACE0_HEIGHT,0},
  646. X
  647. X  /* Side 4 (top) */
  648. X  {MR_X, MR_Y, Z_DEPTH},
  649. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  650. X  {MR_X+FACE0_WIDTH, MR_Y, Z_DEPTH},
  651. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  652. X  {MR_X+2*FACE0_WIDTH, MR_Y, Z_DEPTH},
  653. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  654. X
  655. X  {MR_X, MR_Y, Z_DEPTH+FACE0_HEIGHT},
  656. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  657. X  {MR_X+FACE0_WIDTH, MR_Y, Z_DEPTH+FACE0_HEIGHT},
  658. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  659. X  {MR_X+2*FACE0_WIDTH, MR_Y, Z_DEPTH+FACE0_HEIGHT},
  660. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  661. X
  662. X  {MR_X, MR_Y, Z_DEPTH+2*FACE0_HEIGHT},
  663. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  664. X  {MR_X+FACE0_WIDTH, MR_Y, Z_DEPTH+2*FACE0_HEIGHT},
  665. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  666. X  {MR_X+2*FACE0_WIDTH, MR_Y, Z_DEPTH+2*FACE0_HEIGHT},
  667. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  668. X
  669. X  /* Side 5 (bottom) */
  670. X  {MR_X, MR_Y+3*FACE0_HEIGHT, Z_DEPTH},
  671. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  672. X  {MR_X+FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH},
  673. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  674. X  {MR_X+2*FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH},
  675. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  676. X
  677. X  {MR_X, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+FACE0_HEIGHT},
  678. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  679. X  {MR_X+FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+FACE0_HEIGHT},
  680. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  681. X  {MR_X+2*FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+FACE0_HEIGHT},
  682. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  683. X
  684. X  {MR_X, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+2*FACE0_HEIGHT},
  685. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  686. X  {MR_X+FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+2*FACE0_HEIGHT},
  687. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  688. X  {MR_X+2*FACE0_WIDTH, MR_Y+3*FACE0_HEIGHT, Z_DEPTH+2*FACE0_HEIGHT},
  689. X              {FACE0_WIDTH,0,0},{0,0,FACE0_HEIGHT},{-FACE0_WIDTH,0,0},{0,0,-FACE0_HEIGHT},
  690. X
  691. X};
  692. Xint rot_angle,spin_angle,flip_angle;
  693. X
  694. X/* The subplanes that are moved in the cubikc_xxxx callback
  695. X * that make up a twisting of the 1/3 of the cube.
  696. X * 
  697. X */
  698. Xint seed_front[] = {
  699. X  0,1,2,3,4,5,6,7,8, 
  700. X  0,0,0,
  701. X  0,0,0,
  702. X  0,0,0,
  703. X  0,0,0
  704. X  };
  705. X
  706. Xint seed_left[] = {
  707. X  9,10,11,12,13,14,15,16,17,
  708. X  0,0,0,
  709. X  0,0,0,
  710. X  0,0,0,
  711. X  0,0,0
  712. X  };
  713. X
  714. Xint seed_right[] = {
  715. X  18,19,20,21,22,23,24,25,26,
  716. X  0,0,0,
  717. X  0,0,0,
  718. X  0,0,0,
  719. X  0,0,0
  720. X  };
  721. X
  722. Xint seed_back[] = {
  723. X  27,28,29,30,31,32,33,34,35,
  724. X  0,0,0,
  725. X  0,0,0,
  726. X  0,0,0,
  727. X  0,0,0
  728. X  };
  729. X
  730. Xint seed_top[] = {
  731. X  36,37,38,39,40,41,42,43,44,
  732. X  0,0,0,
  733. X  0,0,0,
  734. X  0,0,0,
  735. X  0,0,0
  736. X  };
  737. X
  738. Xint seed_bottom[] = {
  739. X  45,46,47,48,49,50,51,52,53,
  740. X  0,0,0,
  741. X  0,0,0,
  742. X  0,0,0,
  743. X  0,0,0
  744. X  };
  745. X/* the front[]. left[], .... arrays 
  746. X   indicate which subplane occupies a subplane location.
  747. X   When pristine these values are equal. (See seed_xxxx.)
  748. X   cubik_face[x][] gives the coordinates of a the xth
  749. X   subplane. The coordinates of a subplane change if a cubik
  750. X   operation operates on the said subplane. 
  751. X */
  752. Xint front[NUM_CUBIKPLANES],left[NUM_CUBIKPLANES];
  753. Xint right[NUM_CUBIKPLANES],back[NUM_CUBIKPLANES];
  754. Xint top[NUM_CUBIKPLANES],bottom[NUM_CUBIKPLANES];
  755. XCorner cornermap[6][6][6]; /* see align_subfaces in cube.c */
  756. XEdge   edgemap[6][6];      /* see align_subfaces in cube.c */
  757. X
  758. X
  759. Xdouble Delta_Angle = DEFAULT_DELTA_ANGLE; 
  760. X
  761. Xvoid  draw_line();
  762. Xvoid  draw_circle();
  763. Xvoid  draw_rectangle();
  764. Xvoid  draw_filled_circle();
  765. Xvoid  draw_filled_rectangle();
  766. X
  767. Xvoid  activate();
  768. Xvoid  refresh();
  769. Xvoid  refresh_cube();
  770. Xvoid  set_stipple();
  771. Xvoid  start_rubber_band();
  772. Xvoid  track_rubber_band();
  773. Xvoid  end_rubber_band();
  774. Xvoid  prev_to_org();
  775. Xvoid  facecpy();
  776. Xvoid  cubik();
  777. Xvoid  cubikcpy();
  778. Xvoid  update_cubik();
  779. Xvoid  lefthand_twist();
  780. Xvoid  righthand_twist();
  781. Xvoid  xs_help_callback();
  782. Xvoid  init_subplane_pattern();
  783. Xvoid  norm_face();
  784. Xvoid  projface();
  785. Xvoid  shortface();
  786. Xextern void xcube_init_cubik();
  787. Xextern void taylor();
  788. Xextern void ldfile();
  789. X
  790. Xvoid init_cornermap();
  791. Xvoid init_edgemap();
  792. Xvoid check_events();
  793. XBool test_for_event();
  794. END_OF_FILE
  795.   if test 14880 -ne `wc -c <'cube/cube.h'`; then
  796.     echo shar: \"'cube/cube.h'\" unpacked with wrong size!
  797.   fi
  798.   # end of 'cube/cube.h'
  799. fi
  800. if test -f 'cube/layer1corner.c' -a "${1}" != "-c" ; then 
  801.   echo shar: Will not clobber existing file \"'cube/layer1corner.c'\"
  802. else
  803.   echo shar: Extracting \"'cube/layer1corner.c'\" \(14286 characters\)
  804.   sed "s/^X//" >'cube/layer1corner.c' <<'END_OF_FILE'
  805. X/* layer1corner.c
  806. X   This incorporates Don Taylor's solution to the 
  807. X   Buvos Kocka (Hungarian Magic Cube). 
  808. X
  809. X   First Layer Corner Cube
  810. X
  811. X   The following references were used:
  812. X   "The X Window System Programming And Applications with Xt
  813. X   OSF/MOTIF EDITION"
  814. X   by Douglas A Young 
  815. X   Prentice-Hall, 1990.
  816. X   ISBN 0-13-642786-3
  817. X
  818. X   "Mastering Rubik's Cube"
  819. X   by Don Taylor
  820. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  821. X   ISBN 0-03-059941-5
  822. X
  823. X-------------------------------------------------------------------
  824. XCopyright (C) 1993 by Pierre A. Fleurant
  825. XPermission is granted to copy and distribute this program
  826. Xwithout charge, provided this copyright notice is included
  827. Xin the copy.
  828. XThis Software is distributed on an as-is basis. There will be
  829. XABSOLUTELY NO WARRANTY for any part of this software to work
  830. Xcorrect. In no case will the author be liable to you for damages
  831. Xcaused by the usage of this software.
  832. X-------------------------------------------------------------------    
  833. X*/   
  834. X
  835. X#include "taylor.h"
  836. X
  837. Xextern void F(); /*  front  */
  838. Xextern void L(); /*  left   */
  839. Xextern void R(); /*  right  */
  840. Xextern void B(); /*  back   */
  841. Xextern void U(); /*  up     */
  842. Xextern void D(); /*  down   */
  843. X
  844. Xextern void first_layer_corner_tfr();   /* layer1c_txx */
  845. Xextern void first_layer_corner_trb();   /* layer1c_txx */
  846. Xextern void first_layer_corner_tbl();   /* layer1c_txx */
  847. Xextern void first_layer_corner_tlf();   /* layer1c_txx */
  848. X
  849. XBoolean first_layer_corner(w,wdata,call_data) /* These parameters needed for macros */
  850. X     Widget   w;
  851. X     widget_data *wdata;
  852. X     caddr_t  call_data;
  853. X{
  854. X  /* Search for the Top corner cubes,
  855. X     place in lower layer directly below
  856. X     destination cube then  
  857. X     dispatch to first_layer_corner_tXX accordingly.
  858. X     There are 8 corner cubes in all.
  859. X     */
  860. X
  861. X  /* Bottom Corner Cubes */
  862. X  /* There are 12 places a TOP can be in the bottom layer.
  863. X   */
  864. X  
  865. X  /*1*/
  866. X  if(Front(8) == TOP){
  867. X    if(Right(6) == FRONT){
  868. X      if(Bottom(2) == RIGHT){
  869. X    first_layer_corner_tfr(w,wdata,call_data); 
  870. X      }
  871. X      else if(Bottom(2) == LEFT){
  872. X    D(-1);
  873. X    first_layer_corner_tlf(w,wdata,call_data); 
  874. X      }
  875. X    }
  876. X    else if(Right(6) == RIGHT){
  877. X      if(Bottom(2) == FRONT){
  878. X    first_layer_corner_tfr(w,wdata,call_data); 
  879. X      }
  880. X      else if(Bottom(2) == BACK){
  881. X    D(1);
  882. X    first_layer_corner_trb(w,wdata,call_data); 
  883. X      }
  884. X    }
  885. X    else if(Right(6) == BACK){
  886. X      if(Bottom(2) == RIGHT){
  887. X    D(1);
  888. X    first_layer_corner_trb(w,wdata,call_data);
  889. X      }
  890. X      else if(Bottom(2) == LEFT){
  891. X    D(2);
  892. X    first_layer_corner_tbl(w,wdata,call_data);
  893. X      }
  894. X    }
  895. X    else if(Right(6) == LEFT){
  896. X      if(Bottom(2) == FRONT){
  897. X    D(-1);
  898. X    first_layer_corner_tlf(w,wdata,call_data);
  899. X      }
  900. X      else if(Bottom(2) == BACK){
  901. X    D(2);
  902. X    first_layer_corner_tbl(w,wdata,call_data);
  903. X      }
  904. X    }
  905. X  }
  906. X  
  907. X  else if(Right(6) == TOP){
  908. X    if(Front(8) == FRONT){
  909. X      if(Bottom(2) == RIGHT){
  910. X    first_layer_corner_tfr(w,wdata,call_data); 
  911. X      }
  912. X      else if(Bottom(2) == LEFT){
  913. X    D(-1);
  914. X    first_layer_corner_tlf(w,wdata,call_data); 
  915. X      }
  916. X    }
  917. X    else if(Front(8) == RIGHT){
  918. X      if(Bottom(2) == FRONT){
  919. X    first_layer_corner_tfr(w,wdata,call_data); 
  920. X      }
  921. X      else if(Bottom(2) == BACK){
  922. X    D(1);
  923. X    first_layer_corner_trb(w,wdata,call_data); 
  924. X      }
  925. X    }
  926. X    else if(Front(8) == BACK){
  927. X      if(Bottom(2) == RIGHT){
  928. X    D(1);
  929. X    first_layer_corner_trb(w,wdata,call_data);
  930. X      }
  931. X      else if(Bottom(2) == LEFT){
  932. X    D(2);
  933. X    first_layer_corner_tbl(w,wdata,call_data);
  934. X      }
  935. X    }
  936. X    else if(Front(8) == LEFT){
  937. X      if(Bottom(2) == FRONT){
  938. X    D(-1);
  939. X    first_layer_corner_tlf(w,wdata,call_data);
  940. X      }
  941. X      else if(Bottom(2) == BACK){
  942. X    D(2);
  943. X    first_layer_corner_tbl(w,wdata,call_data);
  944. X      }
  945. X    }
  946. X  }
  947. X  
  948. X  else if(Bottom(2) == TOP){
  949. X    if(Front(8) == FRONT){
  950. X      if(Right(6) == RIGHT){
  951. X    first_layer_corner_tfr(w,wdata,call_data); 
  952. X      }
  953. X      else if(Right(6) == LEFT){
  954. X    D(-1);
  955. X    first_layer_corner_tlf(w,wdata,call_data); 
  956. X      }
  957. X    }
  958. X    else if(Front(8) == RIGHT){
  959. X      if(Right(6) == FRONT){
  960. X    first_layer_corner_tfr(w,wdata,call_data); 
  961. X      }
  962. X      else if(Right(6) == BACK){
  963. X    D(1);
  964. X    first_layer_corner_trb(w,wdata,call_data); 
  965. X      }
  966. X    }
  967. X    else if(Front(8) == BACK){
  968. X      if(Right(6) == RIGHT){
  969. X    D(1);
  970. X    first_layer_corner_trb(w,wdata,call_data);
  971. X      }
  972. X      else if(Right(6) == LEFT){
  973. X    D(2);
  974. X    first_layer_corner_tbl(w,wdata,call_data);
  975. X      }
  976. X    }
  977. X    else if(Front(8) == LEFT){
  978. X      if(Right(6) == FRONT){
  979. X    D(-1);
  980. X    first_layer_corner_tlf(w,wdata,call_data);
  981. X      }
  982. X      else if(Right(6) == BACK){
  983. X    D(2);
  984. X    first_layer_corner_tbl(w,wdata,call_data);
  985. X      }
  986. X    }
  987. X  }
  988. X  
  989. X  /*2*/
  990. X  if(Right(8)  == TOP){
  991. X    if(Back(8) == FRONT){
  992. X      if(Bottom(8) == RIGHT){
  993. X    D(-1);
  994. X    first_layer_corner_tfr(w,wdata,call_data); 
  995. X      }
  996. X      else if(Bottom(8) == LEFT){
  997. X    D(2);
  998. X    first_layer_corner_tlf(w,wdata,call_data); 
  999. X      }
  1000. X    }
  1001. X    else if(Back(8) == RIGHT){
  1002. X      if(Bottom(8) == FRONT){
  1003. X    D(-1);
  1004. X    first_layer_corner_tfr(w,wdata,call_data); 
  1005. X      }
  1006. X      else if(Bottom(8) == BACK){
  1007. X    first_layer_corner_trb(w,wdata,call_data); 
  1008. X      }
  1009. X    }
  1010. X    else if(Back(8) == BACK){
  1011. X      if(Bottom(8) == RIGHT){
  1012. X    first_layer_corner_trb(w,wdata,call_data);
  1013. X      }
  1014. X      else if(Bottom(8) == LEFT){
  1015. X    D(1);
  1016. X    first_layer_corner_tbl(w,wdata,call_data);
  1017. X      }
  1018. X    }
  1019. X    else if(Back(8) == LEFT){
  1020. X      if(Bottom(8) == FRONT){
  1021. X    D(2);
  1022. X    first_layer_corner_tlf(w,wdata,call_data);
  1023. X      }
  1024. X      else if(Bottom(8) == BACK){
  1025. X    D(1);
  1026. X    first_layer_corner_tbl(w,wdata,call_data);
  1027. X      }
  1028. X    }
  1029. X  }
  1030. X  
  1031. X  else if(Back(8)  == TOP){
  1032. X    if(Right(8) == FRONT){
  1033. X      if(Bottom(8) == RIGHT){
  1034. X    D(-1);
  1035. X    first_layer_corner_tfr(w,wdata,call_data); 
  1036. X      }
  1037. X      else if(Bottom(8) == LEFT){
  1038. X    D(2);
  1039. X    first_layer_corner_tlf(w,wdata,call_data); 
  1040. X      }
  1041. X    }
  1042. X    else if(Right(8) == RIGHT){
  1043. X      if(Bottom(8) == FRONT){
  1044. X    D(-1);
  1045. X    first_layer_corner_tfr(w,wdata,call_data); 
  1046. X      }
  1047. X      else if(Bottom(8) == BACK){
  1048. X    first_layer_corner_trb(w,wdata,call_data); 
  1049. X      }
  1050. X    }
  1051. X    else if(Right(8) == BACK){
  1052. X      if(Bottom(8) == RIGHT){
  1053. X    first_layer_corner_trb(w,wdata,call_data);
  1054. X      }
  1055. X      else if(Bottom(8) == LEFT){
  1056. X    D(1);
  1057. X    first_layer_corner_tbl(w,wdata,call_data);
  1058. X      }
  1059. X    }
  1060. X    else if(Right(8) == LEFT){
  1061. X      if(Bottom(8) == FRONT){
  1062. X    D(2);
  1063. X    first_layer_corner_tlf(w,wdata,call_data);
  1064. X      }
  1065. X      else if(Bottom(8) == BACK){
  1066. X    D(1);
  1067. X    first_layer_corner_tbl(w,wdata,call_data);
  1068. X      }
  1069. X    }
  1070. X  }
  1071. X  
  1072. X  else if(Bottom(8)  == TOP){
  1073. X    if(Right(8) == FRONT){
  1074. X      if(Back(8) == RIGHT){
  1075. X    D(-1);
  1076. X    first_layer_corner_tfr(w,wdata,call_data); 
  1077. X      }
  1078. X      else if(Back(8) == LEFT){
  1079. X    D(2);
  1080. X    first_layer_corner_tlf(w,wdata,call_data); 
  1081. X      }
  1082. X    }
  1083. X    else if(Right(8) == RIGHT){
  1084. X      if(Back(8) == FRONT){
  1085. X    D(-1);
  1086. X    first_layer_corner_tfr(w,wdata,call_data); 
  1087. X      }
  1088. X      else if(Back(8) == BACK){
  1089. X    first_layer_corner_trb(w,wdata,call_data); 
  1090. X      }
  1091. X    }
  1092. X    else if(Right(8) == BACK){
  1093. X      if(Back(8) == RIGHT){
  1094. X    first_layer_corner_trb(w,wdata,call_data);
  1095. X      }
  1096. X      else if(Back(8) == LEFT){
  1097. X    D(1);
  1098. X    first_layer_corner_tbl(w,wdata,call_data);
  1099. X      }
  1100. X    }
  1101. X    else if(Right(8) == LEFT){
  1102. X      if(Back(8) == FRONT){
  1103. X    D(2);
  1104. X    first_layer_corner_tlf(w,wdata,call_data);
  1105. X      }
  1106. X      else if(Back(8) == BACK){
  1107. X    D(1);
  1108. X    first_layer_corner_tbl(w,wdata,call_data);
  1109. X      }
  1110. X    }
  1111. X  }
  1112. X  
  1113. X  /*3*/
  1114. X  if(Back(6)  == TOP){
  1115. X    if(Left(8) == FRONT){
  1116. X      if(Bottom(6) == RIGHT){
  1117. X    D(2);
  1118. X    first_layer_corner_tfr(w,wdata,call_data); 
  1119. X      }
  1120. X      else if(Bottom(6) == LEFT){
  1121. X    D(1);
  1122. X    first_layer_corner_tlf(w,wdata,call_data); 
  1123. X      }
  1124. X    }
  1125. X    else if(Left(8) == RIGHT){
  1126. X      if(Bottom(6) == FRONT){
  1127. X    D(2);
  1128. X    first_layer_corner_tfr(w,wdata,call_data); 
  1129. X      }
  1130. X      else if(Bottom(6) == BACK){
  1131. X    D(-1);
  1132. X    first_layer_corner_trb(w,wdata,call_data); 
  1133. X      }
  1134. X    }
  1135. X    else if(Left(8) == BACK){
  1136. X      if(Bottom(6) == RIGHT){
  1137. X    D(-1);
  1138. X    first_layer_corner_trb(w,wdata,call_data);
  1139. X      }
  1140. X      else if(Bottom(6) == LEFT){
  1141. X    first_layer_corner_tbl(w,wdata,call_data);
  1142. X      }
  1143. X    }
  1144. X    else if(Left(8) == LEFT){
  1145. X      if(Bottom(6) == FRONT){
  1146. X    D(1);
  1147. X    first_layer_corner_tlf(w,wdata,call_data);
  1148. X      }
  1149. X      else if(Bottom(6) == BACK){
  1150. X    first_layer_corner_tbl(w,wdata,call_data);
  1151. X      }
  1152. X    }
  1153. X  }
  1154. X  
  1155. X  else if(Left(8)  == TOP){
  1156. X    if(Back(6) == FRONT){
  1157. X      if(Bottom(6) == RIGHT){
  1158. X    D(2);
  1159. X    first_layer_corner_tfr(w,wdata,call_data); 
  1160. X      }
  1161. X      else if(Bottom(6) == LEFT){
  1162. X    D(1);
  1163. X    first_layer_corner_tlf(w,wdata,call_data); 
  1164. X      }
  1165. X    }
  1166. X    else if(Back(6) == RIGHT){
  1167. X      if(Bottom(6) == FRONT){
  1168. X    D(2);
  1169. X    first_layer_corner_tfr(w,wdata,call_data); 
  1170. X      }
  1171. X      else if(Bottom(6) == BACK){
  1172. X    D(-1);
  1173. X    first_layer_corner_trb(w,wdata,call_data); 
  1174. X      }
  1175. X    }
  1176. X    else if(Back(6) == BACK){
  1177. X      if(Bottom(6) == RIGHT){
  1178. X    D(-1);
  1179. X    first_layer_corner_trb(w,wdata,call_data);
  1180. X      }
  1181. X      else if(Bottom(6) == LEFT){
  1182. X    first_layer_corner_tbl(w,wdata,call_data);
  1183. X      }
  1184. X    }
  1185. X    else if(Back(6) == LEFT){
  1186. X      if(Bottom(6) == FRONT){
  1187. X    D(1);
  1188. X    first_layer_corner_tlf(w,wdata,call_data);
  1189. X      }
  1190. X      else if(Bottom(6) == BACK){
  1191. X    first_layer_corner_tbl(w,wdata,call_data);
  1192. X      }
  1193. X    }
  1194. X  }
  1195. X  
  1196. X  else if(Bottom(6)  == TOP){
  1197. X    if(Back(6) == FRONT){
  1198. X      if(Left(8) == RIGHT){
  1199. X    D(2);
  1200. X    first_layer_corner_tfr(w,wdata,call_data); 
  1201. X      }
  1202. X      else if(Left(8) == LEFT){
  1203. X    D(1);
  1204. X    first_layer_corner_tlf(w,wdata,call_data); 
  1205. X      }
  1206. X    }
  1207. X    else if(Back(6) == RIGHT){
  1208. X      if(Left(8) == FRONT){
  1209. X    D(2);
  1210. X    first_layer_corner_tfr(w,wdata,call_data); 
  1211. X      }
  1212. X      else if(Left(8) == BACK){
  1213. X    D(-1);
  1214. X    first_layer_corner_trb(w,wdata,call_data); 
  1215. X      }
  1216. X    }
  1217. X    else if(Back(6) == BACK){
  1218. X      if(Left(8) == RIGHT){
  1219. X    D(-1);
  1220. X    first_layer_corner_trb(w,wdata,call_data);
  1221. X      }
  1222. X      else if(Left(8) == LEFT){
  1223. X    first_layer_corner_tbl(w,wdata,call_data);
  1224. X      }
  1225. X    }
  1226. X    else if(Back(6) == LEFT){
  1227. X      if(Left(8) == FRONT){
  1228. X    D(1);
  1229. X    first_layer_corner_tlf(w,wdata,call_data);
  1230. X      }
  1231. X      else if(Left(8) == BACK){
  1232. X    first_layer_corner_tbl(w,wdata,call_data);
  1233. X      }
  1234. X    }
  1235. X  }
  1236. X  
  1237. X  /*4*/
  1238. X  if(Left(6)  == TOP){
  1239. X    if(Front(6) == FRONT){
  1240. X      if(Bottom(0) == RIGHT){
  1241. X    D(1);
  1242. X    first_layer_corner_tfr(w,wdata,call_data); 
  1243. X      }
  1244. X      else if(Bottom(0) == LEFT){
  1245. X    first_layer_corner_tlf(w,wdata,call_data); 
  1246. X      }
  1247. X    }
  1248. X    else if(Front(6) == RIGHT){
  1249. X      if(Bottom(0) == FRONT){
  1250. X    D(1);
  1251. X    first_layer_corner_tfr(w,wdata,call_data); 
  1252. X      }
  1253. X      else if(Bottom(0) == BACK){
  1254. X    D(2);
  1255. X    first_layer_corner_trb(w,wdata,call_data); 
  1256. X      }
  1257. X    }
  1258. X    else if(Front(6) == BACK){
  1259. X      if(Bottom(0) == RIGHT){
  1260. X    D(2);
  1261. X    first_layer_corner_trb(w,wdata,call_data);
  1262. X      }
  1263. X      else if(Bottom(0) == LEFT){
  1264. X    D(-1);
  1265. X    first_layer_corner_tbl(w,wdata,call_data);
  1266. X      }
  1267. X    }
  1268. X    else if(Front(6) == LEFT){
  1269. X      if(Bottom(0) == FRONT){
  1270. X    first_layer_corner_tlf(w,wdata,call_data);
  1271. X      }
  1272. X      else if(Bottom(0) == BACK){
  1273. X    D(-1);
  1274. X    first_layer_corner_tbl(w,wdata,call_data);
  1275. X      }
  1276. X    }
  1277. X  }
  1278. X  
  1279. X  else if(Front(6)  == TOP){
  1280. X    if(Left(6) == FRONT){
  1281. X      if(Bottom(0) == RIGHT){
  1282. X    D(1);
  1283. X    first_layer_corner_tfr(w,wdata,call_data); 
  1284. X      }
  1285. X      else if(Bottom(0) == LEFT){
  1286. X    first_layer_corner_tlf(w,wdata,call_data); 
  1287. X      }
  1288. X    }
  1289. X    else if(Left(6) == RIGHT){
  1290. X      if(Bottom(0) == FRONT){
  1291. X    D(1);
  1292. X    first_layer_corner_tfr(w,wdata,call_data); 
  1293. X      }
  1294. X      else if(Bottom(0) == BACK){
  1295. X    D(2);
  1296. X    first_layer_corner_trb(w,wdata,call_data); 
  1297. X      }
  1298. X    }
  1299. X    else if(Left(6) == BACK){
  1300. X      if(Bottom(0) == RIGHT){
  1301. X    D(2);
  1302. X    first_layer_corner_trb(w,wdata,call_data);
  1303. X      }
  1304. X      else if(Bottom(0) == LEFT){
  1305. X    D(-1);
  1306. X    first_layer_corner_tbl(w,wdata,call_data);
  1307. X      }
  1308. X    }
  1309. X    else if(Left(6) == LEFT){
  1310. X      if(Bottom(0) == FRONT){
  1311. X    first_layer_corner_tlf(w,wdata,call_data);
  1312. X      }
  1313. X      else if(Bottom(0) == BACK){
  1314. X    D(-1);
  1315. X    first_layer_corner_tbl(w,wdata,call_data);
  1316. X      }
  1317. X    }
  1318. X  }
  1319. X
  1320. X  else if(Bottom(0)  == TOP){
  1321. X    if(Left(6) == FRONT){
  1322. X      if(Front(6) == RIGHT){
  1323. X    D(1);
  1324. X    first_layer_corner_tfr(w,wdata,call_data); 
  1325. X      }
  1326. X      else if(Front(6) == LEFT){
  1327. X    first_layer_corner_tlf(w,wdata,call_data); 
  1328. X      }
  1329. X    }
  1330. X    else if(Left(6) == RIGHT){
  1331. X      if(Front(6) == FRONT){
  1332. X    D(1);
  1333. X    first_layer_corner_tfr(w,wdata,call_data); 
  1334. X      }
  1335. X      else if(Front(6) == BACK){
  1336. X    D(2);
  1337. X    first_layer_corner_trb(w,wdata,call_data); 
  1338. X      }
  1339. X    }
  1340. X    else if(Left(6) == BACK){
  1341. X      if(Front(6) == RIGHT){
  1342. X    D(2);
  1343. X    first_layer_corner_trb(w,wdata,call_data);
  1344. X      }
  1345. X      else if(Front(6) == LEFT){
  1346. X    D(-1);
  1347. X    first_layer_corner_tbl(w,wdata,call_data);
  1348. X      }
  1349. X    }
  1350. X    else if(Left(6) == LEFT){
  1351. X      if(Front(6) == FRONT){
  1352. X    first_layer_corner_tlf(w,wdata,call_data);
  1353. X      }
  1354. X      else if(Front(6) == BACK){
  1355. X    D(-1);
  1356. X    first_layer_corner_tbl(w,wdata,call_data);
  1357. X      }
  1358. X    }
  1359. X  }
  1360. X
  1361. X  /* Top Corner Cubes */
  1362. X  /* There are 12 places a TOP can be in the top layer corner cubes layer.
  1363. X      If all first layer corners are ok, then True is returned.
  1364. X      Else if a TOP is found in top layer corner, with the wrong orientation then
  1365. X     the operation to bring it to the lower layer is performed.
  1366. X      Else False is returned. 
  1367. X   */
  1368. X
  1369. X  if(Top(0) == TOP &&
  1370. X     Top(2) == TOP &&
  1371. X     Top(6) == TOP &&
  1372. X     Top(8) == TOP &&
  1373. X     Front(0) == FRONT &&
  1374. X     Front(2) == FRONT &&
  1375. X     Right(0) == RIGHT &&
  1376. X     Right(2) == RIGHT &&
  1377. X     Back(0) == BACK &&
  1378. X     Back(2) == BACK &&
  1379. X     Left(0) == LEFT &&
  1380. X     Left(2) == LEFT)
  1381. X    return(True);
  1382. X  
  1383. X  /* Here if more passes needed.
  1384. X   * Check if any miss-oriented ones on top.
  1385. X   * If so, then bring it down to bottom layer.
  1386. X   */
  1387. X  if((Top(2)   == TOP ||  
  1388. X      Front(2) == TOP ||  
  1389. X      Right(0) == TOP) &&
  1390. X     (Top(2)   != TOP ||  
  1391. X      Front(2) != FRONT ||  
  1392. X      Right(0) != RIGHT)){
  1393. X    R(-1);D(1);R(1);
  1394. X    return(False);
  1395. X  }
  1396. X  
  1397. X  if((Top(8)   == TOP ||  
  1398. X      Right(2) == TOP ||  
  1399. X      Back(2)  == TOP) &&
  1400. X     (Top(8)   != TOP ||  
  1401. X      Right(2) != RIGHT ||  
  1402. X      Back(2)  != BACK)){
  1403. X    B(-1);D(1);B(1);
  1404. X    return(False);
  1405. X  }
  1406. X  
  1407. X  if((Top(6)   == TOP ||  
  1408. X      Back(0)  == TOP ||  
  1409. X      Left(2)  == TOP) &&
  1410. X     (Top(6)   != TOP ||  
  1411. X      Back(0)  != BACK ||  
  1412. X      Left(2)  != LEFT)){
  1413. X    L(-1);D(1);L(1);
  1414. X    return(False);
  1415. X  }
  1416. X  
  1417. X  if((Top(0)   == TOP ||  
  1418. X      Left(0)  == TOP ||  
  1419. X      Front(0) == TOP) &&
  1420. X     (Top(0)   != TOP ||  
  1421. X      Left(0)  != LEFT ||  
  1422. X      Front(0) != FRONT)){
  1423. X    F(-1);D(1);F(1);
  1424. X    return(False);
  1425. X  }
  1426. X  return(False);
  1427. X}
  1428. END_OF_FILE
  1429.   if test 14286 -ne `wc -c <'cube/layer1corner.c'`; then
  1430.     echo shar: \"'cube/layer1corner.c'\" unpacked with wrong size!
  1431.   fi
  1432.   # end of 'cube/layer1corner.c'
  1433. fi
  1434. if test ! -d 'cube/lib' ; then
  1435.     echo shar: Creating directory \"'cube/lib'\"
  1436.     mkdir 'cube/lib'
  1437. fi
  1438. if test -f 'cube/lib/Makefile' -a "${1}" != "-c" ; then 
  1439.   echo shar: Will not clobber existing file \"'cube/lib/Makefile'\"
  1440. else
  1441.   echo shar: Extracting \"'cube/lib/Makefile'\" \(8662 characters\)
  1442.   sed "s/^X//" >'cube/lib/Makefile' <<'END_OF_FILE'
  1443. X# Makefile generated by imake - do not edit!
  1444. X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  1445. X#
  1446. X# The cpp used on this machine replaces all newlines and multiple tabs and
  1447. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  1448. X# for this, but is not always successful.
  1449. X#
  1450. X
  1451. X###########################################################################
  1452. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a02079>
  1453. X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  1454. X#
  1455. X# Platform-specific parameters may be set in the appropriate .cf
  1456. X# configuration files.  Site-wide parameters may be set in the file
  1457. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  1458. X#
  1459. X# If your C preprocessor doesn't define any unique symbols, you'll need
  1460. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  1461. X# "make Makefile", "make Makefiles", or "make World").
  1462. X#
  1463. X# If you absolutely can't get imake to work, you'll need to set the
  1464. X# variables at the top of each Makefile as well as the dependencies at the
  1465. X# bottom (makedepend will do this automatically).
  1466. X#
  1467. X
  1468. X###########################################################################
  1469. X# platform-specific configuration parameters - edit sun.cf to change
  1470. X
  1471. X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
  1472. X# operating system:  SunOS 4.0.3
  1473. X
  1474. X###########################################################################
  1475. X# site-specific configuration parameters - edit site.def to change
  1476. X
  1477. X            SHELL = /bin/sh
  1478. X
  1479. X              TOP = ../.
  1480. X      CURRENT_DIR = ./lib
  1481. X
  1482. X               AR = ar clq
  1483. X  BOOTSTRAPCFLAGS =
  1484. X               CC = cc
  1485. X
  1486. X         COMPRESS = compress
  1487. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  1488. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  1489. X          INSTALL = install
  1490. X               LD = ld
  1491. X             LINT = lint
  1492. X      LINTLIBFLAG = -C
  1493. X         LINTOPTS = -axz
  1494. X               LN = ln -s
  1495. X             MAKE = make
  1496. X               MV = mv
  1497. X               CP = cp
  1498. X           RANLIB = ranlib
  1499. X  RANLIBINSTFLAGS =
  1500. X               RM = rm -f
  1501. X     STD_INCLUDES =
  1502. X  STD_CPP_DEFINES =
  1503. X      STD_DEFINES =
  1504. X EXTRA_LOAD_FLAGS =
  1505. X  EXTRA_LIBRARIES =
  1506. X             TAGS = ctags
  1507. X
  1508. X    SHAREDCODEDEF = -DSHAREDCODE
  1509. X         SHLIBDEF = -DSUNSHLIB
  1510. X
  1511. X    PROTO_DEFINES =
  1512. X
  1513. X     INSTPGMFLAGS =
  1514. X
  1515. X     INSTBINFLAGS = -m 0755
  1516. X     INSTUIDFLAGS = -m 4755
  1517. X     INSTLIBFLAGS = -m 0664
  1518. X     INSTINCFLAGS = -m 0444
  1519. X     INSTMANFLAGS = -m 0444
  1520. X     INSTDATFLAGS = -m 0444
  1521. X    INSTKMEMFLAGS = -m 4755
  1522. X
  1523. X          DESTDIR =
  1524. X
  1525. X     TOP_INCLUDES = -I$(INCROOT)
  1526. X
  1527. X      CDEBUGFLAGS = -O
  1528. X        CCOPTIONS =
  1529. X      COMPATFLAGS =
  1530. X
  1531. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
  1532. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  1533. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  1534. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  1535. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1536. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  1537. X   LDCOMBINEFLAGS = -X -r
  1538. X
  1539. X        MACROFILE = sun.cf
  1540. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  1541. X
  1542. X    IMAKE_DEFINES =
  1543. X
  1544. X         IRULESRC = $(CONFIGDIR)
  1545. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  1546. X
  1547. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  1548. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  1549. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  1550. X
  1551. X###########################################################################
  1552. X# X Window System Build Parameters
  1553. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  1554. X
  1555. X###########################################################################
  1556. X# X Window System make variables; this need to be coordinated with rules
  1557. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  1558. X
  1559. X          PATHSEP = /
  1560. X        USRLIBDIR = $(DESTDIR)/usr/lib
  1561. X           BINDIR = $(DESTDIR)/usr/bin/X11
  1562. X          INCROOT = $(DESTDIR)/usr/include
  1563. X     BUILDINCROOT = $(TOP)
  1564. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  1565. X      BUILDINCTOP = ..
  1566. X           INCDIR = $(INCROOT)/X11
  1567. X           ADMDIR = $(DESTDIR)/usr/adm
  1568. X           LIBDIR = $(USRLIBDIR)/X11
  1569. X        CONFIGDIR = $(LIBDIR)/config
  1570. X       LINTLIBDIR = $(USRLIBDIR)/lint
  1571. X
  1572. X          FONTDIR = $(LIBDIR)/fonts
  1573. X         XINITDIR = $(LIBDIR)/xinit
  1574. X           XDMDIR = $(LIBDIR)/xdm
  1575. X           AWMDIR = $(LIBDIR)/awm
  1576. X           TWMDIR = $(LIBDIR)/twm
  1577. X           GWMDIR = $(LIBDIR)/gwm
  1578. X          MANPATH = $(DESTDIR)/usr/man
  1579. X    MANSOURCEPATH = $(MANPATH)/man
  1580. X           MANDIR = $(MANSOURCEPATH)n
  1581. X        LIBMANDIR = $(MANSOURCEPATH)3
  1582. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  1583. X
  1584. X        SOXLIBREV = 4.2
  1585. X          SOXTREV = 4.0
  1586. X         SOXAWREV = 4.0
  1587. X        SOOLDXREV = 4.0
  1588. X         SOXMUREV = 4.0
  1589. X        SOXEXTREV = 4.0
  1590. X
  1591. X       FONTCFLAGS = -t
  1592. X
  1593. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  1594. X
  1595. X            IMAKE = imake
  1596. X           DEPEND = makedepend
  1597. X              RGB = rgb
  1598. X            FONTC = bdftosnf
  1599. X        MKFONTDIR = mkfontdir
  1600. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
  1601. X
  1602. X        CONFIGSRC = $(TOP)/config
  1603. X        CLIENTSRC = $(TOP)/clients
  1604. X          DEMOSRC = $(TOP)/demos
  1605. X           LIBSRC = $(TOP)/lib
  1606. X          FONTSRC = $(TOP)/fonts
  1607. X       INCLUDESRC = $(TOP)/X11
  1608. X        SERVERSRC = $(TOP)/server
  1609. X          UTILSRC = $(TOP)/util
  1610. X        SCRIPTSRC = $(UTILSRC)/scripts
  1611. X       EXAMPLESRC = $(TOP)/examples
  1612. X       CONTRIBSRC = $(TOP)/../contrib
  1613. X           DOCSRC = $(TOP)/doc
  1614. X           RGBSRC = $(TOP)/rgb
  1615. X        DEPENDSRC = $(UTILSRC)/makedepend
  1616. X         IMAKESRC = $(CONFIGSRC)
  1617. X         XAUTHSRC = $(LIBSRC)/Xau
  1618. X          XLIBSRC = $(LIBSRC)/X
  1619. X           XMUSRC = $(LIBSRC)/Xmu
  1620. X       TOOLKITSRC = $(LIBSRC)/Xt
  1621. X       AWIDGETSRC = $(LIBSRC)/Xaw
  1622. X       OLDXLIBSRC = $(LIBSRC)/oldX
  1623. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  1624. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1625. X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  1626. X     EXTENSIONSRC = $(TOP)/extensions
  1627. X
  1628. X  DEPEXTENSIONLIB =
  1629. X     EXTENSIONLIB = -lXext
  1630. X
  1631. X          DEPXLIB = $(DEPEXTENSIONLIB)
  1632. X             XLIB = $(EXTENSIONLIB) -lX11
  1633. X
  1634. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  1635. X         XAUTHLIB =  -lXau
  1636. X
  1637. X        DEPXMULIB =
  1638. X           XMULIB = -lXmu
  1639. X
  1640. X       DEPOLDXLIB =
  1641. X          OLDXLIB = -loldX
  1642. X
  1643. X      DEPXTOOLLIB =
  1644. X         XTOOLLIB = -lXt
  1645. X
  1646. X        DEPXAWLIB =
  1647. X           XAWLIB = -lXaw
  1648. X
  1649. X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
  1650. X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
  1651. X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
  1652. X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
  1653. X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
  1654. X
  1655. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  1656. X
  1657. X         DEPLIBS1 = $(DEPLIBS)
  1658. X         DEPLIBS2 = $(DEPLIBS)
  1659. X         DEPLIBS3 = $(DEPLIBS)
  1660. X
  1661. X###########################################################################
  1662. X# Imake rules for building libraries, programs, scripts, and data files
  1663. X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
  1664. X
  1665. X###########################################################################
  1666. X# start of Imakefile
  1667. X
  1668. X#
  1669. X# Imakefile - Xs
  1670. X
  1671. XSTD_INCLUDES = -I/usr/local/X11R5/include -I/usr/local/include  -I./lib
  1672. XSTD_CPP_DEFINES =
  1673. XSTD_DEFINES =
  1674. XEXTRA_LOAD_FLAGS = -lXm -lX11 -lXt
  1675. XEXTRA_LIBRARIES = -L/usr/local/X11R5/lib -L/usr/lib
  1676. X
  1677. XSRCS =  concat.c str2flt.c invert.c quit.c talkto.c wprintf.c insert.c xmstr_to_str.c\
  1678. X    send_msg.c xor.c strtoxmstr.c menus.c help_dialog.c pix_buttons.c
  1679. X
  1680. XOBJS =  concat.o str2flt.o invert.o quit.o talkto.o wprintf.o insert.o xmstr_to_str.o\
  1681. X    send_msg.o  xor.o strtoxmstr.o menus.o help_dialog.o pix_buttons.o
  1682. X
  1683. X#
  1684. X# Make Xs
  1685. X#
  1686. X
  1687. Xall:: libXs.a
  1688. X
  1689. XlibXs.a:  $(OBJS)
  1690. X    $(RM) $@
  1691. X    $(AR) $@  $(OBJS)
  1692. X    $(RANLIB) $@
  1693. X
  1694. Xdepend::
  1695. X    $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  1696. X
  1697. X###########################################################################
  1698. X# common rules for all Makefiles - do not edit
  1699. X
  1700. Xemptyrule::
  1701. X
  1702. Xclean::
  1703. X    $(RM_CMD) \#*
  1704. X
  1705. XMakefile::
  1706. X    -@if [ -f Makefile ]; then \
  1707. X    echo "    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  1708. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  1709. X    else exit 0; fi
  1710. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  1711. X
  1712. Xtags::
  1713. X    $(TAGS) -w *.[ch]
  1714. X    $(TAGS) -xw *.[ch] > TAGS
  1715. X
  1716. Xsaber:
  1717. X    #load $(ALLDEFINES) $(SRCS)
  1718. X
  1719. Xosaber:
  1720. X    #load $(ALLDEFINES) $(OBJS)
  1721. X
  1722. X###########################################################################
  1723. X# empty rules for directories that do not have SUBDIRS - do not edit
  1724. X
  1725. Xinstall::
  1726. X    @echo "install in $(CURRENT_DIR) done"
  1727. X
  1728. Xinstall.man::
  1729. X    @echo "install.man in $(CURRENT_DIR) done"
  1730. X
  1731. XMakefiles::
  1732. X
  1733. Xincludes::
  1734. X
  1735. X###########################################################################
  1736. X# dependencies generated by makedepend
  1737. X
  1738. END_OF_FILE
  1739.   if test 8662 -ne `wc -c <'cube/lib/Makefile'`; then
  1740.     echo shar: \"'cube/lib/Makefile'\" unpacked with wrong size!
  1741.   fi
  1742.   # end of 'cube/lib/Makefile'
  1743. fi
  1744. echo shar: End of archive 1 \(of 5\).
  1745. cp /dev/null ark1isdone
  1746. MISSING=""
  1747. for I in 1 2 3 4 5 ; do
  1748.     if test ! -f ark${I}isdone ; then
  1749.     MISSING="${MISSING} ${I}"
  1750.     fi
  1751. done
  1752. if test "${MISSING}" = "" ; then
  1753.     echo You have unpacked all 5 archives.
  1754.     rm -f ark[1-9]isdone
  1755. else
  1756.     echo You still must unpack the following archives:
  1757.     echo "        " ${MISSING}
  1758. fi
  1759. exit 0
  1760. exit 0 # Just in case...
  1761.