home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_oth / monopoly.lzh / monopoly_source.LZH / f0.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-06  |  31.1 KB  |  981 lines

  1. /* f0.c  contains function calls for monopoly  */
  2.  
  3.    /* Leave this structure definition at the top. Look at gels.h. */
  4. struct vInfo {
  5.    short vx,vy;      /* This VSprites velocity. */
  6.    short id;
  7. };
  8.  
  9. #define VUserStuff struct vInfo
  10.  
  11. #include "mono:defines"
  12. #include "mono:xvariables"
  13.  
  14. typedef struct {
  15.    ClientFrame clientFrame;
  16.    UBYTE foundBMHD;
  17.    UBYTE nColorRegs;
  18.    BitMapHeader bmHdr;
  19.    Color4 colorMap[maxColorReg];
  20.    /* If you want to read any other property chunks, e.g. GRAB or CAMG,
  21.     * add fields to this record to store them. */
  22.    } ILBMFrame;
  23.  
  24. ILBMFrame iFrame, ilbmFrame;
  25.  
  26. VOID freeimages()
  27. {
  28. extern USHORT *Red_chip, *Green_chip, *Blue_chip, *Yellow_chip;
  29.  
  30.    if (Red_chip != 0)
  31.       FreeMem(Red_chip, sizeof(Reddata));
  32.    if (Green_chip != 0)
  33.       FreeMem(Green_chip, sizeof(Greendata));
  34.    if (Blue_chip != 0)
  35.       FreeMem(Blue_chip, sizeof(Bluedata));
  36.    if (Yellow_chip != 0)
  37.       FreeMem(Yellow_chip, sizeof(Yellowdata));
  38. }
  39.  
  40. VOID mycleanup()
  41. {
  42.    if (Redbob != NULL)
  43.       {
  44.        if (Redbob->SaveBuffer != NULL)
  45.           {
  46.           FreeMem(Redbob->SaveBuffer, (sizeof(SHORT)*
  47.                Redbob->BobVSprite->Width*Redbob->BobVSprite->Height*
  48.                Redbob->BobVSprite->Depth));
  49.           }
  50.       if (Redbob->BobVSprite->CollMask != NULL)
  51.          {
  52.      FreeMem(Redbob->BobVSprite->CollMask, (sizeof(WORD)*
  53.             Redbob->BobVSprite->Height*Redbob->BobVSprite->Width));
  54.      }
  55.       if (Redbob->BobVSprite->BorderLine != NULL) 
  56.          {
  57.          FreeMem(Redbob->BobVSprite->BorderLine, 
  58.                  (sizeof(WORD)*Redbob->BobVSprite->Width));
  59.          }
  60.       FreeMem(Redbob->BobVSprite, sizeof(struct VSprite));
  61.       FreeMem(Redbob, sizeof(struct Bob));
  62.       }              
  63.    if (Greenbob != NULL)
  64.       {
  65.        if (Greenbob->SaveBuffer != NULL)
  66.           {
  67.           FreeMem(Greenbob->SaveBuffer, (sizeof(SHORT)*
  68.                Greenbob->BobVSprite->Width*Greenbob->BobVSprite->Height*
  69.                Greenbob->BobVSprite->Depth));
  70.           }
  71.       if (Greenbob->BobVSprite->CollMask != NULL)
  72.          {
  73.      FreeMem(Greenbob->BobVSprite->CollMask, (sizeof(WORD)*
  74.             Greenbob->BobVSprite->Height*Greenbob->BobVSprite->Width));
  75.      }
  76.       if (Greenbob->BobVSprite->BorderLine != NULL) 
  77.          {
  78.          FreeMem(Greenbob->BobVSprite->BorderLine, 
  79.                  (sizeof(WORD)*Greenbob->BobVSprite->Width));
  80.          }
  81.       FreeMem(Greenbob->BobVSprite, sizeof(struct VSprite));
  82.       FreeMem(Greenbob, sizeof(struct Bob));
  83.       }     
  84.    if (Bluebob != NULL)
  85.       {
  86.        if (Bluebob->SaveBuffer != NULL)
  87.           {
  88.           FreeMem(Bluebob->SaveBuffer, (sizeof(SHORT)*
  89.                Bluebob->BobVSprite->Width*Bluebob->BobVSprite->Height*
  90.                Bluebob->BobVSprite->Depth));
  91.           }
  92.       if (Bluebob->BobVSprite->CollMask != NULL)
  93.          {
  94.      FreeMem(Bluebob->BobVSprite->CollMask, (sizeof(WORD)*
  95.             Bluebob->BobVSprite->Height*Bluebob->BobVSprite->Width));
  96.      }
  97.       if (Bluebob->BobVSprite->BorderLine != NULL) 
  98.          {
  99.          FreeMem(Bluebob->BobVSprite->BorderLine, 
  100.                  (sizeof(WORD)*Bluebob->BobVSprite->Width));
  101.          }
  102.       FreeMem(Bluebob->BobVSprite, sizeof(struct VSprite));
  103.       FreeMem(Bluebob, sizeof(struct Bob));
  104.       }         
  105.    if (Yellowbob != NULL)
  106.       {
  107.        if (Yellowbob->SaveBuffer != NULL)
  108.           {
  109.           FreeMem(Yellowbob->SaveBuffer, (sizeof(SHORT)*
  110.                Yellowbob->BobVSprite->Width*Yellowbob->BobVSprite->Height*
  111.                Yellowbob->BobVSprite->Depth));
  112.           }
  113.       if (Yellowbob->BobVSprite->CollMask != NULL)
  114.          {
  115.      FreeMem(Yellowbob->BobVSprite->CollMask, (sizeof(WORD)*
  116.             Yellowbob->BobVSprite->Height*Yellowbob->BobVSprite->Width));
  117.      }
  118.       if (Yellowbob->BobVSprite->BorderLine != NULL) 
  119.          {
  120.          FreeMem(Yellowbob->BobVSprite->BorderLine, 
  121.                  (sizeof(WORD)*Yellowbob->BobVSprite->Width));
  122.          }
  123.       FreeMem(Yellowbob->BobVSprite, sizeof(struct VSprite));
  124.       FreeMem(Yellowbob, sizeof(struct Bob));
  125.       }     
  126.   
  127.    (VOID) PurgeGels(&GInfo);
  128.    freeimages();
  129. }     /*   end of MyCleanup   */
  130.  
  131. VOID cleanup()
  132. {
  133.    /* tBitMap planes were deallocated in DisplayPic() */
  134. mycleanup();
  135. ClearMenuStrip(boardwindow);
  136. if (boardwindow) CloseWindow(boardwindow);
  137. if (screen1) CloseScreen(screen1);
  138. if (IntuitionBase) CloseLibrary(IntuitionBase);
  139. if (GfxBase) CloseLibrary(GfxBase);
  140. exit(0);
  141. }
  142.  
  143.  
  144.  
  145.  
  146.  
  147. VOID getID(mes)
  148. struct IntuiMessage *mes;
  149. {
  150. struct Gadget *igad;
  151.  
  152. igad = (struct Gadget *) mes->IAddress;
  153. gagid = igad->GadgetID;
  154. }
  155.  
  156.    /*  the following will prepare a message for display as IntuiText  */
  157. VOID CMes(xcm, left, top, mesg, fpen, bpen)
  158.    struct IntuiText *xcm;
  159.    SHORT left, top, fpen, bpen;
  160.    UBYTE *mesg;
  161. {
  162.    xcm->FrontPen=fpen;
  163.    xcm->BackPen=bpen;
  164.    xcm->DrawMode=JAM1;
  165.    xcm->LeftEdge=left;
  166.    xcm->TopEdge=top;
  167.    xcm->ITextFont=&TextFont;
  168.    xcm->IText=mesg;
  169.    xcm->NextText=NULL;
  170. }
  171.  
  172. BOOL really(command)          /* make requester to verify command  */
  173. int command;
  174. {
  175. struct IntuiText prompt, yesprompt, noprompt, win, win_name;
  176. USHORT test_ahead;
  177.  
  178. if (command == QUIT)
  179.    {
  180.    CMes(&prompt, 5, 5, "QUIT PLAYING MONOPOLY?", black, 1);
  181.    CMes(&win, 5, 19, NULL, maroon, 1);
  182.    CMes(&win_name, 5, 29, NULL, black, 1);
  183.    prompt.NextText=&win;
  184.    test_ahead=ahead();
  185.    if (test_ahead == 5)
  186.       win.IText=(UBYTE *)"NO WINNER  A TIE EXISTS!";
  187.    if (test_ahead != 5)
  188.       {
  189.       win.NextText=&win_name;
  190.       win.IText=(UBYTE *)"THE WINNER IS:";
  191.       if (test_ahead == 0)
  192.          {
  193.      win_name.IText=&name0[0];
  194.      win_name.FrontPen=25;
  195.      }
  196.       if (test_ahead == 1)
  197.          {
  198.      win_name.IText=&name1[0];
  199.      win_name.FrontPen=26;
  200.      }
  201.       if (test_ahead == 2)
  202.          {
  203.          win_name.IText=&name2[0];
  204.      win_name.FrontPen=27;
  205.      }
  206.       if (test_ahead == 3)
  207.          {
  208.          win_name.IText=&name3[0];
  209.      win_name.FrontPen=28;
  210.      }
  211.       }
  212.    CMes(&yesprompt, 6, 4, "YES", green, 1);
  213.    CMes(&noprompt, 6, 4, "NO", red, 1);
  214.    if (AutoRequest(boardwindow, &prompt, &yesprompt, &noprompt, NULL, NULL,
  215.                       225, 75)) return(TRUE);
  216.    else return(FALSE);
  217.    }
  218. return(FALSE); 
  219. }
  220.  
  221. VOID cleanexit(errstr)
  222. char  *errstr;
  223. {
  224. printf("\n %s \n",errstr);
  225. cleanup();
  226. }
  227.  
  228. VOID DrawGels()
  229. {
  230. SortGList(&screen1->RastPort);        /* Put the list in order. */
  231. WaitTOF();
  232. DrawGList(&screen1->RastPort, &screen1->ViewPort);      /* Draw 'em. */
  233. WaitTOF();                           /* When the beam hits the top... */
  234. MakeScreen(screen1);                  /* Tell intuition to do it's stuff. */
  235. RethinkDisplay();                    /* Does a MrgCop & LoadView. */
  236. }
  237.  
  238.  
  239. BOOL initimages()
  240. {
  241. extern USHORT *Red_chip, *Green_chip, *Blue_chip, *Yellow_chip;
  242. USHORT iter;
  243.  
  244.    if ((Red_chip = (USHORT *)
  245.        AllocMem(sizeof(Reddata), MEMF_CHIP)) == 0)   return(FALSE);
  246.    if ((Green_chip = (USHORT *)
  247.        AllocMem(sizeof(Greendata), MEMF_CHIP)) == 0)   return(FALSE);
  248.    if ((Blue_chip = (USHORT *)
  249.        AllocMem(sizeof(Bluedata), MEMF_CHIP)) == 0)   return(FALSE);
  250.    if ((Yellow_chip = (USHORT *)
  251.        AllocMem(sizeof(Yellowdata), MEMF_CHIP)) == 0)   return(FALSE);
  252.  
  253.    for(iter=0; iter<35; iter++)
  254.       Red_chip[iter] = Reddata[iter];
  255.    for(iter=0; iter<35; iter++)
  256.       Green_chip[iter] = Greendata[iter];
  257.    for(iter=0; iter<35; iter++)
  258.       Blue_chip[iter] = Bluedata[iter];
  259.    for(iter=0; iter<35; iter++)
  260.       Yellow_chip[iter] = Yellowdata[iter];
  261.  
  262. return(TRUE);
  263. }
  264.  
  265. VOID bob()
  266. {
  267.             /* ReadyGels is in GelTools(). */
  268.    if (ReadyGels(&GInfo, &screen1->RastPort) != 0) 
  269.    {
  270.       mycleanup();
  271.       Exit(-1);
  272.    }
  273.  
  274.  
  275.          /* Copy Images to chip memory. */
  276.    if (!initimages()) 
  277.    {
  278.       mycleanup();
  279.       Exit(-1);
  280.    }
  281.  
  282.  
  283.  
  284. startRX=50;
  285. startRY=40;
  286. startGX=100;
  287. startGY=40;
  288. startBX=150;
  289. startBY=40;
  290. startYX=200;
  291. startYY=40;
  292.  
  293.  
  294.       /* First use the routines in geltools to get the bob. */
  295.  
  296. if ((Redbob = (struct Bob *)MakeBob(BOBWIDTH, BOBHEIGHT, BOBDEPTH,
  297.                       Red_chip, 0x001F, 0x00, startRX,
  298.                       startRY, SAVEBACK | OVERLAY)) == 0)
  299.    {
  300.    mycleanup();
  301.    Exit(-1);
  302.    }
  303. Redbob->BobVSprite->VUserExt.id = 0;
  304. AddBob(Redbob, &screen1->RastPort);
  305.    
  306. if ((Greenbob = (struct Bob *)MakeBob(BOBWIDTH, BOBHEIGHT, BOBDEPTH,
  307.                       Green_chip, 0x001F, 0x00, startGX,
  308.                       startGY, SAVEBACK | OVERLAY)) == 0)
  309.    {
  310.    mycleanup();
  311.    Exit(-1);
  312.    }
  313. Greenbob->BobVSprite->VUserExt.id = 1;
  314. AddBob(Greenbob, &screen1->RastPort);
  315.     
  316. if ((ntp == 3) || (ntp == 4))
  317.    {      
  318.    if ((Bluebob = (struct Bob *)MakeBob(BOBWIDTH, BOBHEIGHT, BOBDEPTH,
  319.                       Blue_chip, 0x001F, 0x00, startBX,
  320.                       startBY, SAVEBACK | OVERLAY)) == 0)
  321.       {
  322.        mycleanup();
  323.        Exit(-1);
  324.        }
  325.    Bluebob->BobVSprite->VUserExt.id = 2;
  326.    AddBob(Bluebob, &screen1->RastPort);
  327.    } 
  328. if (ntp == 4)
  329.    {          
  330.    if ((Yellowbob = (struct Bob *)MakeBob(BOBWIDTH, BOBHEIGHT, BOBDEPTH,
  331.                       Yellow_chip, 0x001F, 0x00, startYX,
  332.                       startYY, SAVEBACK | OVERLAY)) == 0)
  333.       {
  334.       mycleanup();
  335.       Exit(-1);
  336.       }
  337.    Yellowbob->BobVSprite->VUserExt.id = 3;
  338.    AddBob(Yellowbob, &screen1->RastPort);   
  339.    }     
  340. }       /*   end of bob()   */
  341.  
  342.  
  343. VOID do_gag()
  344. {
  345. nhp=nhpinfo.LongInt;
  346. ncp=ncpinfo.LongInt;
  347. switch (gagid)
  348.    {
  349.    case GID0:  
  350.    case GID1: break;
  351.    case GID2:
  352.       {
  353.       if (((nhp+ncp)<2 || (nhp+ncp)>4) || (nhp == 0))
  354.          {
  355.          DisplayBeep(screen1);
  356.          break;
  357.          }
  358.        endnum=TRUE; 
  359.        break;
  360.        }
  361.    case GN0:
  362.    case GN1:
  363.    case GN2:
  364.    case GN3:  break;
  365.    case GN4:
  366.       {
  367.       endname=TRUE;
  368.       break;
  369.       }
  370.    case VN: 
  371.       {
  372.       verifyname=TRUE;
  373.       break;
  374.       }
  375.    case DN:  
  376.       {
  377.       verifyname=TRUE;
  378.       nameagain=TRUE;
  379.       break;
  380.       }     
  381.    }
  382. }
  383.  
  384. VOID ckinfomsg()
  385. {
  386. ULONG infoclass;
  387. USHORT infocode;
  388. infoclass=0;
  389. infocode=0;
  390.  
  391. while (infomsg=(struct IntuiMessage *)GetMsg(infowindow->UserPort))
  392.    {
  393.    infoclass = infomsg->Class;
  394.    infocode = infomsg->Code;
  395.    if (infoclass == GADGETDOWN)  getID(infomsg);     
  396.    ReplyMsg(infomsg);
  397.    if ( (infoclass == RAWKEY) && (infocode == HELP) ) instruction();
  398.    if (infoclass == GADGETDOWN)   do_gag();
  399.    }
  400. }
  401.  
  402.  
  403. VOID CreateMenuItem(name, item, next, sub, left, top, wide, flags)
  404.    UBYTE *name;
  405.    USHORT left, top, wide;
  406.    ULONG flags;
  407.    struct MenuItem *item, *next, *sub;
  408. {
  409.    item->NextItem=next;
  410.    item->LeftEdge=left;
  411.    item->TopEdge=top;
  412.    item->Width=wide;
  413.    item->Height=10;
  414.    item->Flags=ITEMTEXT | HIGHBOX | ITEMENABLED | flags;
  415.    item->MutualExclude=NULL;
  416.    item->ItemFill=(APTR)name;
  417.    item->SelectFill=NULL;
  418.    item->Command=NULL;
  419.    item->SubItem=sub;
  420. }
  421.  
  422.  
  423.  
  424. /** getBitMap() ***********************************************
  425.  *
  426.  * Open screen or temp bitmap.
  427.  *   Returns ptr destBitMap  or  0 = error
  428.  *
  429.  **************************************************************/
  430. struct BitMap *getBitMap(ptilbmFrame)
  431. ILBMFrame *ptilbmFrame;
  432. {
  433. int     i, nPlanes, plsize;
  434. SHORT  sWidth, sHeight, dWidth, dHeight;
  435. struct BitMap *destBitMap;
  436.  
  437. sWidth  = ptilbmFrame->bmHdr.w;
  438. sHeight = ptilbmFrame->bmHdr.h;
  439. dWidth  = ptilbmFrame->bmHdr.pageWidth;
  440. dHeight = ptilbmFrame->bmHdr.pageHeight;
  441. nPlanes   = MIN(ptilbmFrame->bmHdr.nPlanes, EXDepth);
  442.  
  443. for (i = 0; i < ptilbmFrame->nColorRegs; i++)
  444.    {
  445.    allBgColor[i] = ptilbmFrame->colorMap[0];
  446.    }
  447.  
  448. ns.Width  = dWidth;
  449. ns.Height = dHeight;
  450. ns.Depth  = nPlanes;
  451.  
  452. if (ptilbmFrame->bmHdr.pageWidth <= 320)
  453.    ns.ViewModes = SPRITES;
  454. else
  455.    ns.ViewModes = HIRES | SPRITES;
  456.  
  457. if (ptilbmFrame->bmHdr.pageHeight > 200)
  458.    ns.ViewModes |= LACE | SPRITES;
  459.  
  460. if ((screen1=(struct Screen *)OpenScreen(&ns))==NULL)  return(0);
  461.  
  462. vport1 = &screen1->ViewPort;
  463. LoadRGB4(vport1, &allBgColor[0], ptilbmFrame->nColorRegs);
  464.  
  465. nw.Width  = dWidth;
  466. nw.Height = dHeight;
  467. nw.Screen = screen1;
  468.  
  469. if ((boardwindow=(struct Window *)OpenWindow(&nw))==NULL)  return(0);
  470. rportboard=boardwindow->RPort;
  471.  
  472. ShowTitle(screen1, FALSE);
  473.  
  474. if ((sWidth == dWidth) && (sHeight == dHeight))
  475.    {
  476.    destBitMap = (struct BitMap *)screen1->RastPort.BitMap;
  477.    }
  478. else
  479.    {
  480.    InitBitMap( &tBitMap,
  481.                nPlanes,
  482.                sWidth,
  483.                sHeight);
  484.  
  485.    plsize = RowBytes(ptilbmFrame->bmHdr.w) * ptilbmFrame->bmHdr.h;
  486.    if (tBitMap.Planes[0] =
  487.          (PLANEPTR)AllocMem(nPlanes * plsize, MEMF_CHIP))
  488.       {
  489.       for (i = 1; i < nPlanes; i++)
  490.            tBitMap.Planes[i] = (PLANEPTR)tBitMap.Planes[0] + plsize*i;
  491.       destBitMap = &tBitMap;
  492.       }
  493.    else
  494.       {
  495.       return(0);  /* can't allocate temp BitMap */
  496.       }
  497.    }
  498. return(destBitMap);          /* destBitMap allocated */
  499. }
  500.  
  501.  
  502. /** DisplayPic() **********************************************
  503.  *
  504.  * Display loaded bitmap.  If tBitMap, first transfer to screen.
  505.  *
  506.  **************************************************************/
  507. DisplayPic(ptilbmFrame)
  508. ILBMFrame *ptilbmFrame;
  509. {
  510. int    i, row, byte, nrows, nbytes;
  511. struct BitMap  *tbp, *sbp; /* temp and screen BitMap ptrs */
  512. UBYTE  *tpp, *spp;         /* temp and screen plane ptrs  */
  513.  
  514. if (tBitMap.Planes[0])     /* transfer from tBitMap if nec. */
  515.    {
  516.    tbp = &tBitMap;
  517.    sbp = screen1->RastPort.BitMap;
  518.    nrows  = MIN(tbp->Rows, sbp->Rows);
  519.    nbytes = MIN(tbp->BytesPerRow, sbp->BytesPerRow);
  520.  
  521.    for (i = 0; i < sbp->Depth; i++)
  522.       {
  523.       tpp = (UBYTE *)tbp->Planes[i];
  524.       spp = (UBYTE *)sbp->Planes[i];
  525.       for (row = 0; row < nrows; row++)
  526.          {
  527.          tpp = tbp->Planes[i] + (row * tbp->BytesPerRow);
  528.          spp = sbp->Planes[i] + (row * sbp->BytesPerRow);
  529.          for (byte = 0; byte < nbytes; byte++)
  530.             {
  531.             *spp++ = *tpp++;
  532.             }
  533.          }
  534.       }
  535.     /*  Can now deallocate the temp BitMap  */
  536.    FreeMem(tBitMap.Planes[0],
  537.               tBitMap.BytesPerRow * tBitMap.Rows * tBitMap.Depth);
  538.    }
  539.  
  540. vport1 = &screen1->ViewPort;
  541. LoadRGB4(vport1, ptilbmFrame->colorMap, ptilbmFrame->nColorRegs);
  542.  
  543. return(0);
  544. }
  545.  
  546.  
  547. /** GetLiILBM() *************************************************
  548.  *
  549.  * Called via ReadPicture to handle every LIST encountered in an
  550.  * IFF file.
  551.  *
  552.  ****************************************************************/
  553. #if Fancy
  554.    IFFP GetLiILBM(parent)
  555.    GroupContext *parent; 
  556.    {
  557.    ILBMFrame newFrame;   /* allocate a new Frame */
  558.  
  559.    newFrame = *(ILBMFrame *)parent->clientFrame;  /* copy parent frame */
  560.  
  561.    return( ReadIList(parent, (ClientFrame *)&newFrame) );
  562.    }
  563. #endif
  564.  
  565.  
  566. /** GetPrILBM() **************************************************
  567.  *
  568.  * Called via ReadPicture to handle every PROP encountered in an
  569.  * IFF file.   Reads PROPs ILBM and skips all others.
  570.  *
  571.  ****************************************************************/
  572. #if Fancy
  573.    IFFP GetPrILBM(parent)
  574.    GroupContext *parent; 
  575.    {
  576.    /*compilerBug register*/ IFFP iffp;
  577.    GroupContext propContext;
  578.    ILBMFrame *ilbmFrame = (ILBMFrame *)parent->clientFrame;
  579.  
  580.    if (parent->subtype != ID_ILBM)
  581.       return(IFF_OKAY);   /* just continue scaning the file */
  582.  
  583.    iffp = OpenRGroup(parent, &propContext);
  584.    CheckIFFP();
  585.  
  586.    do switch (iffp = GetPChunkHdr(&propContext)) 
  587.       {
  588.       case ID_BMHD: 
  589.          {
  590.          ilbmFrame->foundBMHD = TRUE;
  591.          iffp = GetBMHD(&propContext, &ilbmFrame->bmHdr);
  592.          break; 
  593.      }
  594.       case ID_CMAP: 
  595.          {
  596.          ilbmFrame->nColorRegs = maxColorReg; /* room for this many */
  597.          iffp = GetCMAP( &propContext, (WORD *)ilbmFrame->colorMap,
  598.                           &ilbmFrame->nColorRegs);
  599.          break; 
  600.      }
  601.  
  602.       }   while (iffp >= IFF_OKAY);
  603.                  /* loop if valid ID of ignored chunk or
  604.                   * subrtn returned IFF_OKAY (no errors).*/
  605.  
  606.    CloseRGroup(&propContext);
  607.    return(iffp == END_MARK ? IFF_OKAY : iffp);
  608.    }
  609. #endif
  610.  
  611.  
  612. /** GetFoILBM() *************************************************
  613.  *
  614.  * Called via ReadPicture to handle every FORM encountered in an IFF
  615.  * file.  Reads FORMs ILBM and skips all others.
  616.  * Inside a FORM ILBM, it stops once it reads a BODY. It complains if
  617.  * it finds no BODY or if it has no BMHD to decode the BODY.
  618.  *
  619.  * Once we find a BODY chunk, we'll allocate the BitMap and read the
  620.  * image.
  621.  *
  622.  * Modified by C. Scheppner:  ilbmFrame moved above main making it
  623.  *                            global so main can call DisplayPic()
  624.  *
  625.  *****************************************************************/
  626. IFFP GetFoILBM(parent)
  627. GroupContext *parent;
  628. {
  629. IFFP iffp;
  630. GroupContext formContext;
  631. BYTE buffer[bufSz];
  632. struct BitMap *destBitMap;
  633.  
  634. if (parent->subtype != ID_ILBM)
  635.     return(IFF_OKAY);   /* just continue scaning the file */
  636.  
  637. ilbmFrame = *(ILBMFrame *)parent->clientFrame;
  638. iffp = OpenRGroup(parent, &formContext);
  639. CheckIFFP();
  640.  
  641. do switch (iffp = GetFChunkHdr(&formContext)) 
  642.    {
  643.    case ID_BMHD: 
  644.       {
  645.       ilbmFrame.foundBMHD = TRUE;
  646.       iffp = GetBMHD(&formContext, &ilbmFrame.bmHdr);
  647.       break; 
  648.       }
  649.       case ID_CMAP: 
  650.          {
  651.          ilbmFrame.nColorRegs = maxColorReg;
  652.                               /* we have room for this many */
  653.  
  654.          iffp = GetCMAP(&formContext, (WORD *)ilbmFrame.colorMap,
  655.                            &ilbmFrame.nColorRegs);
  656.          break; 
  657.      }
  658.       case ID_BODY: 
  659.          {
  660.          if (!ilbmFrame.foundBMHD)  return(BAD_FORM);
  661.                                  /* No BMHD chunk! */
  662.  
  663.          if(destBitMap=(struct BitMap *)getBitMap(&ilbmFrame))
  664.             {
  665.             iffp = GetBODY( &formContext,
  666.                             destBitMap,
  667.                             NULL,
  668.                             &ilbmFrame.bmHdr,
  669.                             buffer,
  670.                             bufSz);
  671.             if (iffp == IFF_OKAY) iffp = IFF_DONE;   /* Eureka */
  672.             }
  673.          else
  674.             iffp = CLIENT_ERROR;   /* not enough RAM for the bitmap */
  675.          break; 
  676.      }
  677.  
  678.       case END_MARK: 
  679.          {
  680.          iffp = BAD_FORM;
  681.          break; 
  682.      }
  683.  
  684. }   while (iffp >= IFF_OKAY);
  685.           /* loop if valid ID of ignored chunk or a
  686.            * subroutine returned IFF_OKAY (no errors).*/
  687.  
  688. if (iffp != IFF_DONE)  return(iffp);
  689.  
  690. CloseRGroup(&formContext);
  691. return(iffp);
  692. }
  693.  
  694. /** Notes on extending GetFoILBM *******************************
  695.  *
  696.  * To read more kinds of chunks, just add clauses to the switch statement.
  697.  * To read more kinds of property chunks (GRAB, CAMG, etc.) add clauses to
  698.  * the switch statement in GetPrILBM, too.
  699.  *
  700.  * To read a FORM type that contains a variable number of data chunks--e.g.
  701.  * a FORM FTXT with any number of CHRS chunks--replace the ID_BODY case with
  702.  * an ID_CHRS case that doesn't set iffp = IFF_DONE, and make the END_MARK
  703.  * case do whatever cleanup you need.
  704.  *
  705.  ****************************************************************/
  706.  
  707.  
  708. /** ReadPicture() ************************************************
  709.  *
  710.  * Read a picture from an IFF file, given a file handle open for reading.
  711.  *
  712.  * Modified by Carolyn Scheppner   CBM   03-86
  713.  *   iFrame made global (above main)
  714.  *   Close(file) moved to main
  715.  *
  716.  *****************************************************************/
  717. IFFP ReadPicture(file)
  718. LONG file;
  719. {
  720. IFFP iffp = IFF_OKAY;
  721.  
  722. #if Fancy
  723.    iFrame.clientFrame.getList = GetLiILBM;
  724.    iFrame.clientFrame.getProp = GetPrILBM;
  725. #else
  726.    iFrame.clientFrame.getList = SkipGroup;
  727.    iFrame.clientFrame.getProp = SkipGroup;
  728. #endif
  729.    iFrame.clientFrame.getForm = GetFoILBM;
  730.    iFrame.clientFrame.getCat  = ReadICat ;
  731.  
  732.    /* Initialize the top-level client frame's property settings to the
  733.     * program-wide defaults. This example just records that we haven't read
  734.     * any BMHD property or CMAP color registers yet. For the color map, that
  735.     * means the default is to leave the machine's color registers alone.
  736.     * If you want to read a property like GRAB, init it here to (0, 0). */
  737.  
  738.  
  739. iFrame.foundBMHD  = FALSE;
  740. iFrame.nColorRegs = 0;
  741.  
  742. iffp = ReadIFF(file, (ClientFrame *)&iFrame);
  743. return(iffp);
  744. }
  745.  
  746. VOID fill_instruct_text()
  747. {
  748. int iter, j;
  749.  
  750. /*  these are the text lines for MONOPOLY computer instructions
  751.  
  752.                            sample max line:
  753. instructline[X]="123456789012345678901234567890123456Abc"          */
  754.  
  755. /*   find-instructions   */
  756.  
  757. instructline[0]=" ";
  758. instructline[1]="       THE AMIGA SIMULATION OF";
  759. instructline[2]="      Parker Brothers' original  ";
  760. instructline[3]="              MONOPOLY";
  761. instructline[4]=" ";
  762. instructline[5]=" ";
  763. instructline[6]="    A game for two to four players.";
  764. instructline[7]=" ";
  765. instructline[8]="    Use the scroll and page gadgets";
  766. instructline[9]="to move through these instructions.";
  767. instructline[10]="Use the `close window' gadget to exit";
  768. instructline[11]="these instructions.";
  769. instructline[12]=" ";
  770. instructline[13]="     This game uses menus and gadgets";
  771. instructline[14]="to accomplish all game activities.";
  772. instructline[15]="The <HELP> key displays these";
  773. instructline[16]="directions at almost any time.  You";
  774. instructline[17]="may roll the dice by clicking the left"; 
  775. instructline[18]="mouse button with the pointer over the";
  776. instructline[19]="dice cup at the bottom of the board's";
  777. instructline[20]="center.  The computer takes care of all";
  778. instructline[21]="banking functions, rolls your dice,"; 
  779. instructline[22]="moves your token, pays and collects";
  780. instructline[23]="rent, and displays all information.";
  781. instructline[24]=" ";
  782. instructline[25]="    The PROJECT menu gives you five";
  783. instructline[26]="options, Change Token Colors, New Game,";
  784. instructline[27]="Old Game, Save Game, and QUIT.   You";
  785. instructline[28]="will get a VERIFY requester any time";
  786. instructline[29]="your command would destroy any unsaved";
  787. instructline[30]="game data.  Any time a player may roll,";
  788. instructline[31]="you may choose a command from the";
  789. instructline[32]="PROJECT menu.";
  790. instructline[33]="     To modify the colors of the";  
  791. instructline[34]="tokens, choose the first menu option."; 
  792. instructline[35]="This brings up a color-change requester"; 
  793. instructline[36]="allowing you to monitor your changes.";
  794. instructline[37]="The New Game command will start a new";
  795. instructline[38]="game (after the VERIFY requester.)  You";
  796. instructline[39]="may restore a previously saved game";
  797. instructline[40]="(after getting the VERIFY requester)";
  798. instructline[41]="using Old Game, which will bring up a";
  799. instructline[42]="file requester.  Save Game will also";
  800. instructline[43]="bring up a file requester.  The last";
  801. instructline[44]="command, QUIT, will bring up the VERIFY";
  802. instructline[45]="requester while showing the name of the";
  803. instructline[46]="player with the highest net worth.";
  804. instructline[47]=" ";
  805. instructline[48]="    The next menu, TRANSACTIONS,";
  806. instructline[49]="contains commands available at";
  807. instructline[50]="various times.  The first, Build House,";
  808. instructline[51]="has the players' names as sub-menus.";
  809. instructline[52]="Players with `ghosted' names have no";
  810. instructline[53]="monopolies upon which to build.  After";
  811. instructline[54]="selecting the proper name, you will be";
  812. instructline[55]="instructed to use the menu to choose a";
  813. instructline[56]="property upon which to build a house.";
  814. instructline[57]="Once again, `ghosted' properties are";
  815. instructline[58]="not available for construction, to";
  816. instructline[59]="the named player.  The next command,";
  817. instructline[60]="Sell House, follows the previous";
  818. instructline[61]="command's format, and allows you to";
  819. instructline[62]="remove any or all houses or hotels";
  820. instructline[63]="(reselling them to the bank.)  Of";
  821. instructline[64]="course, you will take a loss!";
  822. instructline[65]="Next, Mortgage Property, working";
  823. instructline[66]="similarly, allows you to borrow";
  824. instructline[67]="money from the bank.  Property";
  825. instructline[68]="MAY NOT BE MORTGAGED when there";
  826. instructline[69]="is a house or hotel upon it.  ALL";
  827. instructline[70]="buildings must be sold first!  Rent";
  828. instructline[71]="is not collected on mortgaged property.";
  829. instructline[72]="Lift Mortgage (same command format),"; 
  830. instructline[73]="allows you to repay the money borrowed";
  831. instructline[74]="with a mortgage.  You will pay ten";
  832. instructline[75]="percent (10%) interest, plus the amount";
  833. instructline[76]="of the loan.  You will collect rent the";
  834. instructline[77]="next time an opponent lands on this";
  835. instructline[78]="property.";
  836. instructline[79]="    The last two commands give you";
  837. instructline[80]="access to important information, though";
  838. instructline[81]="no action can be taken with these";
  839. instructline[82]="commands.  Review Property gives you";
  840. instructline[83]="information about all the properties.";
  841. instructline[84]="View Title Deeds brings up a notice to";
  842. instructline[85]="use the menu for access to a specific";
  843. instructline[86]="Title Deed.  The ADJACENT menu allows";
  844. instructline[87]="you to `page' through the deeds, in";
  845. instructline[88]="the order in which they appear on the";
  846. instructline[89]="board.  It also allows access to your";
  847. instructline[90]="bank balance and lets you stop";
  848. instructline[91]="examining deeds.  The PROPERTIES";
  849. instructline[92]="menu shows color groups with";
  850. instructline[93]="property names as sub-menus, select";
  851. instructline[94]="the name of the deed you wish";
  852. instructline[95]="to review.  When the deed appears";
  853. instructline[96]="the current rent value will be shown";
  854. instructline[97]="in red.  If the property is mortgaged,";
  855. instructline[98]="the last line will show this";
  856. instructline[99]="information.";
  857. instructline[100]="     The next menu, DEALS, can be used";
  858. instructline[101]="at many times.  Offer To Sell allows";
  859. instructline[102]="you to put an UNDEVELOPED property";
  860. instructline[103]="up for auction.  All players will";
  861. instructline[104]="have the option of bidding until";
  862. instructline[105]="satisfied, you will have the option";
  863. instructline[106]="of accepting any bid, or none at all.";
  864. instructline[107]="Offer To Buy lets you make offers";
  865. instructline[108]="on any UNDEVELOPED piece of property";
  866. instructline[109]="owned by another player.  Both of the";
  867. instructline[110]="Offer To... commands work in the same";
  868. instructline[111]="manner.  You are first instructed to";
  869. instructline[112]="choose an offeror's name from the"; 
  870. instructline[113]="NAME menu (clicking on the CONTINUE";
  871. instructline[114]="gadget will end the trading session),";
  872. instructline[115]="then you will be able to select an";
  873. instructline[116]="offering from the ASSET menu and enter";
  874. instructline[117]="a bid.  Clicking on the NO gadget will";
  875. instructline[118]="abort the trade at any time, the YES";
  876. instructline[119]="gadget will signify your approval of";
  877. instructline[120]="the trade information.  If no asset";
  878. instructline[121]="has been selected from the menu, the";
  879. instructline[122]="YES gadget will NOT work.  BE WARNED,";
  880. instructline[123]="the dollar gadget ALWAYS contains the";
  881. instructline[124]="most recently entered figure, insure";
  882. instructline[125]="that the information for BUYER, SELLER";
  883. instructline[126]="and AMOUNT are correct BEFORE";
  884. instructline[127]="finalizing the trade.  The last option";
  885. instructline[128]="under DEALS is Examine Bankroll.  This";
  886. instructline[129]="option displays your cash-on-hand, or";
  887. instructline[130]="bank balance.  Examine Bankroll will";
  888. instructline[131]="be found in a number of menus, but";
  889. instructline[132]="will NOT be available to a player";
  890. instructline[133]="landing on the Income Tax property.";
  891. instructline[134]="    The final menu, ROLL, controls the";
  892. instructline[135]="toss of the dice.  Roll Dice does just";
  893. instructline[136]="that.  When IN JAIL, you will have";
  894. instructline[137]="access to the option Get Out Free only";
  895. instructline[138]="if you have a GET-OUT-OF-JAIL-FREE";
  896. instructline[139]="card.  The third, Roll Doubles, lets";
  897. instructline[140]="you attempt to roll a pair of doubles,";
  898. instructline[141]="thereby escaping jail and advancing";
  899. instructline[142]="the amount shown on the dice.  You will";
  900. instructline[143]="have the option of rolling doubles at";
  901. instructline[144]="most three times.  From JAIL, you may";
  902. instructline[145]="choose Pay $50, paying your fine and";
  903. instructline[146]="getting to roll and advance.";
  904. instructline[147]=" ";
  905. instructline[148]="     When you land on an un-owned";
  906. instructline[149]="property you will see some information";
  907. instructline[150]="about that property and others in it's";
  908. instructline[151]="group.  The menus will give access to";
  909. instructline[152]="other information and two gadgets will";
  910. instructline[153]="offer you the option of purchasing the";
  911. instructline[154]="property or not.  If you select YES,";
  912. instructline[155]="the computer will check your bank";
  913. instructline[156]="balance; if you have funds to cover the";
  914. instructline[157]="purchase, the title will be in your";
  915. instructline[158]="name and your bank balance will be";
  916. instructline[159]="reduced by the purchase price.  If you";
  917. instructline[160]="select NO, the property will be put";
  918. instructline[161]="up for immediate auction.  If `NO BIDS'";
  919. instructline[162]="is selected play continues with no one";
  920. instructline[163]="gaining ownership of the property.";
  921. instructline[164]="Any player, including the player";
  922. instructline[165]="landing on the property, may bid on the";
  923. instructline[166]="property -- there is no minimum bid.";
  924. instructline[167]="After bidding is concluded, FIRST enter";
  925. instructline[168]="the amount of the winning bid in the";
  926. instructline[169]="dollar gadget (use the mouse to select";
  927. instructline[170]="the gadget, delete the current entry,";
  928. instructline[171]="then enter the new amount.)  LAST,";
  929. instructline[172]="select the winning player's name";
  930. instructline[173]="from the menu.  This menu selection";
  931. instructline[174]="will bring up a verification window";
  932. instructline[175]="showing the property's name, the";
  933. instructline[176]="buyer's name, and the final bid.";
  934. instructline[177]="CAREFULLY check all information for";
  935. instructline[178]="accuracy, then select YES if";
  936. instructline[179]="everything is correct, NO if changes"; 
  937. instructline[180]="need to be made.";
  938. instructline[181]="     Any time your activity causes";
  939. instructline[182]="your bank balance to drop below zero";
  940. instructline[183]="you will see an overdrawn requester.";
  941. instructline[184]="CAUTION!!! IF YOU CLOSE THIS WINDOW";
  942. instructline[185]="BEFORE OBTAINING FUNDS YOU MAY BE";
  943. instructline[186]="REMOVED FROM THE GAME IMMEDIATELY!";
  944. instructline[187]="ONLY when buying a property upon";
  945. instructline[188]="which you have JUST LANDED, building";
  946. instructline[189]="houses or hotels, or lifting a";
  947. instructline[190]="mortgage will you be able to close";
  948. instructline[191]="this overdrawn window safely!  Every";
  949. instructline[192]="other time, closing the window will";
  950. instructline[193]="be an act of ultimate submission,";
  951. instructline[194]="bringing up the QUIT GAME requester.";
  952. instructline[195]="If you select YES you will leave";
  953. instructline[196]="the game and all your assets will be";
  954. instructline[197]="turned over to the player or bank";
  955. instructline[198]="to whom you owe money.  If you select";
  956. instructline[199]="NO you will be given further chance";
  957. instructline[200]="to raise money.";
  958. instructline[201]="        --end of instructions--        ";
  959.  
  960. /*  must add all instructions for other things!!  */
  961. /*  if adding lines must recompile all files with reference to MAX_LINE
  962.         i.e.  f18.c                 */
  963.  
  964. instructIT[0].FrontPen=dk_blue;
  965. instructIT[0].BackPen=lt_blue;
  966. instructIT[0].DrawMode=JAM1;
  967. instructIT[0].ITextFont=NULL;
  968. instructIT[0].IText=NULL;
  969. instructIT[0].NextText=NULL;
  970. instructIT[0].LeftEdge=3;
  971. instructIT[0].TopEdge=15;
  972.  
  973. for (iter=0; iter<SHOW_LINES; iter++)   instructIT[iter]=instructIT[0];
  974. for (iter=0; iter<SHOW_LINES-1; iter++)
  975.    instructIT[iter].NextText=&instructIT[iter+1];
  976. for (iter=0; iter<SHOW_LINES; iter++)
  977.    instructIT[iter].IText=instructline[iter];
  978. for (iter=1, j=15; iter<SHOW_LINES; iter++)
  979.    instructIT[iter].TopEdge=j+=10;
  980. }
  981.