home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / v2600 / source.lha / source / amiga_raster.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-10  |  16.6 KB  |  810 lines

  1. /*****************************************************************************
  2.  
  3.    This file is part of x2600, the Atari 2600 Emulator
  4.    ===================================================
  5.    
  6.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  7.  
  8.    This software is distributed under the terms of the GNU General Public
  9.    License. This is free software with ABSOLUTELY NO WARRANTY.
  10.    
  11.    See the file COPYING for Details.
  12.    
  13.    Really tweaked by Matthew Stroup for Amiga v2600, February 5, 1997.
  14.  
  15. ******************************************************************************/
  16.  
  17. /* Raster graphics procedures */
  18.  
  19. #include "config.h"
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include "types.h"
  23. #include "address.h"
  24. #include "vmachine.h"
  25. #include "display.h"
  26. #include "options.h"
  27. #include "debug.h"
  28. #include "collision.h"
  29.  
  30. /* Color lookup tables. Used to speed up rendering */
  31. /* The current colour lookup table */
  32. int *colour_lookup;  
  33.  
  34. /* Colour table */
  35. #define P0M0_COLOUR 0
  36. #define P1M1_COLOUR 1
  37. #define PFBL_COLOUR 2
  38. #define BK_COLOUR 3
  39. UBYTE colour_table[4];
  40.  
  41. /* normal/alternate, not scores/scores*/
  42. int norm_val, scores_val;
  43. int *colour_ptrs[2][3];
  44.  
  45. /* Normal priority */
  46. static int colour_normal[64];
  47. static int colour_normscoresl[64];
  48. static int colour_normscoresr[64];
  49.  
  50. /* Alternate priority */
  51. static int colour_alternate[64];
  52. static int colour_altscoresl[64];
  53. static int colour_altscoresr[64];
  54.  
  55. /* Playfield screen position */
  56. UINT32 *pf_pos;
  57. UBYTE *line_ptr;
  58. UBYTE bkc;
  59.  
  60. /* Draw playfield register PF0 */
  61. /* pf: playfield structure */
  62. /* dir: 1=normal, 0=mirrored */
  63. __inline void draw_pf0 (struct PlayField *pf, int dir)
  64. {
  65.   int pfm;            /* playfield mask */
  66.   /* 1=forward */
  67.   if (dir)
  68.     {
  69.       for (pfm = 0x10; pfm < 0x100; pfm <<= 1)
  70.     {
  71.       if (pf->pf0 & pfm)
  72.         *(pf_pos++) = PF_MASK32;
  73.       else
  74.         pf_pos++;
  75.     }
  76.     }
  77.   else
  78.     {
  79.       for (pfm = 0x80; pfm > 0x08; pfm >>= 1)
  80.     {
  81.       if (pf->pf0 & pfm)
  82.         *(pf_pos++) = PF_MASK32;
  83.       else
  84.         pf_pos++;
  85.     }
  86.     }
  87. }
  88.  
  89. /* Draw playfield register PF1 */
  90. /* pf: playfield structure */
  91. /* dir: 1=normal, 0=mirrored */
  92. __inline void draw_pf1 (struct PlayField *pf, int dir)
  93. {
  94.   int pfm;            /* playfield mask */
  95.   /* 1=forward */
  96.   if (dir)
  97.     {
  98.       /* do PF1 */
  99.       for (pfm = 0x80; pfm > 0; pfm >>= 1)
  100.     {
  101.       if (pf->pf1 & pfm)
  102.         *(pf_pos++) = PF_MASK32;
  103.       else
  104.         pf_pos ++;
  105.     }
  106.     }
  107.   else
  108.     {
  109.       /* do PF1 */
  110.       for (pfm = 0x01; pfm < 0x100; pfm <<= 1)
  111.     {
  112.       if (pf->pf1 & pfm)
  113.         *(pf_pos++) = PF_MASK32;
  114.       else
  115.         pf_pos ++;
  116.     }
  117.     }
  118. }
  119.  
  120. /* Draw playfield register PF2 */
  121. /* pf: playfield structure */
  122. /* dir: 1=normal, 0=mirrored */
  123. __inline void draw_pf2 (struct PlayField *pf, int dir)
  124. {
  125.   int pfm;            /* playfield mask */
  126.   /* 1=forward */
  127.   if (dir)
  128.     {
  129.       /* do PF2 */
  130.       for (pfm = 0x01; pfm < 0x100; pfm <<= 1)
  131.     {
  132.       if (pf->pf2 & pfm)
  133.         *(pf_pos++) = PF_MASK32;
  134.       else
  135.         pf_pos ++;
  136.     }
  137.     }
  138.   else
  139.     {
  140.       for (pfm = 0x80; pfm > 0; pfm >>= 1)
  141.     {
  142.       if (pf->pf2 & pfm)
  143.         *(pf_pos++) = PF_MASK32;
  144.       else
  145.         pf_pos ++;
  146.     }
  147.     }
  148. }
  149.  
  150. /* Update from the playfield display list */
  151. /* num: playfield to use. Now depreciated as only pf[0] is used */
  152. /* nextx: the start position of the next playfield element */
  153. /* pfc: the number of the next playfield change structure */
  154. /* pf_max: the highest playfield change structure */
  155. __inline void pf_update (int num, int nextx, int *pfc, int pf_max)
  156. {
  157.   for (; (*pfc < pf_max) && (nextx + 3 > pf_change[num][*pfc].x); (*pfc)++)
  158.     {
  159.       use_pfraster_change (&pf[num], &pf_change[num][*pfc]);
  160.     }
  161. }
  162.  
  163. /* Draw the playfield */
  164. void draw_playfield (void)
  165. {
  166.   const int num = 0;        /* Stick to one playfield */
  167.   int pfc = 0;
  168.   int pf_max = pf_change_count[num];
  169.  
  170.   pf_pos = (UINT32 *)colvect;
  171.   /* First half of playfield */
  172.  
  173.   pf_update (num, 0, &pfc, pf_max);
  174.   draw_pf0 (&pf[0], 1);
  175.   pf_update (num, 16, &pfc, pf_max);
  176.   draw_pf1 (&pf[0], 1);
  177.   pf_update (num, 48, &pfc, pf_max);
  178.   draw_pf2 (&pf[0], 1);
  179.  
  180.   pf_update (num, 80, &pfc, pf_max);
  181.   /* Second half of playfield */
  182.   if (pf[0].ref)
  183.     {
  184.       draw_pf2 (&pf[0], 0);
  185.       pf_update (num, 112, &pfc, pf_max);
  186.       draw_pf1 (&pf[0], 0);
  187.       pf_update (num, 144, &pfc, pf_max);
  188.       draw_pf0 (&pf[0], 0);
  189.     }
  190.   else
  191.     {
  192.       draw_pf0 (&pf[0], 1);
  193.       pf_update (num, 96, &pfc, pf_max);
  194.       draw_pf1 (&pf[0], 1);
  195.       pf_update (num, 128, &pfc, pf_max);
  196.       draw_pf2 (&pf[0], 1);
  197.     }
  198.   /* Use last changes */
  199.   for (; pfc < pf_max; pfc++)
  200.     use_pfraster_change (&pf[num], &pf_change[num][pfc]);
  201.  
  202.   pf_change_count[num] = 0;
  203. }
  204.  
  205. /* Draws a normal (8 clocks) sized player */
  206. /* p: the player to draw */
  207. /* x: the position to draw it */
  208. __inline void pl_normal (struct Player *p, int x)
  209. {
  210.   /* Set pointer to start of player graphic */
  211.   UBYTE *ptr = colvect + x;
  212.   UBYTE mask;
  213.   UBYTE gr;
  214.  
  215.   if (p->vdel_flag)
  216.     gr = p->vdel;
  217.   else
  218.     gr = p->grp;
  219.  
  220.   if (p->reflect)
  221.     {
  222.       /* Reflected: start with D0 of GRP on left */
  223.       for (mask = 0x01; mask > 0; mask <<= 1)
  224.     {
  225.       if (gr & mask)
  226.         {
  227.           *(ptr++) |= p->mask;
  228.         }
  229.       else
  230.         ptr++;
  231.     }
  232.     }
  233.   else
  234.     {
  235.       /* Unreflected: start with D7 of GRP on left */
  236.       for (mask = 0x80; mask > 0; mask >>= 1)
  237.     {
  238.       if (gr & mask)
  239.         {
  240.           *(ptr++) |= p->mask;
  241.         }
  242.       else
  243.         ptr++;
  244.     }
  245.     }
  246. }
  247.  
  248. /* Draws a double width ( 16 clocks ) player */
  249. /* p: the player to draw */
  250. /* x: the position to draw it */
  251. __inline void pl_double (struct Player *p, int x)
  252. {
  253.   /* Set pointer to start of player graphic */
  254.   UBYTE *ptr = colvect + (x);
  255.   UBYTE mask;
  256.   UBYTE gr;
  257.  
  258.   if (p->vdel_flag)
  259.     gr = p->vdel;
  260.   else
  261.     gr = p->grp;
  262.  
  263.   if (p->reflect)
  264.     {
  265.       for (mask = 0x01; mask > 0; mask <<= 1)
  266.     {
  267.       if (gr & mask)
  268.         {
  269.           *(ptr++) |= p->mask;
  270.           *(ptr++) |= p->mask;
  271.         }
  272.       else
  273.         ptr += 2;
  274.     }
  275.     }
  276.   else
  277.     {
  278.       for (mask = 0x80; mask > 0; mask >>= 1)
  279.     {
  280.       if (gr & mask)
  281.         {
  282.           *(ptr++) |= p->mask;
  283.           *(ptr++) |= p->mask;
  284.         }
  285.       else
  286.         ptr += 2;
  287.     }
  288.     }
  289. }
  290.  
  291. /* Draws a quad sized ( 32 clocks) player */
  292. /* p: the player to draw */
  293. /* x: the position to draw it */
  294. __inline void pl_quad (struct Player *p, int x)
  295. {
  296.   /* Set pointer to start of player graphic */
  297.   UBYTE *ptr = colvect + x;
  298.   UBYTE mask;
  299.   UBYTE gr;
  300.  
  301.   if (p->vdel_flag)
  302.     gr = p->vdel;
  303.   else
  304.     gr = p->grp;
  305.  
  306.   if (p->reflect)
  307.     {
  308.       for (mask = 0x01; mask > 0; mask <<= 1)
  309.     {
  310.       if (gr & mask)
  311.         {
  312.           *(ptr++) |= p->mask;
  313.           *(ptr++) |= p->mask;
  314.           *(ptr++) |= p->mask;
  315.           *(ptr++) |= p->mask;
  316.         }
  317.       else
  318.         ptr += 4;
  319.     }
  320.     }
  321.   else
  322.     {
  323.       for (mask = 0x80; mask > 0; mask >>= 1)
  324.     {
  325.       if (gr & mask)
  326.         {
  327.           *(ptr++) |= p->mask;
  328.           *(ptr++) |= p->mask;
  329.           *(ptr++) |= p->mask;
  330.           *(ptr++) |= p->mask;
  331.         }
  332.       else
  333.         ptr += 4;
  334.     }
  335.     }
  336. }
  337.  
  338. /* Consume the player display list */
  339. __inline void pl_update (int num, int nextx, int *plc, int pl_max)
  340. {
  341.   for (; (*plc < pl_max) && (nextx > pl_change[num][*plc].x); (*plc)++)
  342.     {
  343.       use_plraster_change (&pl[num], &pl_change[num][*plc]);
  344.     }
  345. }
  346.  
  347. /* Draw a player graphic */
  348. /* line: the vertical position of the raster */
  349. /* num: the number of player to draw, current 0 or 1 for P0 and P1 */
  350. static __inline void pl_draw (int num)
  351. {
  352.   int plc = 0;
  353.   int pl_max = pl_change_count[num];
  354.   int nextx;
  355.  
  356.   pl_update (num, pl[num].x, &plc, pl_max);
  357.   if (pl[num].x >= 0 && pl[num].x < tv_width)
  358.     {
  359.  
  360.       /*if(pl_max > plc)
  361.          use_plraster_change( &pl[num], &pl_change[num][plc++]); */
  362.       switch (pl[num].nusize)
  363.     {
  364.     case 0:
  365.       /* One copy */
  366.       pl_normal (&pl[num], pl[num].x);
  367.       break;
  368.     case 1:
  369.       /* Two copies close */
  370.       pl_normal (&pl[num], pl[num].x);
  371.       nextx = pl[num].x + 8 + 8;
  372.       pl_update (num, nextx, &plc, pl_max);
  373.       pl_normal (&pl[num], nextx);
  374.       break;
  375.     case 2:
  376.       /* Two copies medium */
  377.       pl_normal (&pl[num], pl[num].x);
  378.       nextx = pl[num].x + 8 + 24;
  379.       pl_update (num, nextx, &plc, pl_max);
  380.       pl_normal (&pl[num], nextx);
  381.       break;
  382.     case 3:
  383.       /* Three copies close */
  384.       /* Pacman score line */
  385.       pl_normal (&pl[num], pl[num].x);
  386.  
  387.       nextx = pl[num].x + 16;
  388.       pl_update (num, nextx, &plc, pl_max);
  389.       pl_normal (&pl[num], nextx);
  390.  
  391.       nextx = pl[num].x + 32;
  392.       pl_update (num, nextx, &plc, pl_max);
  393.  
  394.       pl_normal (&pl[num], nextx);
  395.       break;
  396.     case 4:
  397.       /* Two copies wide */
  398.       pl_normal (&pl[num], pl[num].x);
  399.       nextx = pl[num].x + 8 + 56;
  400.       pl_update (num, nextx, &plc, pl_max);
  401.       pl_normal (&pl[num], nextx);
  402.       break;
  403.     case 5:
  404.       /* Double sized player */
  405.       pl_double (&pl[num], pl[num].x);
  406.       break;
  407.     case 6:
  408.       /* Three copies medium */
  409.       pl_normal (&pl[num], pl[num].x);
  410.       nextx = pl[num].x + 8 + 24;
  411.       pl_update (num, nextx, &plc, pl_max);
  412.       pl_normal (&pl[num], nextx);
  413.       nextx = pl[num].x + 8 + 56;
  414.       pl_update (num, nextx, &plc, pl_max);
  415.       pl_normal (&pl[num], nextx);
  416.       break;
  417.     case 7:
  418.       /* Quad sized player */
  419.       pl_quad (&pl[num], pl[num].x);
  420.       break;
  421.     }
  422.     }
  423.   /* Use last changes */
  424.   for (; plc < pl_max; plc++)
  425.     use_plraster_change (&pl[num], &pl_change[num][plc]);
  426.   pl_change_count[num] = 0;
  427. }
  428.  
  429.  
  430. /* Draw the ball graphic */
  431. /* line: the vertical position of the raster */
  432. static __inline void draw_ball (void)
  433. {
  434.   int i;
  435.   UBYTE *blptr;
  436.   UBYTE e;
  437.  
  438.   if (ml[2].vdel_flag)
  439.     e = ml[2].vdel;
  440.   else
  441.     e = ml[2].enabled;
  442.  
  443.   if (e && ml[2].x >= 0)
  444.     {
  445.       blptr = colvect + (ml[2].x);
  446.       switch (tiaWrite[CTRLPF] >> 4)
  447.     {
  448.     case 3:
  449.       /* Eight clocks */
  450.       for (i = 0; i < 8; i++)
  451.         *(blptr++) |= BL_MASK;
  452.       break;
  453.     case 2:
  454.       /* Four clocks */
  455.       for (i = 0; i < 4; i++)
  456.         *(blptr++) |= BL_MASK;
  457.       break;
  458.     case 1:
  459.       /* Two clocks */
  460.       for (i = 0; i < 2; i++)
  461.         *(blptr++) |= BL_MASK;
  462.       break;
  463.     case 0:
  464.       /* One clock */
  465.       *(blptr++) |= BL_MASK;
  466.       break;
  467.     }
  468.     }
  469. }
  470.  
  471.  
  472. /* Draw a missile graphic */
  473. static __inline void do_missile (int num, UBYTE * misptr)
  474. {
  475.   int i;
  476.  
  477.   misptr = colvect + (ml[num].x);
  478.   switch (ml[num].width)
  479.     {
  480.     case 0:
  481.       /* one clock */
  482.       *(misptr++) |= ml[num].mask;
  483.       break;
  484.     case 1:
  485.       /* two clocks */
  486.       for (i = 0; i < 2; i++)
  487.     *(misptr++) |= ml[num].mask;
  488.       break;
  489.     case 2:
  490.       /* four clocks */
  491.       for (i = 0; i < 4; i++)
  492.     *(misptr++) |= ml[num].mask;
  493.       break;
  494.     case 3:
  495.       /* Eight clocks */
  496.       for (i = 0; i < 8; i++)
  497.     *(misptr++) |= ml[num].mask;
  498.       break;
  499.     }                /* switch */
  500. }
  501.  
  502. /* Draw a missile taking into account the player's position. */
  503. /* line: the vertical position of the raster */
  504. /* num: 0 for M0, 1 for M1 */
  505. static __inline void draw_missile (int num)
  506. {
  507.   UBYTE *misptr;
  508.  
  509.   if (ml[num].enabled && ml[num].x >= 0)
  510.     {
  511.       switch (pl[num].nusize)
  512.     {
  513.     case 0:
  514.       misptr = colvect + (ml[num].x);
  515.       do_missile (num, misptr);
  516.       break;
  517.     case 1:
  518.       misptr = colvect + (ml[num].x);
  519.       do_missile (num, misptr);
  520.       misptr = misptr + 16;
  521.       do_missile (num, misptr);
  522.       break;
  523.     case 2:
  524.       misptr = colvect + (ml[num].x);
  525.       do_missile (num, misptr);
  526.       misptr = misptr + 32;
  527.       do_missile (num, misptr);
  528.       break;
  529.     case 3:
  530.       misptr = colvect + (ml[num].x);
  531.       do_missile (num, misptr);
  532.       misptr = misptr + 16;
  533.       do_missile (num, misptr);
  534.       misptr = misptr + 16;
  535.       do_missile (num, misptr);
  536.       break;
  537.     case 4:
  538.       misptr = colvect + (ml[num].x);
  539.       do_missile (num, misptr);
  540.       misptr = misptr + 64;
  541.       do_missile (num, misptr);
  542.       break;
  543.     case 5:
  544.       misptr = colvect + (ml[num].x);
  545.       do_missile (num, misptr);
  546.       break;
  547.     case 6:
  548.       misptr = colvect + (ml[num].x);
  549.       do_missile (num, misptr);
  550.       misptr = misptr + 32;
  551.       do_missile (num, misptr);
  552.       misptr = misptr + 32;
  553.       do_missile (num, misptr);
  554.       break;
  555.     case 7:
  556.       misptr = colvect + (ml[num].x);
  557.       do_missile (num, misptr);
  558.       break;
  559.  
  560.     }
  561.  
  562.     }                /* If */
  563. }
  564.  
  565.  
  566. /* Construct one tv raster line colvect */
  567. /* line: the vertical position of the raster */
  568. void tv_rasterise (int line)
  569. {
  570.   line_ptr = vscreen + line * vwidth;
  571.  
  572.   /* Draw the playfield first */
  573.   draw_playfield (); 
  574.   
  575.   /* Do the ball */
  576.   draw_ball ();
  577.   
  578.   /* Do the player 1 graphics */
  579.   draw_missile (1);
  580.   pl_draw (1);
  581.   
  582.   /* Do the player 0 graphics */
  583.   draw_missile (0);
  584.   pl_draw (0);
  585. }
  586.  
  587. /* Reset the collision vector */
  588. void reset_vector (void)
  589. {
  590.   int i;
  591.   UINT32 *cpos=(UINT32 *)colvect;
  592.   for (i = 0; i < 40; i++)
  593.     cpos[i] = 0;
  594. }
  595.  
  596.  
  597. /* draw the collision vector */
  598. /* Quick version with no magnification */
  599. void draw_vector_q (void)
  600. {
  601.   int i;
  602.   int uct = 0;
  603.   int colind, colval;
  604.   UBYTE pad;
  605.   UBYTE *tv_ptr = line_ptr;
  606.   
  607.   /* Check for scores */
  608.   if(scores_val ==2) 
  609.     {
  610.       scores_val=1;
  611.       colour_lookup=colour_ptrs[norm_val][scores_val];
  612.     }
  613.  
  614.   /* Use starting changes */
  615.   while (uct < unified_count && unified[uct].x < 0)
  616.     use_unified_change (&unified[uct++]);
  617.  
  618.   for (i = 0; i < 80; i++)
  619.     {
  620.       if (uct < unified_count && unified[uct].x == i)
  621.     use_unified_change (&unified[uct++]);
  622.       
  623.       if((colval=colvect[i])){
  624.     
  625.     /* Collision detection */
  626.     col_state|=col_table[colval];
  627.     
  628.     colind=colour_lookup[colval];
  629.     pad=colors[colour_table[colind]];
  630.       } else
  631.     pad=colors[colour_table[BK_COLOUR]];      
  632.  
  633.     *(tv_ptr++)=pad;
  634.     *(tv_ptr++)=pad;
  635.     }
  636.  
  637.   /* Check for scores */
  638.   if(scores_val ==1)
  639.     {
  640.       scores_val=2;
  641.       colour_lookup=colour_ptrs[norm_val][scores_val];
  642.     }
  643.   for (i = 80; i < 160; i++)
  644.     {
  645.       if (uct < unified_count && unified[uct].x == i)
  646.     use_unified_change (&unified[uct++]);
  647.       
  648.       if((colval=colvect[i])){
  649.     
  650.     /* Collision detection */
  651.     col_state|=col_table[colval];
  652.     
  653.     colind=colour_lookup[colval];
  654.     pad=colors[colour_table[colind]];
  655.       } else
  656.     pad=colors[colour_table[BK_COLOUR]];      
  657.  
  658.     *(tv_ptr++)=pad;
  659.     *(tv_ptr++)=pad;
  660.     }
  661.  
  662.   while (uct < unified_count)
  663.     use_unified_change (&unified[uct++]);
  664.   unified_count = 0;
  665. }
  666.  
  667. /* Used for when running in frame skipping mode */
  668. static __inline void update_registers (void)
  669. {
  670.   int i, num;
  671.  
  672.   /* Playfield */
  673.   for (i = 0; i < pf_change_count[0]; i++)
  674.     use_pfraster_change (&pf[0], &pf_change[0][i]);
  675.   pf_change_count[0] = 0;
  676.  
  677.   /* Player graphics */
  678.   for (num = 0; num < 2; num++)
  679.     {
  680.       for (i = 0; i < pl_change_count[num]; i++)
  681.     use_plraster_change (&pl[num], &pl_change[num][i]);
  682.       pl_change_count[num] = 0;
  683.     }
  684.  
  685.   /* Unified */
  686.   for (i = 0; i < unified_count; i++)
  687.     use_unified_change (&unified[i]);
  688.   unified_count = 0;
  689. }
  690.  
  691. /* Main raster function, will have switches for different magsteps */
  692. /* line: the vertical position of the raster */
  693. void tv_raster (int line)
  694. {
  695.   if ((tv_counter % base_opts.rr != 0)  || (line > theight) )
  696.     {
  697.       update_registers ();
  698.     }
  699.   else
  700.     {
  701.       reset_vector();
  702.       tv_rasterise (line);
  703.       draw_vector_q();
  704.     }
  705. }
  706.  
  707.  
  708. void init_raster (void)
  709. {
  710.   int i,val;
  711.  
  712.   init_collisions();
  713.  
  714.   /* Normal Priority */
  715.   for (i=0; i<64; i++)
  716.     {
  717.       if (i & (PL0_MASK | ML0_MASK))
  718.     val = P0M0_COLOUR;
  719.       else if (i & (PL1_MASK | ML1_MASK))
  720.     val = P1M1_COLOUR;
  721.       else if (i & (BL_MASK | PF_MASK))
  722.     val = PFBL_COLOUR;
  723.       else
  724.     val = BK_COLOUR;     
  725.       colour_normal[i]=val;
  726.     }
  727.  
  728.   /* Alternate Priority */
  729.   for (i=0; i<64; i++)
  730.     {  
  731.       if (i & (BL_MASK | PF_MASK))
  732.     val = PFBL_COLOUR;
  733.       else if (i & (PL0_MASK | ML0_MASK))
  734.     val = P0M0_COLOUR;
  735.       else if (i & (PL1_MASK | ML1_MASK))
  736.     val = P1M1_COLOUR;
  737.       else
  738.     val = BK_COLOUR;
  739.       colour_alternate[i]=val;
  740.     }
  741.  
  742.   /* Normal Scores Left */
  743.   for (i=0; i<64; i++)
  744.     {
  745.       if (i & (PL0_MASK | ML0_MASK))
  746.     val = P0M0_COLOUR;
  747.       else if (i & (PL1_MASK | ML1_MASK))
  748.     val = P1M1_COLOUR;
  749.       else if (i & (BL_MASK | PF_MASK))
  750.     /* Use P1 colour */
  751.     val = P0M0_COLOUR;
  752.       else
  753.     val = BK_COLOUR;     
  754.       colour_normscoresl[i]=val;
  755.     }
  756.   
  757.   /* Normal Scores Right */
  758.   for (i=0; i<64; i++)
  759.     {
  760.       if (i & (PL0_MASK | ML0_MASK))
  761.     val = P0M0_COLOUR;
  762.       else if (i & (PL1_MASK | ML1_MASK))
  763.     val = P1M1_COLOUR;
  764.       else if (i & (BL_MASK | PF_MASK))
  765.     /* Use P1 colour */
  766.     val = P1M1_COLOUR;
  767.       else
  768.     val = BK_COLOUR;     
  769.       colour_normscoresr[i]=val;
  770.     }
  771.  
  772.   /* Alternate Scores Left*/
  773.   for (i=0; i<64; i++)
  774.     {  
  775.       if (i & (BL_MASK | PF_MASK))
  776.     val = P0M0_COLOUR;
  777.       else if (i & (PL0_MASK | ML0_MASK))
  778.     val = P0M0_COLOUR;
  779.       else if (i & (PL1_MASK | ML1_MASK))
  780.     val = P1M1_COLOUR;
  781.       else
  782.     val = BK_COLOUR;
  783.       colour_altscoresl[i]=val;
  784.     }
  785.  
  786.   /* Alternate Scores Right*/
  787.   for (i=0; i<64; i++)
  788.     {  
  789.       if (i & (BL_MASK | PF_MASK))
  790.     val = P1M1_COLOUR;
  791.       else if (i & (PL0_MASK | ML0_MASK))
  792.     val = P0M0_COLOUR;
  793.       else if (i & (PL1_MASK | ML1_MASK))
  794.     val = P1M1_COLOUR;
  795.       else
  796.     val = BK_COLOUR;
  797.       colour_altscoresr[i]=val;
  798.     }
  799.   
  800.   colour_ptrs[0][0]=colour_normal;
  801.   colour_ptrs[1][0]=colour_alternate;
  802.   colour_ptrs[0][1]=colour_normscoresl;
  803.   colour_ptrs[1][1]=colour_altscoresl;
  804.   colour_ptrs[0][2]=colour_normscoresr;
  805.   colour_ptrs[1][2]=colour_altscoresr;
  806.   norm_val=0; scores_val=0;
  807.  
  808.   colour_lookup=colour_normal;
  809. }
  810.