home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 288.lha / AmiGo_v1.0 / amigainterface.c < prev    next >
C/C++ Source or Header  |  1989-08-22  |  18KB  |  746 lines

  1. /* AmiGo Interface.  Started 4/7/88 by Todd R. Johnson */
  2. /* 8/8/89 Cleaned up for first release */
  3. /* Version 1.0 */
  4. /* Public Domain */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/exec.h>
  8. #include <graphics/display.h>
  9. #include <graphics/gfxbase.h>
  10. #include <graphics/gfxmacros.h>
  11. #include <graphics/rastport.h>
  12. #include <intuition/intuition.h>
  13. #include <libraries/dosextens.h>
  14. #include <proto/exec.h>
  15. #include <proto/graphics.h>
  16. #include <proto/intuition.h>
  17. #include <proto/dos.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21.  
  22. #include "go.h"
  23. #include "menus.h"
  24.  
  25. extern UWORD BlackStoneData[], WhiteStoneData[], IntersectData[],
  26.     starPointData[], ULIntersectData[], UMIntersectData[], URIntersectData[],
  27.     LCIntersectData[], RMIntersectData[], LLIntersectData[], LMIntersectData[],
  28.     LRIntersectData[];
  29.  
  30. extern struct Menu game;
  31.  
  32. extern short showTrees, playLevel, showMoveReason, groupInfo,
  33.              computerBlack, computerWhite;
  34.          
  35. extern enum bVal color;
  36.  
  37. /* Procedures from this file */
  38. void amigainit();
  39. void PrintBoard();
  40. void amigaexit();
  41. void getinput( short *, short *, short *, short );
  42. void processMenuItem( int, short *);
  43. short Intersection( short, short, short *, short * );
  44. void removestone( short, short );
  45. void intrMoveReport( enum bVal, char *, char * );
  46. void intrPass( enum bVal );
  47. void intrPrisonerReport( short, short );
  48. void intrInitScratchArea();
  49. void intrPuts( char * );
  50. void intrPutLn();
  51. void intrPutshort( short );
  52. void intrCredits();
  53.  
  54. /* Amiga display vars */
  55. struct GfxBase *GfxBase;
  56. struct Screen *Screen;
  57. struct NewWindow nw;
  58. struct Window *window;
  59. struct RastPort *rp;
  60. struct ViewPort *vp;
  61. struct IntuiMessage *message;
  62. short sx, sy;        /* Scratch area line pointers */
  63.  
  64. struct NewScreen NewScreen =
  65.    {
  66.    0, 0,             /* LeftEdge, TopEdge */
  67.    640, 200,         /* Width, Height */
  68.    4,                /* Depth */
  69.    0, 0,             /* DetailPen, BlockPen */
  70.    HIRES,            /* ViewModes */
  71.    CUSTOMSCREEN,     /* Type */
  72.    NULL,             /* Font */
  73.    NULL,     /* DefaultTitle */
  74.    NULL,             /* Gadgets */
  75.    NULL,             /* CustomBitMap */
  76.    };
  77.  
  78. USHORT NullColorTable[] =
  79.    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, };
  80.    
  81. USHORT ColorTable[] =
  82.    {
  83.    0x148,    /* Screen background */
  84.    0xFFF,    
  85.    0xD95,    /* Board background */
  86.    0x000,    /* Board Lines */
  87.    0x000,    /* Black stone */
  88.    0xFFF,    /* White stone */
  89.    0x5D0,
  90.    0x7DF,
  91.    0x0ED,
  92.    0x7DF,
  93.    0xC0E,
  94.    0x000,
  95.    0xF2E,
  96.    0xF7D,
  97.    0xFDD,
  98.    0x000,
  99. };
  100.  
  101. struct Image BlackStoneImage =
  102. {
  103.    -7, -3,        /* left top */
  104.    15, 7, 2,        /* width, height, depth */
  105.    BlackStoneData,    /* Image data */
  106.    0x6, 0x0,        /* PlanePick, PlaneOnOff */
  107.    NULL,        /* NextImage */
  108. };
  109.  
  110. struct Image WhiteStoneImage =
  111. {
  112.    -7, -3,        /* left top */
  113.    15, 7, 3,        /* width, height, depth */
  114.    WhiteStoneData,    /* Image data */
  115.    0x7, 0x0,        /* PlanePick, PlaneOnOff */
  116.    NULL,        /* NextImage */
  117. };
  118.  
  119. struct Image IntersectImage =
  120. {
  121.    -7, -3,        /* left top */
  122.    15, 7, 1,        /* width, height, depth */
  123.    IntersectData,    /* Image data */
  124.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  125.    NULL,        /* NextImage */
  126. };
  127.  
  128. struct Image ULIntersectImage =
  129. {
  130.    -7, -3,        /* left top */
  131.    15, 7, 1,        /* width, height, depth */
  132.    ULIntersectData,    /* Image data */
  133.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  134.    NULL,        /* NextImage */
  135. };
  136.  
  137. struct Image UMIntersectImage =
  138. {
  139.    -7, -3,        /* left top */
  140.    15, 7, 1,        /* width, height, depth */
  141.    UMIntersectData,    /* Image data */
  142.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  143.    NULL,        /* NextImage */
  144. };
  145.  
  146. struct Image URIntersectImage =
  147. {
  148.    -7, -3,        /* left top */
  149.    15, 7, 1,        /* width, height, depth */
  150.    URIntersectData,    /* Image data */
  151.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  152.    NULL,        /* NextImage */
  153. };
  154.  
  155. struct Image LCIntersectImage =
  156. {
  157.    -7, -3,        /* left top */
  158.    15, 7, 1,        /* width, height, depth */
  159.    LCIntersectData,    /* Image data */
  160.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  161.    NULL,        /* NextImage */
  162. };
  163.  
  164. struct Image RMIntersectImage =
  165. {
  166.    -7, -3,        /* left top */
  167.    15, 7, 1,        /* width, height, depth */
  168.    RMIntersectData,    /* Image data */
  169.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  170.    NULL,        /* NextImage */
  171. };
  172.  
  173. struct Image LLIntersectImage =
  174. {
  175.    -7, -3,        /* left top */
  176.    15, 7, 1,        /* width, height, depth */
  177.    LLIntersectData,    /* Image data */
  178.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  179.    NULL,        /* NextImage */
  180. };
  181.  
  182. struct Image LMIntersectImage =
  183. {
  184.    -7, -3,        /* left top */
  185.    15, 7, 1,        /* width, height, depth */
  186.    LMIntersectData,    /* Image data */
  187.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  188.    NULL,        /* NextImage */
  189. };
  190.  
  191. struct Image LRIntersectImage =
  192. {
  193.    -7, -3,        /* left top */
  194.    15, 7, 1,        /* width, height, depth */
  195.    LRIntersectData,    /* Image data */
  196.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  197.    NULL,        /* NextImage */
  198. };
  199.  
  200. struct Image starPointImage =
  201. {
  202.    -7, -3,        /* left top */
  203.    15, 7, 1,        /* width, height, depth */
  204.    starPointData,    /* Image data */
  205.    0x1, 0x2,        /* PlanePick, PlaneOnOff */
  206.    NULL,        /* NextImage */
  207. };
  208.  
  209. short starPoint[] = { 3, 9, 15 };
  210.  
  211. #define linecolor 3
  212. #define boardcolor 2
  213. #define bxoffset 28
  214. #define byoffset 5
  215. #define xedge 10     /* Width of the x border */
  216. #define yedge 5        /* Width of the y border */
  217. #define bxmin 0 + bxoffset
  218. #define bxmax 396 + bxoffset
  219. #define bymin 0 + byoffset
  220. #define bymax 180 + byoffset
  221. #define ylinestretch 10
  222. #define xlinestretch 22
  223. #define BLACKCOLOR 4
  224. #define WHITECOLOR 5
  225. #define titleX bxmax + 63
  226. #define titleY bymin + 5
  227. #define bprisonerX bxmax + 15
  228. #define bprisonerY bymin + 15
  229. #define wprisonerX bprisonerX
  230. #define wprisonerY bprisonerY + 10
  231. #define REPLEN 25        /* Line length of report area */
  232. #define reportX bxmax + 15
  233. #define reportY wprisonerY + 10
  234. #define reasonX reportX
  235. #define reasonY reportY + 10
  236. #define scratchX reasonX
  237. #define scratchY reasonY + 10
  238. #define scratchLines 14
  239.  
  240. #define minStack 21000L
  241.  
  242. void amigainit()
  243. {
  244.    ULONG  stacksize;
  245.    struct Process *Process;
  246.    char   *mem;
  247.    /* Check stack size */
  248.    Process = (struct Process *)FindTask(0L);
  249.    stacksize = *((ULONG *)Process->pr_ReturnAddr);
  250.    if (stacksize < minStack)
  251.    {
  252.     printf("Stack size is %ld\n",stacksize);
  253.     printf("Stack must be at least %ld to run AmiGo\n", minStack);
  254.     exit(1);
  255.    }
  256.    if (!(GfxBase = (struct GfxBase*)OpenLibrary("graphics.library", 1)))
  257.    {
  258.       printf("no graphic library");
  259.       exit(1);
  260.    }
  261.    if (!(IntuitionBase = (struct
  262.          IntuitionBase*)OpenLibrary("intuition.library", 1)))
  263.    {
  264.       CloseLibrary(GfxBase);
  265.       printf( "no intuition here\n" );
  266.       exit(1);
  267.    }
  268.  
  269.    /* Open the screen */
  270.    if ((Screen = (struct Screen *)OpenScreen(&NewScreen)) == NULL)
  271.       exit(FALSE);
  272.  
  273.    nw.LeftEdge = 0;
  274.    nw.TopEdge = 0;
  275.    nw.Width = 640;
  276.    nw.Height = 200;
  277.    nw.DetailPen = 15;
  278.    nw.BlockPen = 5;
  279.    nw.Flags = SMART_REFRESH | ACTIVATE | BORDERLESS;
  280.    nw.IDCMPFlags = MOUSEBUTTONS | MENUPICK;
  281.    nw.FirstGadget = NULL;  /* Add this below */
  282.    nw.CheckMark = NULL;
  283.    nw.Title = NULL;
  284.    nw.Screen = Screen;
  285.    nw.BitMap = NULL;
  286.    nw.Type = CUSTOMSCREEN;
  287.  
  288.    /* Open the window */
  289.    if ((window = (struct Window*)OpenWindow(&nw)) == NULL)
  290.       exit (FALSE);
  291.  
  292.    vp = (struct ViewPort*)ViewPortAddress(window);
  293.    rp = window->RPort;
  294.    LoadRGB4( vp, &ColorTable, 16 );
  295.    PrintBoard();
  296.    Move( rp, titleX, titleY );
  297.    Text( rp, "AmiGo 1.0", 9 );
  298.    SetMenuStrip( window, &game );
  299.  
  300. }
  301.  
  302. void PrintBoard()
  303. {
  304.    short x, y, i = 0;
  305.    char *horizontal = "19181716151413121110 9 8 7 6 5 4 3 2 1";
  306.    char *vertical = "ABCDEFGHJKLMNOPQRST";
  307.  
  308.    SetAPen( rp, boardcolor );
  309.    RectFill( rp, bxmin - xedge, bymin - yedge, bxmax + xedge, bymax + yedge );
  310.    SetAPen( rp, linecolor );
  311.    for (y = bymin; y <= bymax; y = y + ylinestretch )
  312.    {
  313.       Move( rp, bxmin, y );
  314.       Draw( rp, bxmax, y );
  315.       /* Print the algebraic label */
  316.       Move( rp, bxmin - xedge - 18, y + 3);
  317.       Text( rp, horizontal + i, 2 );
  318.       i += 2;
  319.    }
  320.    i = 0;
  321.    for (x = bxmin; x <= bxmax; x = x + xlinestretch )
  322.    {
  323.       Move( rp, x, bymin );
  324.       Draw( rp, x, bymax );
  325.       Move( rp, x - 3, bymax + 13 );
  326.       Text( rp, vertical + i, 1 );
  327.       i++;
  328.    }
  329.    /* Draw the star points */
  330.    for (y = 0; y <= 2; y++)
  331.       for (x = 0; x <= 2; x++)
  332.          DrawImage( rp, &starPointImage,
  333.          starPoint[x] * xlinestretch + bxoffset,
  334.         starPoint[y] * ylinestretch + byoffset);
  335. }
  336.  
  337. void amigaexit()
  338. {
  339. #ifdef DEBUG
  340.    printf( "Freeing image data\n" );
  341. #endif
  342. /*   FreeMem( BlackStoneImage.ImageData, sizeof(USHORT) * 14l );
  343.    FreeMem( WhiteStoneImage.ImageData, sizeof(USHORT) * 21l );
  344.    FreeMem( IntersectImage.ImageData, sizeof(USHORT) * 7l );
  345. */
  346.    CloseWindow(window);
  347.    CloseScreen(Screen);
  348. #ifdef DEBUG
  349.    printf( "Closing intuition\n" );
  350. #endif
  351. /*   CloseLibrary((struct IntuitionBase *)IntuitionBase); */
  352. #ifdef DEBUG
  353.    printf( "Closing Gfx\n");
  354. #endif
  355.    CloseLibrary(GfxBase);
  356. }
  357.  
  358. /* Get input from the user */
  359. /* msg = type of input */
  360. /* xstone ystone is location where user wants to put a stone */
  361. /* if continue is true, the routine will return if no message is present */
  362. void getinput(msg, xstone, ystone, cont)
  363. short *msg, *xstone, *ystone, cont;
  364. {
  365. struct IntuiMessage *imsg;
  366. struct MenuItem *item;
  367. int class, code;
  368. short xlast, ylast, oldx, oldy, newx, newy, mousex, mousey;
  369.  
  370. *msg = NULL;
  371.  
  372. while( TRUE )
  373. {
  374. if (((imsg = (struct IntuiMessage*)GetMsg(window->UserPort)) == NULL) && cont)
  375.     return;
  376.  
  377. if (imsg == NULL)
  378.     while ((imsg = (struct IntuiMessage*)GetMsg(window->UserPort)) == NULL)
  379.        Wait(1<<window->UserPort->mp_SigBit);
  380. class = imsg->Class;
  381. code = imsg->Code;
  382. mousex = imsg->MouseX - bxoffset;
  383. mousey = imsg->MouseY - byoffset;
  384. ReplyMsg( imsg );
  385. switch( class )
  386. {
  387.    case MOUSEBUTTONS:
  388.       if (code == SELECTDOWN)
  389.       {
  390.          /* Save mouse position for possible move */
  391.      xlast = mousex;
  392.      ylast = mousey;
  393.       }
  394.       if (code == SELECTUP)
  395.       {
  396.          if (! Intersection( xlast, ylast, &oldx, &oldy )) continue;
  397.          if (! Intersection( mousex, mousey, &newx, &newy ))
  398.         continue;
  399.      /* two valid intersections were selected */
  400.      /* are they the same? */
  401.      if ((oldx == newx) && (oldy == newy))
  402.      {
  403.         /* They are the same */
  404.         *msg = INTERSECTIONMSG;
  405.         *xstone = newx;
  406.         *ystone = newy;
  407.         return;
  408.      }
  409.       }
  410.       break;
  411.    case CLOSEWINDOW:
  412.       *msg = QUITMSG;
  413.       return;
  414.    case MENUPICK: /* Process Menu selections */
  415.       while (code != MENUNULL)
  416.       {
  417.          item = ItemAddress( &game, code );
  418.          processMenuItem( code, msg );
  419.          code = item->NextSelect;
  420.       }
  421.       if (*msg) return;
  422.       break;
  423. } /* switch */
  424. } /* while */
  425. } /* getinput */
  426.  
  427. void processMenuItem( num, msg )
  428. int num;
  429. short *msg;
  430. {
  431.    switch (MENUNUM(num))
  432.    {
  433.       case GAME:
  434.       switch (ITEMNUM(num))
  435.       {
  436.          case PLAY:
  437.      {
  438.         OffMenu( window, GAME | SHIFTITEM(PLAY) );
  439.         OffMenu( window, OPTION | SHIFTITEM(BLACKTOPLAY) );
  440.         OffMenu( window, OPTION | SHIFTITEM(WHITETOPLAY) );
  441.         OnMenu( window, GAME | SHIFTITEM(RESTART) );
  442.         OnMenu( window, MOVE | SHIFTITEM(PASS) );
  443.         *msg = PLAYMSG;
  444.         return;
  445.      }
  446.      case RESTART:
  447.      {
  448.         OffMenu( window, GAME | SHIFTITEM(RESTART) );
  449.         OffMenu( window, MOVE | SHIFTITEM(PASS) );
  450.         OnMenu( window, GAME | SHIFTITEM(PLAY) );
  451.         OnMenu( window, OPTION | SHIFTITEM(BLACKTOPLAY) );
  452.         OnMenu( window, OPTION | SHIFTITEM(WHITETOPLAY) );
  453.         *msg = RESTARTMSG;
  454.         return;
  455.      }
  456.      case QUIT:
  457.      {
  458.         *msg = QUITMSG;
  459.         return;
  460.      }
  461.       }
  462.       case OPTION:
  463.       switch(ITEMNUM(num))
  464.       {
  465.          case SETPLAYLEVEL:
  466.      {
  467.         playLevel = SUBNUM(num) + 1;
  468.         return;
  469.      }
  470.      case HUMANVSHUMAN:
  471.      {
  472.         computerBlack = FALSE;
  473.         computerWhite = FALSE;
  474.         OffMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSBLACK) );
  475.         OffMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSWHITE) );
  476.         OffMenu( window, OPTION | SHIFTITEM(SETPLAYLEVEL) |
  477.                       SHIFTSUB(NOSUB) );
  478.         return;
  479.      }
  480.          case AMIGAVSAMIGA:
  481.      {
  482.         computerBlack = TRUE;
  483.         computerWhite = TRUE;
  484.         OffMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSBLACK) );
  485.         OffMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSWHITE) );
  486.         OnMenu( window, OPTION | SHIFTITEM(SETPLAYLEVEL) |
  487.                      SHIFTSUB(NOSUB) );
  488.         return;
  489.      }
  490.      case AMIGAVSHUMAN:
  491.      {
  492.             computerBlack = TRUE;
  493.         computerWhite = FALSE;
  494.         OnMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSBLACK) );
  495.         OnMenu( window, OPTION | SHIFTITEM(AMIGAPLAYSWHITE) );
  496.         OnMenu( window, OPTION | SHIFTITEM(SETPLAYLEVEL) |
  497.                      SHIFTSUB(NOSUB) );
  498.         return;
  499.      }
  500.      case AMIGAPLAYSBLACK:
  501.      {
  502.         computerBlack = TRUE;
  503.         computerWhite = FALSE;
  504.         return;
  505.      }
  506.      case AMIGAPLAYSWHITE:
  507.      {
  508.         computerBlack = FALSE;
  509.         computerWhite = TRUE;
  510.         return;
  511.      }
  512.          case BLACKTOPLAY:
  513.      {
  514.         color = BLACK;
  515.         return;
  516.      }
  517.      case WHITETOPLAY:
  518.      {
  519.         color = WHITE;
  520.         return;
  521.      }
  522.       }
  523.       case MOVE:
  524.       switch (ITEMNUM(num))
  525.       {
  526.          case PASS:
  527.      {
  528.         *msg = PASSMSG;
  529.         return;
  530.      }
  531.       }
  532.       case INFO:
  533.       switch (ITEMNUM(num))
  534.       {
  535.          case SHOWLOOKAHEAD:
  536.      {
  537.         showTrees = ! showTrees;
  538.         return;
  539.      }
  540.      case MOVEREASON:
  541.      {
  542.         showMoveReason = ! showMoveReason;
  543.         return;
  544.      }
  545.      case GROUPINFO:
  546.      {
  547.         groupInfo = ! groupInfo;
  548.         return;
  549.      }
  550.       }
  551.    }
  552. }
  553.       
  554. short Intersection( mx, my, ix, iy )
  555. short mx, my, *ix, *iy;
  556. {
  557.  short rem;
  558.  if ((bxmin - 2 <= mx + bxoffset) && (bxmax + 2 >= mx + bxoffset) &&
  559.      (bymin - 2 <= my + byoffset) && (bymax + 2 >= my + byoffset))
  560.  {
  561.     /* Calculate closest intersection */
  562.     *ix = mx / xlinestretch;
  563.     rem = mx % xlinestretch;
  564.     if ((rem == (xlinestretch - 1)) || (rem == xlinestretch - 2))
  565.        *ix = *ix + 1;
  566.     else if ((rem != xlinestretch) && (! (rem <= 3)))
  567.             return FALSE;    /* Too far from intersection */
  568.     /* ix is correct */        
  569.     *iy = my / ylinestretch;
  570.     rem = my % ylinestretch;
  571.     if ((rem == (ylinestretch - 1)) || (rem == ylinestretch - 2))
  572.        *iy = *iy + 1;
  573.     else if ((rem != ylinestretch) && (! (rem <= 3))) return FALSE;    /* Too far from intersection */
  574.     /* iy is correct */
  575.     return TRUE;
  576.  }
  577. return FALSE;
  578. }
  579.  
  580. /* Print a stone of color at x, y intersection */
  581. void placestone(color, x, y)
  582. enum bVal color;
  583. short x, y;
  584. {
  585.    if (color == BLACK)
  586.       DrawImage( rp, &BlackStoneImage, x * xlinestretch + bxoffset,
  587.                   y * ylinestretch + byoffset );
  588.    else
  589.       DrawImage( rp, &WhiteStoneImage, x * xlinestretch + bxoffset,
  590.                   y * ylinestretch + byoffset );
  591. }
  592.  
  593. /* Remove a stone from an intersection */
  594. void removestone( x, y )
  595. short x, y;
  596. {
  597.    short sx, sy, starX = FALSE, starY = FALSE;
  598.    unsigned short i;
  599.    sx = x * xlinestretch + bxoffset;
  600.    sy = y * ylinestretch + byoffset;
  601.    /* Is it a star point? */
  602.    for (i = 0; i <= 2; i++)
  603.    {
  604.       if (x == starPoint[i]) starX = TRUE;
  605.       if (y == starPoint[i]) starY = TRUE;
  606.    }
  607.    if (starX && starY)
  608.       DrawImage( rp, &starPointImage, sx, sy );
  609.    else
  610.       /* Determine type of regular intersection */
  611.       if (x == 0)
  612.      if (y == 0)
  613.         DrawImage( rp, &ULIntersectImage, sx, sy );
  614.      else if (y == 18)
  615.         DrawImage( rp, &LLIntersectImage, sx, sy );
  616.      else
  617.         DrawImage( rp, &LCIntersectImage, sx, sy );
  618.       else if (y == 0)
  619.          if (x == 18)
  620.         DrawImage( rp, &URIntersectImage, sx, sy );
  621.      else
  622.         DrawImage( rp, &UMIntersectImage, sx, sy );
  623.       else if (y == 18)
  624.          if (x == 18)
  625.         DrawImage( rp, &LRIntersectImage, sx, sy );
  626.      else
  627.         DrawImage( rp, &LMIntersectImage, sx, sy );
  628.       else if (x == 18)
  629.             DrawImage( rp, &RMIntersectImage, sx, sy );
  630.       else
  631.          DrawImage( rp, &IntersectImage, sx, sy );
  632. }
  633.  
  634. /* Report on a move */
  635. void intrMoveReport( color, coord, reason )
  636. enum bVal color;
  637. char *coord, *reason;
  638. {
  639.   char *spaces = "                         ";
  640.   int len;
  641.   Move( rp, reportX, reportY );
  642.   Text( rp, spaces, REPLEN );
  643.   Move( rp, reportX, reportY );
  644.   if (color == BLACK)
  645.      Text( rp, "Black at ", 9 );
  646.   else
  647.      Text( rp, "White at ", 9 );
  648.   Text( rp, coord, 3 );
  649.   if (! showMoveReason) return;
  650.   len = strlen( reason );
  651.   Move( rp, reasonX, reasonY );
  652.   Text( rp, spaces, REPLEN );
  653.   Move( rp, reasonX, reasonY );
  654.   Text( rp, reason, len );
  655. }
  656.  
  657. void intrPass( color )
  658. enum bVal color;
  659. {
  660.   Move( rp, reportX, reportY );
  661.   if (color == BLACK)
  662.      Text( rp, "Black Passes             ", REPLEN );
  663.   else
  664.      Text( rp, "White Passes             ", REPLEN );
  665. }
  666.    
  667. void intrPrisonerReport( blackcnt, whitecnt )
  668. short blackcnt, whitecnt;
  669. {
  670.    char *num = "    ",
  671.        *spaces = "                    ";
  672.    int len;
  673.    Move( rp, bprisonerX, bprisonerY );
  674.    Text( rp, spaces, 20 );
  675.    Move( rp, bprisonerX, bprisonerY );
  676.    Text( rp, "Black: ", 7 );
  677.    len = stci_d( num, (int)blackcnt );
  678.    Text( rp, num, len );
  679.    Move( rp, wprisonerX, wprisonerY );
  680.    Text( rp, spaces, 20 );
  681.    Move( rp, wprisonerX, wprisonerY );
  682.    Text( rp, "White: ", 7 );
  683.    len = stci_d( num, (int)whitecnt );
  684.    Text( rp, num, len );
  685. }
  686.  
  687. void intrInitScratchArea()
  688. {
  689.    short i;
  690.    char *spaces = "                         ";
  691.    sx = scratchX;
  692.    sy = scratchY;
  693.    for (i = 0; i < scratchLines; i++)
  694.    {
  695.       Move( rp, sx, sy );
  696.       Text( rp, spaces, REPLEN );
  697.       sy += 10;
  698.    }
  699.    sx = scratchX;
  700.    sy = scratchY;
  701.    Move( rp, sx, sy );
  702. }
  703.  
  704. void intrPuts( s )
  705. char *s;
  706. {
  707.    int len;
  708.    len = strlen( s );
  709.    if (len > REPLEN) len = REPLEN;
  710.    Text( rp, s, len );
  711. }
  712.  
  713. void intrPutLn()
  714. {
  715.    sx = scratchX;
  716.    sy += 10;
  717.    Move( rp, sx, sy );
  718. }
  719.  
  720. void intrPutshort( n )
  721. short n;
  722. {
  723.    int len;
  724.    char *num = "    ";
  725.    len = stci_d( num, (short)n );
  726.    Text( rp, num, len );
  727. }
  728.  
  729.  
  730. void intrCredits()
  731. {
  732.    intrPuts( "Player by Stoney Ballard" ); intrPutLn();
  733.    intrPuts( "C port and interface"); intrPutLn();
  734.    intrPuts( "by Todd R. Johnson"); intrPutLn();
  735.    intrPutLn();
  736.    intrPuts( "To place handicap or" ); intrPutLn();
  737.    intrPuts( "set up a position use" ); intrPutLn();
  738.    intrPuts( "the mouse to cycle the" ); intrPutLn();
  739.    intrPuts( "contents of a location" ); intrPutLn();
  740.    intrPuts( "from empty to black to" ); intrPutLn();
  741.    intrPuts( "white to empty." ); intrPutLn();
  742.    intrPutLn();
  743.    intrPuts( "Use menus to set options." ); intrPutLn();
  744.    intrPuts( "Select the Play menu" ); intrPutLn();
  745.    intrPuts( "item to begin play." );
  746. }