home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / nethack-3.1 / sys / amiga / amirip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-25  |  16.7 KB  |  702 lines

  1. /*  SCCS Id: @(#)amirip.c   3.2 93/01/08
  2. /* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1991, 1992, 1993. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6. #include <exec/types.h>
  7. #include <exec/io.h>
  8. #include <exec/alerts.h>
  9. #include <exec/devices.h>
  10. #include <devices/console.h>
  11. #include <devices/conunit.h>
  12. #include <graphics/gfxbase.h>
  13. #include <graphics/gfxmacros.h>
  14. #include <intuition/intuition.h>
  15. #include <libraries/dosextens.h>
  16. #include <ctype.h>
  17. #include <string.h>
  18. #include "winami.h"
  19.  
  20. #undef  NULL
  21. #define NULL    0
  22.  
  23. #ifdef AZTEC_C
  24. # include <functions.h>
  25. #else
  26. # include <proto/dos.h>
  27. # include <proto/exec.h>
  28. # include <proto/console.h>
  29. # include <proto/diskfont.h>
  30.  
  31. /* terrible kludge */
  32. /* this is why prototypes should have ONLY types in them! */
  33. # undef red
  34. # undef green
  35. # undef blue
  36. # undef index
  37. # include <proto/graphics.h>
  38.  
  39. # include <proto/intuition.h>
  40. #endif /* AZTEC_C */
  41.  
  42. static void grass ( int x , int y );
  43. static void strand ( int x , int y , int dir );
  44. static void tomb_text ( char *p );
  45. static void getret( void );
  46. void draw_moon(int phase);
  47.  
  48. extern char *killed_by_prefix[];
  49. struct Window *ripwin;
  50.  
  51. #define STONE_LINE_LEN 18   /* # chars that fit on one line
  52.                  * (note 1 ' ' border)
  53.                  */
  54. #define MOONSIZE    30
  55.  
  56. static struct stabstuff
  57. {
  58.     short x1,y0;
  59. }
  60. stab[]=
  61. {
  62.     {0,0}, {0,1}, {0,2}, {1,3}, {2,4},
  63.     {3,5}, {5,6}, {7,7}, {9,8}, {11,9}
  64. };
  65.  
  66. static struct
  67. {
  68.     int x, y;    /* center of moon */
  69. }
  70. moon[]=
  71. {
  72. /* 0-7, left to right, 4 is full and just right of center
  73. 0-3 hollow to left, 5-7 hollow to right (DONT GO OFF THE SCREEN EDGE!) */
  74.     { 50, 70, },
  75.     { 120, 60, },
  76.     { 190, 50, },
  77.     { 260, 40, },
  78.     { 330, 30, },
  79.     { 410, 40, },
  80.     { 480, 50, },
  81.     { 550, 60, },
  82. };
  83.  
  84. unsigned short dirtpat[ 7 ][ 3 ][ 8 ]=
  85. {
  86. {
  87.  {0xb8a0, 0xc124, 0xa60f, 0x7894, 0x1152, 0x0ec1, 0x14c0, 0xa921, },
  88.  {0x4611, 0x365b, 0x5030, 0x0460, 0x44a0, 0xd106, 0x0131, 0x4282, },
  89.  {0xb9ee, 0xc9a4, 0xafcf, 0xfb9f, 0xbb5f, 0x2ef9, 0xfece, 0xbd7d, },
  90. },
  91.  
  92. {
  93.  {0x1258, 0x1015, 0xd430, 0x0488, 0x1402, 0x1040, 0x22e3, 0x8ce8, },
  94.  {0x00a4, 0x818a, 0x2a45, 0x6255, 0x49a8, 0xe69a, 0x9118, 0x1215, },
  95.  {0xff5b, 0x7e75, 0xd5ba, 0x9daa, 0xb657, 0x1965, 0x6ee7, 0xedea, },
  96. },
  97.  
  98. {
  99.  {0x9958, 0x0164, 0x80c8, 0xa660, 0x0412, 0x0025, 0x22ab, 0x2512, },
  100.  {0x64a4, 0xb292, 0x5525, 0x489d, 0x73c0, 0x7e8a, 0x0514, 0xd2ad, },
  101.  {0x9b5b, 0x4d6d, 0xaada, 0xb762, 0x8c3f, 0x8175, 0xfaeb, 0x2d52, },
  102. },
  103.  
  104. {
  105.  {0x8f41, 0xca1e, 0x29c2, 0xa4c0, 0x5481, 0x94d8, 0x9702, 0x0914, },
  106.  {0x608c, 0x05c0, 0x4425, 0x1936, 0x2a3e, 0x4203, 0x4064, 0x54c0, },
  107.  {0x9f73, 0xfa3f, 0xbbda, 0xe6c9, 0xd5c1, 0xbdfc, 0xbf9b, 0xab3f, },
  108. },
  109.  
  110. {
  111.  {0x4000, 0xd52b, 0x1010, 0x5008, 0x40c1, 0x4057, 0x014a, 0x606c, },
  112.  {0xa900, 0x2810, 0x0a85, 0x8fc6, 0x3406, 0xbfa0, 0xf020, 0x9d10, },
  113.  {0x56ff, 0xd7ef, 0xf57a, 0x7039, 0xcbf9, 0x405f, 0x0fdf, 0x62ef, },
  114. },
  115.  
  116. {
  117.  {0x8368, 0x0480, 0x900e, 0xf41f, 0x2e24, 0xfa03, 0x0397, 0x895c, },
  118.  {0x5814, 0x1022, 0x4ca0, 0x0300, 0x0042, 0x0078, 0xf048, 0x6683, },
  119.  {0xa7eb, 0xefdd, 0xb35f, 0xfcff, 0xffbd, 0xff87, 0x0fb7, 0x997c, },
  120. },
  121.  
  122. {
  123.  {0x4228, 0x0050, 0xa016, 0x42a3, 0x341c, 0x46a2, 0x23d3, 0x4001, },
  124.  {0xb515, 0x6383, 0x13c8, 0x8d5c, 0x0822, 0x1149, 0x4400, 0x8728, },
  125.  {0x4aea, 0x9c7c, 0xec37, 0x72a3, 0xf7dd, 0xeeb6, 0xbbff, 0x78d7, },
  126. },
  127. };
  128.  
  129. static USHORT stonepat[] =
  130. {
  131.     0x8242,
  132.     0x2421,
  133.     0x1888,
  134.     0x4112,
  135.     0x2444,
  136.     0x8218,
  137.     0x4181,
  138.     0x1824,
  139. };
  140.  
  141. static USHORT moundpat[] =
  142. {
  143.     0x5235,
  144.     0xd7c6,
  145.     0x1298,
  146.     0x34a7,
  147.     0x2736,
  148.     0x2c54,
  149.     0xdc93,
  150.     0xc551,
  151. };
  152.  
  153. #define DEATH_LINE  10
  154. #define YEAR_LINE   15
  155.  
  156. static int horizon;
  157. static struct RastPort *rp;
  158. static unsigned char tomb_line;
  159.  
  160. extern struct DisplayDesc *amiIDisplay;
  161. extern struct Screen *HackScreen;
  162. extern unsigned short amii_curmap[];
  163. extern int havelace;
  164.  
  165. #undef  BLACK
  166. #undef  WHITE
  167. #undef  BROWN
  168. #undef  GREEN
  169.  
  170. #define BLACK   0
  171. #define WHITE   1
  172. #define BROWN   2
  173. #define GREY    3
  174. #define GREEN   4
  175. #define DKGRN   5
  176.  
  177. static unsigned short zeropalette[] = {
  178.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  179. };
  180. static unsigned short toppalette[] = {
  181.     0x0000, 0x0EEF, 0x0730, 0x0778, 0x0082, 0x0573, 0x0000, 0x0000,
  182. };
  183.  
  184. #define AREA_SIZE   500
  185. static WORD areabuffer[ AREA_SIZE ];
  186.  
  187. static struct NewWindow newwin =
  188. {
  189.     0,0,640,200,1,0,
  190.     MOUSEBUTTONS|VANILLAKEY|NOCAREREFRESH,
  191.     BORDERLESS|ACTIVATE|SMART_REFRESH,
  192.     NULL,NULL,(UBYTE*)NULL,NULL,NULL,-1,-1,-1,-1,CUSTOMSCREEN
  193. };
  194.  
  195. int wh; /* was local in outrip, but needed for SCALE macro */
  196.  
  197. #define DEPTH ripwin->RPort->BitMap->Depth
  198. /*TODO: should use real algorithm to get circles */
  199. #define SCALE(x) ((wh<300)?(x):((x)*2))
  200. #define MOONSX  MOONSIZE
  201. #define MOONSY  ((SCALE(MOONSIZE)/2)-4)
  202.  
  203. void
  204. draw_moon(int phase)
  205. {
  206.     int x;
  207.     int off_c_x=MOONSX+10;    /* moon center x in srp */
  208.     int off_c_y=MOONSY;        /* moon center y in srp */
  209.     int blit_urhx=10;        /* upper right hand corner for blit */
  210.     int blit_urhy=0;
  211.     int blit_width=MOONSX*2;    /* sizes for blit */
  212.     int blit_height=MOONSY*2+1;    /* +1 - hmm (rounding? 0 base?)*/
  213.  
  214.     /* set up scratch rastport */
  215.     struct BitMap sbm;
  216.     struct RastPort srp;
  217.     struct AreaInfo ainfo;
  218.     short abuf[5];
  219.     struct TmpRas atr;
  220.     PLANEPTR ap;
  221.  
  222.     /*TODO: sizes here are bigger than needed */
  223.     InitBitMap(&sbm,DEPTH,MOONSIZE*4,MOONSIZE*2);
  224.     for(x=0;x<DEPTH;x++){
  225.     sbm.Planes[x]=(PLANEPTR)AllocRaster(MOONSIZE*2,MOONSIZE*4);
  226.     if(!sbm.Planes[x])goto free;
  227.     }
  228.     InitRastPort(&srp);
  229.     srp.BitMap=&sbm;
  230.     InitArea(&ainfo,abuf,2);
  231.     srp.AreaInfo= &ainfo;
  232.     ap=AllocRaster(320,200);
  233.     if(!ap)goto free;
  234. #ifdef AZTEC_C
  235.     /*
  236.      * Aztec, in their infinite wisdom, require a char * as the
  237.      * second argument.
  238.      */
  239.     InitTmpRas(&atr, (char *)ap, RASSIZE(320,200));
  240. #else
  241.     InitTmpRas(&atr,ap,RASSIZE(320,200));
  242. #endif
  243.     srp.TmpRas = &atr;
  244.     SetAfPt(rp,(UWORD *)NULL,0);
  245.     SetRast(&srp,BLACK);
  246.  
  247.     switch(phase){
  248.     case 0: /* new moon - no image */
  249.     break;
  250.     case 1: /* waxing crescent */
  251.     SetAPen(&srp,WHITE);
  252.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  253.     AreaEnd(&srp);
  254.     SetAPen(&srp,BLACK);
  255.     AreaEllipse(&srp,off_c_x+10,off_c_y,MOONSX,MOONSY);
  256.     AreaEnd(&srp);
  257.     break;
  258.  
  259.     case 2: /* 1st quarter */
  260.     SetAPen(&srp,WHITE);
  261.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  262.     AreaEnd(&srp);
  263.     SetAPen(&srp,BLACK);
  264.     RectFill(&srp,off_c_x,0,MOONSIZE*4-1,MOONSIZE*2-1);
  265.     break;
  266.     case 3: /* gibbous */
  267.     SetAPen(&srp,WHITE);
  268.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  269.     AreaEnd(&srp);
  270.     SetAPen(&srp,BLACK);
  271.     RectFill(&srp,off_c_x,0,MOONSIZE*4-1,MOONSIZE*2-1);
  272.     SetAPen(&srp,WHITE);
  273.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX/2,MOONSY);
  274.     AreaEnd(&srp);
  275.     break;
  276.     case 4: /* full */
  277.     SetAPen(&srp,WHITE);
  278.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  279.     AreaEnd(&srp);
  280.     break;
  281.     case 5: /* gibbous */
  282.     SetAPen(&srp,WHITE);
  283.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  284.     AreaEnd(&srp);
  285.     SetAPen(&srp,BLACK);
  286.     RectFill(&srp,0,0,off_c_x,MOONSIZE*2-1);
  287.     SetAPen(&srp,WHITE);
  288.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX/2,MOONSY);
  289.     AreaEnd(&srp);
  290.     break;
  291.     case 6: /* last quarter */
  292.     SetAPen(&srp,WHITE);
  293.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  294.     AreaEnd(&srp);
  295.     SetAPen(&srp,BLACK);
  296.     RectFill(&srp,0,0,off_c_x,MOONSIZE*4-1+10);
  297.     break;
  298.     case 7: /* waning crescent */
  299.     SetAPen(&srp,WHITE);
  300.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  301.     AreaEnd(&srp);
  302.     SetAPen(&srp,BLACK);
  303.     AreaEllipse(&srp,off_c_x-10,off_c_y,MOONSX,MOONSY);
  304.     AreaEnd(&srp);
  305.     break;
  306.     }
  307.     /*move rastport into window (so that there are no stars "in" the moon)*/
  308.     /* draw black circle in window rport */
  309.     SetAPen(rp,BLACK);
  310.     AreaEllipse( rp, moon[phase].x,moon[phase].y,MOONSX,MOONSY);
  311.     AreaEnd(rp);
  312.  
  313.     if(phase != 0){
  314.     /*move scratch to window: set all white, ignore black (in src)*/
  315.     ClipBlit(&srp,blit_urhx,blit_urhy,
  316.       rp,moon[phase].x-(blit_width/2),moon[phase].y-(blit_height/2),
  317.       blit_width,blit_height,0xe0);
  318.     }
  319.  
  320. free:
  321.     for(x=0;x<DEPTH;x++)
  322.     if(sbm.Planes[x])
  323.         FreeRaster(sbm.Planes[x],MOONSIZE*2,MOONSIZE*4);
  324.     if(ap)FreeRaster(ap,320,200);
  325. }
  326. #undef DEPTH
  327.  
  328. void
  329. outrip( how, tmpwin )
  330. int how;
  331. winid tmpwin;
  332. {
  333.     int done, rtxth;
  334.     struct IntuiMessage *imsg;
  335.     struct AreaInfo areaInfo;
  336.     PLANEPTR planeptr;
  337.     struct TmpRas tmpRas;
  338.     int i;
  339.     register char *dpx;
  340.     char buf[ 200 ];
  341.     register int x;
  342.     int line, phase, c, offset, tw, ww;
  343.  
  344.     /* Use the users display size */
  345.     newwin.Height = amiIDisplay->ypix - newwin.TopEdge;
  346.     newwin.Width = amiIDisplay->xpix;
  347.     newwin.Screen = HackScreen;
  348.  
  349.     ripwin = OpenWindow( &newwin );
  350.     if( !ripwin ){
  351.     return;
  352.     }
  353.  
  354.     rp= ripwin->RPort;
  355.     wh = ripwin->Height;
  356.     ww = ripwin->Width;
  357.     if( !( planeptr = AllocRaster( ww, wh ) ) )
  358.     return;
  359.  
  360. #ifdef AZTEC_C
  361.     InitTmpRas( &tmpRas, (char *) planeptr, RASSIZE( ww, wh ) );
  362. #else
  363.     InitTmpRas( &tmpRas, planeptr, RASSIZE( ww, wh ) );
  364. #endif
  365.     rp->TmpRas = &tmpRas;
  366.  
  367.     for( i = 0; i < AREA_SIZE; ++i )
  368.     areabuffer[ i ] = 0;
  369.     InitArea( &areaInfo, areabuffer, (AREA_SIZE*2)/5);
  370.     rp->AreaInfo = &areaInfo;
  371.  
  372.     LoadRGB4( &HackScreen->ViewPort, zeropalette, 8L );
  373.  
  374.     horizon=ripwin->Height*2/3;
  375.  
  376.     /* sky */
  377.     SetDrMd(rp,JAM1);
  378.     SetAPen( rp, BLACK );
  379.     RectFill(rp,0,0,ripwin->Width,horizon);
  380.  
  381.     /* ground */
  382.     SetDrMd( rp, JAM2 );
  383.     SetAfPt( rp, dirtpat[random()%7], -3 );
  384.     SetAPen( rp, 255 );
  385.     SetBPen( rp, 0 );
  386.     RectFill( rp, 0, horizon+1, ripwin->Width, ripwin->Height );
  387.     SetAfPt( rp, (UWORD *)NULL, 0 );
  388.  
  389.     /* stars */
  390.     SetAPen(rp,WHITE);
  391.     for(c=d(30,40);c;c--)
  392.     WritePixel(rp,rn2(ripwin->Width),rn2(horizon));
  393.  
  394.     /* moon (NB destroys area fill pattern) */
  395.     phase = phase_of_the_moon() % 8;
  396.     draw_moon(phase);
  397.  
  398.     /* grass */
  399.     offset=(phase<4)?-1:1;
  400.     SetAPen(rp,GREEN);
  401.     for( x = 0; x < ripwin->Width; x+=10+rn2(10))
  402.     grass(x, horizon+5 );
  403.  
  404.     /* fence - horizontal, then vertical, each with a moonlit side */
  405.     SetAPen(rp,GREY);
  406.     Move(rp,0,horizon-SCALE(20));
  407.     Draw(rp,ripwin->Width,horizon-SCALE(20));
  408.     Move(rp,0,horizon+30);
  409.     Draw(rp,ripwin->Width,horizon+30);
  410.  
  411.     for(x=30;x<ripwin->Width;x+=50)
  412.     {
  413.     Move(rp,x,horizon-SCALE(25));
  414.     Draw(rp,x,horizon+35);
  415.     Move(rp,x-offset,horizon-SCALE(25));
  416.     Draw(rp,x-offset,horizon+35);
  417.     Move(rp,x-(2*offset),horizon-SCALE(25));
  418.     Draw(rp,x-(2*offset),horizon+35);
  419.     }
  420.  
  421.  
  422.     if(phase)SetAPen(rp,WHITE); /* no vertical white if no moon */
  423.     Move(rp,0,horizon-SCALE(20)-1);
  424.     Draw(rp,ripwin->Width,horizon-SCALE(20)-1);
  425.     Move(rp,0,horizon+29);
  426.     Draw(rp,ripwin->Width,horizon+29);
  427.  
  428.     if(phase!=0 && phase!=4){
  429.     SetAPen(rp,WHITE);
  430.     } else {
  431.     SetAPen(rp,GREY);   /* no hor. white if no or full moon */
  432.     }
  433.     for(x=30;x<ripwin->Width;x+=50)
  434.     {
  435.     Move(rp,x+offset,horizon-SCALE(25));
  436.     Draw(rp,x+offset,horizon+35);
  437.     Move(rp,x+(2*offset),horizon-SCALE(25));
  438.     Draw(rp,x+(2*offset),horizon+35);
  439.     }
  440.  
  441.     /* Put together death description */
  442.     switch (killer_format) {
  443.     default:
  444.     impossible("bad killer format?");
  445.     case KILLED_BY_AN:
  446.     Strcpy(buf, killed_by_prefix[how]);
  447.     Strcat(buf, an(killer));
  448.     break;
  449.     case KILLED_BY:
  450.     Strcpy(buf, killed_by_prefix[how]);
  451.     Strcat(buf, killer);
  452.     break;
  453.     case NO_KILLER_PREFIX:
  454.     Strcpy(buf, killer);
  455.     break;
  456.     }
  457.  
  458.     tw = TextLength(rp,buf,STONE_LINE_LEN) + 40;
  459.  
  460.     {
  461.     char *p=buf;
  462.     int x;
  463.     for(x=STONE_LINE_LEN;x;x--)*p++='W';
  464.     *p='\0';
  465.     tw = max( tw, TextLength(rp,buf,STONE_LINE_LEN) + 40 );
  466.     }
  467.  
  468.     SetAPen( rp, phase ? BLACK : GREY );
  469.     SetBPen( rp, phase ? WHITE : BLACK );
  470.     SetDrMd( rp, JAM2 );
  471.     SetAfPt( rp, stonepat, 3 );
  472.  
  473.     /* There are 5 lines of text on the stone. */
  474.     rtxth = ripwin->RPort->TxHeight * 5;
  475.  
  476.     /* Do shadow ellipse on stone */
  477.     if( phase < 4 )
  478.     AreaEllipse(rp,ripwin->Width/2-3,horizon-rtxth,tw/2+3,tw/6);
  479.     else if( phase > 4 )
  480.     AreaEllipse(rp,ripwin->Width/2+3,horizon-rtxth,tw/2+3,tw/6);
  481.     else
  482.     AreaEllipse(rp,ripwin->Width/2,horizon-rtxth-2,tw/2+3,tw/6);
  483.     AreaEnd( rp );
  484.  
  485.     /* Top ellipse on stone */
  486.     SetAPen( rp, BLACK );
  487.     SetBPen( rp, GREY );
  488.     AreaEllipse(rp,ripwin->Width/2,horizon-rtxth,tw/2,tw/6);
  489.     AreaEnd( rp );
  490.  
  491.     /* Body of stone */
  492.     RectFill(rp,ripwin->Width/2-tw/2,horizon-rtxth,ripwin->Width/2+tw/2,
  493.       horizon-rtxth+15+(rp->TxHeight+1)*8);
  494.  
  495.     SetAPen( rp, phase ? BROWN : GREY );
  496.     SetBPen( rp, phase ? GREY : BROWN );
  497.     SetAfPt( rp, stonepat, 3 );
  498.  
  499. #if 0
  500.     AreaMove( rp, ripwin->Width/2-tw/2, horizon-rtxth+15+(rp->TxHeight+1)*8 );
  501.     AreaDraw( rp, ripwin->Width/2-tw/4, horizon-rtxth+((ripwin->Height > 200)
  502.       ? 55 : 35)+(rp->TxHeight+1)*8 );
  503.     AreaDraw( rp, ripwin->Width/2+tw, horizon-rtxth+((ripwin->Height > 200)
  504.       ? 55 : 35)+(rp->TxHeight+1)*8 );
  505.     AreaDraw( rp, ripwin->Width/2+tw/2, horizon-rtxth+15+(rp->TxHeight+1)*8 );
  506.     AreaEnd( rp );
  507.  
  508.     SetAfPt( rp, stonepat, 3 );
  509.  
  510. #endif
  511.     /* Draw shadow on correct side of stone */
  512.     SetAPen( rp, phase ? BLACK : GREY );
  513.     SetBPen( rp, phase ? WHITE : BLACK );
  514.     if( phase < 4 )
  515.     {
  516.     AreaMove( rp, ripwin->Width/2-tw/2-6, horizon-rtxth );
  517.     AreaDraw( rp, ripwin->Width/2-tw/2-6,
  518.       horizon-rtxth+15+(rp->TxHeight+1)*8-4 );
  519.     AreaDraw( rp, ripwin->Width/2-tw/2-1,
  520.       horizon-rtxth+15+(rp->TxHeight+1)*8 );
  521.     AreaDraw( rp, ripwin->Width/2-tw/2-1, horizon-rtxth );
  522.     }
  523.     else if( phase > 4 )
  524.     {
  525.     AreaMove( rp, ripwin->Width/2+tw/2+6, horizon-rtxth );
  526.     AreaDraw( rp, ripwin->Width/2+tw/2+6,
  527.       horizon-rtxth+15+(rp->TxHeight+1)*8-4 );
  528.     AreaDraw( rp, ripwin->Width/2+tw/2+1,
  529.       horizon-rtxth+15+(rp->TxHeight+1)*8 );
  530.     AreaDraw( rp, ripwin->Width/2+tw/2+1, horizon-rtxth );
  531.     }
  532.     AreaEnd( rp );
  533.  
  534.     SetAfPt( rp, (UWORD *)NULL, 0 );
  535.     SetDrPt( rp, ~0 );
  536.  
  537.     tomb_line=0;
  538.     SetBPen(rp,GREY);
  539.     SetDrMd(rp,JAM1);
  540.     tomb_text("REST");
  541.     tomb_text("IN");
  542.     tomb_text("PEACE");
  543.  
  544.     /* Put name on stone */
  545.     Sprintf(buf, "%s", plname);
  546.     buf[STONE_LINE_LEN] = 0;
  547.     tomb_text(buf);
  548.  
  549.     /* Put $ on stone */
  550.     Sprintf(buf, "%ld Au", u.ugold);
  551.     buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
  552.     tomb_text(buf);
  553.  
  554.     /* Put together death description */
  555.     switch (killer_format) {
  556.     default:
  557.     impossible("bad killer format?");
  558.     case KILLED_BY_AN:
  559.     Strcpy(buf, killed_by_prefix[how]);
  560.     Strcat(buf, an(killer));
  561.     break;
  562.     case KILLED_BY:
  563.     Strcpy(buf, killed_by_prefix[how]);
  564.     Strcat(buf, killer);
  565.     break;
  566.     case NO_KILLER_PREFIX:
  567.     Strcpy(buf, killer);
  568.     break;
  569.     }
  570.  
  571.     /* Put death type on stone */
  572.     for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++)
  573.     {
  574.     register int i,i0;
  575.     char tmpchar;
  576.  
  577.     if ( (i0=strlen(dpx)) > STONE_LINE_LEN)
  578.     {
  579.         for(i=STONE_LINE_LEN;((i0 > STONE_LINE_LEN) && i); i--)
  580.         {
  581.         if(dpx[i] == ' ')
  582.             i0 = i;
  583.         }
  584.         if(!i)
  585.         i0 = STONE_LINE_LEN;
  586.     }
  587.  
  588.     tmpchar = dpx[i0];
  589.     dpx[i0] = 0;
  590.     tomb_text(dpx);
  591.  
  592.     if (tmpchar != ' ')
  593.     {
  594.         dpx[i0] = tmpchar;
  595.         dpx= &dpx[i0];
  596.     }
  597.     else
  598.     {
  599.         dpx= &dpx[i0+1];
  600.     }
  601.     }
  602.  
  603.     /* Put year on stone */
  604.     Sprintf(buf, "%4d", getyear());
  605.     tomb_text(buf);
  606.  
  607.     LoadRGB4( &HackScreen->ViewPort, toppalette, 8L );
  608.  
  609.     done = 0;
  610.     while( !done )
  611.     {
  612.     WaitPort( ripwin->UserPort );
  613.     while( imsg = (struct IntuiMessage *)GetMsg(ripwin->UserPort) )
  614.     {
  615.         switch( imsg->Class )
  616.         {
  617.         case MOUSEBUTTONS:
  618.         case VANILLAKEY:
  619.             done = 1;
  620.             break;
  621.         }
  622.         ReplyMsg( (struct Message *)imsg );
  623.     }
  624.     }
  625.  
  626.     if( planeptr ) FreeRaster( planeptr, ww, wh );
  627.     rp->TmpRas = NULL;
  628.     Forbid();
  629.     while( imsg = (struct IntuiMessage *)GetMsg( ripwin->UserPort ) )
  630.     ReplyMsg( (struct Message *)imsg );
  631.     CloseWindow( ripwin );
  632.     ripwin = NULL;
  633.     Permit();
  634.     LoadRGB4( &HackScreen->ViewPort, amii_curmap, 8L );
  635. }
  636.  
  637. static void grass(x,y)
  638. register int x,y;
  639. {
  640.     register int ct=rn2(5)+3;
  641.     register int c;
  642.     x-=2;
  643.     for(c=ct;c;c--)
  644.     {
  645.     strand(x,y,(c>ct/2)?1:-1);
  646.     x+=2;
  647.     }
  648. }
  649.  
  650. static void strand(x,y,dir)
  651.    register int x,y;
  652.    register int dir;    /* which way the wind blows :-) */
  653. {
  654.     register int i;
  655.     register struct RastPort *nrp = rp;
  656.     register struct stabstuff *st;
  657.     for(i=rn2(10);i>=0;i--)
  658.     {
  659.     st = &stab[i];
  660.     WritePixel(nrp,x+st->x1*dir,y-st->y0);
  661.     }
  662. }
  663.  
  664. static void tomb_text(p)
  665. char *p;
  666. {
  667.     char buf[STONE_LINE_LEN*2];
  668.     int l;
  669.     /*int i;*/
  670.  
  671.     if( !*p )
  672.     return;
  673.     sprintf(buf," %s ",p);
  674.     l=TextLength(rp,buf,strlen(buf));
  675.     ++tomb_line;
  676.  
  677.     SetAPen(rp,WHITE);
  678.     Move(rp,(ripwin->Width/2)-(l/2)-1, 
  679.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  680.     Text(rp,buf,strlen(buf));
  681.  
  682.     SetAPen(rp,WHITE);
  683.     Move(rp,(ripwin->Width/2)-(l/2)+1,
  684.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  685.     Text(rp,buf,strlen(buf));
  686.  
  687.     SetAPen(rp,WHITE);
  688.     Move(rp,(ripwin->Width/2)-(l/2),
  689.       ((tomb_line-6)*(rp->TxHeight+1))+horizon - 1);
  690.     Text(rp,buf,strlen(buf));
  691.  
  692.     SetAPen(rp,WHITE);
  693.     Move(rp,(ripwin->Width/2)-(l/2),
  694.       ((tomb_line-6)*(rp->TxHeight+1))+horizon + 1);
  695.     Text(rp,buf,strlen(buf));
  696.  
  697.     SetAPen(rp,BLACK);
  698.     Move(rp,(ripwin->Width/2)-(l/2),
  699.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  700.     Text(rp,buf,strlen(buf));
  701. }
  702.