⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wow.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:

                    if (Machine->orientation & ORIENTATION_SWAP_XY)
                    {
                    	ey = x;
                        ex = y;
                    }

					stars[total_stars].x      = ex;
					stars[total_stars].y      = ey;
					stars[total_stars].colour = color-1;

					total_stars++;
				}
			}
		}
	}

	return 0;
}


void Gorf_CopyLine(int Line)
{
	/* Copy one line to bitmap, using current colour register settings */

    int memloc;
    int i,x;
    int data,color;
    int ey;

	if (dirtybuffer[Line] == 1 || LineColour[Line] != GorfColourCheck)
    {
		LineColour[Line] = GorfColourCheck;
        dirtybuffer[Line] = 0;

        memloc = Line * 80;

        /* Handle Line swops outside of loop */

        if (Machine->orientation & ORIENTATION_SWAP_XY)
        {
  		    if (Machine->orientation & ORIENTATION_FLIP_Y)
                ey = 203 - Line;
            else
  			    ey = Line;
        }
        else
        {
  		    if (Machine->orientation & ORIENTATION_FLIP_X)
                ey = 203 - Line;
            else
  			    ey = Line;
        }

	    for(i=0;i<80;i++,memloc++)
	    {
			data = wow_videoram[memloc];

            for(x=316-(i*4);x<=319-(i*4);x++)
            {
            	color = data & 0x03;

                if (Machine->orientation & ORIENTATION_SWAP_XY)
                {
					if (Machine->orientation & ORIENTATION_FLIP_X)
						tmpbitmap->line[ey][319-x] = Machine->pens[Colour[color]];
                    else
                    	tmpbitmap->line[ey][x] = Machine->pens[Colour[color]];
                }
                else
                {
					if (Machine->orientation & ORIENTATION_FLIP_Y)
						tmpbitmap->line[319-x][ey] = Machine->pens[Colour[color]];
                    else
                    	tmpbitmap->line[x][ey] = Machine->pens[Colour[color]];
                }

                data >>= 2;
            }
        }
	}
}

void gorf_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
    static int Speed=0;
	int offs;
    int Sparkle=0;
    int SparkleLow=0;
    int SparkleHigh=0;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


	/* copy the character mapped graphics */

  	copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);

    /* Plot the stars (on colour 0 only) */

    if (Colour[0] != 0)
    {
	    Speed = (Speed + 1) & 3;

        if (Speed==0)								/* Time to change colour */
        {
		    for (offs = total_stars-1;offs >= 0;offs--)
				stars[offs].colour = (stars[offs].colour + 1) & 7;
        }

	    for (offs = total_stars-1;offs >= 0;offs--)
	    {
		    if (bitmap->line[stars[offs].y][stars[offs].x] == Machine->pens[Colour[0]])
			    bitmap->line[stars[offs].y][stars[offs].x] = Machine->pens[Colour[0]+StarColour[stars[offs].colour]];
	    }
    }

    /*
     * Sparkle Circuit
     *
     * Because of the way the dirty rectangles are implemented, this will
     * be updated every 4 frames. It needs to be calculated every frame.
     *
     */

	if (RAM[0x5A93]==160) 							/* INVADERS */
    {
        Sparkle     = 3;
        SparkleLow  = 216;
        SparkleHigh = 257;
    }

	if (RAM[0x5A93]==5) 							/* FLAG SHIP */
    {
        Sparkle     = 3;
        SparkleLow  = 131;
        SparkleHigh = 171;
    }

    if (Sparkle)
    {
    	int Line;

        if (Machine->orientation & ORIENTATION_SWAP_XY)
        {
    	    for (Line = SparkleLow;Line <= SparkleHigh;Line++)
        	    for (offs=203;offs>=0;offs--)
            	    if (bitmap->line[offs][Line] == Machine->pens[Colour[Sparkle]])
                	    if (!(rand() & 0x04)) bitmap->line[offs][Line] = Machine->pens[Colour[0]];
        }
        else
        {
    	    for (Line = SparkleLow;Line <= SparkleHigh;Line++)
        	    for (offs=203;offs>=0;offs--)
            	    if (bitmap->line[Line][offs] == Machine->pens[Colour[Sparkle]])
                	    if (!(rand() & 0x04)) bitmap->line[Line][offs] = Machine->pens[Colour[0]];
        }
    }
}

/****************************************************************************
 * Seawolf specific routines
 ****************************************************************************/

void seawolf2_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
	extern int Controller1;
	extern int Controller2;

    int x,y,centre,middle;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


	/* copy the character mapped graphics */

	copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);

    /* Draw a sight */

    if(RAM[0xc1fb] != 0)	/* Number of Players */
    {
    	/* Yellow sight for Player 1 */

        centre = 317 - (Controller1-18) * 10;

        if (centre<2)   centre=2;
        if (centre>317) centre=317;

        if (Machine->orientation & ORIENTATION_SWAP_XY)
        {
			if ((Machine->orientation & ORIENTATION_FLIP_X) == 0)
				centre = 319 - centre;

		    if (Machine->orientation & ORIENTATION_FLIP_Y)
            	middle = 35;
            else
            	middle = 168;

	        for(y=middle-10;y<middle+11;y++)
				bitmap->line[centre][y] = Machine->pens[0x77];

    	    for(x=centre-20;x<centre+21;x++)
        	    if((x>0) && (x<319))
                    bitmap->line[x][middle] = Machine->pens[0x77];
        }
        else
        {
			if (Machine->orientation & ORIENTATION_FLIP_X)
				centre = 319 - centre;

		    if (Machine->orientation & ORIENTATION_FLIP_Y)
            	middle = 168;
            else
            	middle = 35;

	        for(y=middle-10;y<middle+11;y++)
				bitmap->line[y][centre] = Machine->pens[0x77];

    	    for(x=centre-20;x<centre+21;x++)
        	    if((x>0) && (x<319))
			        bitmap->line[middle][x] = Machine->pens[0x77];
        }

        /* Red sight for Player 2 */

        if(RAM[0xc1fb] == 2)
		{
            centre = 316 - (Controller2-18) * 10;

            if (centre<1)   centre=1;
            if (centre>316) centre=316;

            if (Machine->orientation & ORIENTATION_SWAP_XY)
            {
			    if ((Machine->orientation & ORIENTATION_FLIP_X) == 0)
				    centre = 319 - centre;

		    	if (Machine->orientation & ORIENTATION_FLIP_Y)
            		middle = 33;
	            else
    	        	middle = 170;

	            for(y=middle-10;y<middle+11;y++)
               	    bitmap->line[centre][y] = Machine->pens[0x58];

    	        for(x=centre-20;x<centre+21;x++)
        	        if((x>0) && (x<319))
                        bitmap->line[x][middle] = Machine->pens[0x58];
            }
            else
            {
			    if ((Machine->orientation & ORIENTATION_FLIP_X))
				    centre = 319 - centre;

			    if (Machine->orientation & ORIENTATION_FLIP_Y)
    	        	middle = 170;
        	    else
            		middle = 33;

	            for(y=middle-10;y<middle+11;y++)
			        bitmap->line[y][centre] = Machine->pens[0x58];

    	        for(x=centre-20;x<centre+21;x++)
        	        if((x>0) && (x<319))
                        bitmap->line[middle][x] = Machine->pens[0x58];
            }
        }
    }
}

/****************************************************************************
 * Wizard of Wor
 ****************************************************************************/

int wow_vh_start(void)
{
	int generator;
	int x,y;

	if (generic_vh_start() != 0)
		return 1;


	/* precalculate the star background */

	total_stars = 0;
	generator = 0;

	for (y = 203;y >= 0;y--)
	{
		for (x = 319;x >= 0;x--)
		{
			int bit1,bit2;

			generator <<= 1;
			bit1 = (~generator >> 17) & 1;
			bit2 = (generator >> 5) & 1;

			if (bit1 ^ bit2) generator |= 1;

			if (y >= Machine->drv->visible_area.min_y &&
				y <= Machine->drv->visible_area.max_y &&
				((~generator >> 16) & 1) &&
				(generator & 0x3f) == 0x3f)
			{
				int color;

				color = (~(generator >> 8)) & 0x07;
				if (color && (total_stars < MAX_STARS))
				{
               	    int ex,ey;

                    ex = x;
                    ey = y;

                    if (Machine->orientation & ORIENTATION_SWAP_XY)
                    {
                    	ey = x;
                        ex = y;
                    }

					stars[total_stars].x      = ex;
					stars[total_stars].y      = ey;
					stars[total_stars].colour = color-1;

					total_stars++;
				}
			}
		}
	}

	return 0;
}


void wow_vh_screenrefresh_stars(struct osd_bitmap *bitmap,int full_refresh)
{
    static int Speed=0;
	int offs;

	/* copy the character mapped graphics */

  	copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);

    /* Plot the stars (on colour 4 only) */

    if (Colour[4] != 0)
    {
	    Speed = (Speed + 1) & 3;

        if (Speed==0)								/* Time to change colour */
        {
		    for (offs = total_stars-1;offs >= 0;offs--)
				stars[offs].colour = (stars[offs].colour + 1) & 7;
        }

	    for (offs = 0;offs < total_stars;offs++)
	    {
		    int x,y;

		    x = stars[offs].x;
		    y = stars[offs].y;

		    if (bitmap->line[y][x] == Machine->pens[Colour[4]])
			    bitmap->line[y][x] = Machine->pens[Colour[4]+StarColour[stars[offs].colour]];
	    }
    }
}


/****************************************************************************
 * Standard WOW routines
 ****************************************************************************/

void CopyLine(int Line)
{
	/* Copy one line to bitmap, using current colour register settings */

    int memloc;
    int i,x;
    int data,color;
   	int ey;

    /* Redraw line if anything changed */

	if (dirtybuffer[Line] || LineColour[Line] != ColourCheck)
    {
		LineColour[Line]  = ColourCheck;
        dirtybuffer[Line] = 0;

        memloc = Line * 80;

        /* Handle Line swops outside of loop */

        if (Machine->orientation & ORIENTATION_SWAP_XY)
        {
  		    if (Machine->orientation & ORIENTATION_FLIP_Y)
  			    ey = Line;
            else
                ey = 203 - Line;

		}
        else
        {
  		    if (Machine->orientation & ORIENTATION_FLIP_Y)
                ey = 203 - Line;
            else
  			    ey = Line;

		}



        for(i=0;i<80;i++,memloc++)
        {
			data = wow_videoram[memloc];

            for(x=i*4+3;x>=i*4;x--)
            {
            	color = (data & 03) | 4;

                if (Machine->orientation & ORIENTATION_SWAP_XY)
                {
					if (Machine->orientation & ORIENTATION_FLIP_X)
						tmpbitmap->line[x][ey] = Machine->pens[Colour[color]];
                    else
                    	tmpbitmap->line[319-x][ey] = Machine->pens[Colour[color]];
                }
                else
                {
					if (Machine->orientation & ORIENTATION_FLIP_X)
                        tmpbitmap->line[ey][319-x] = Machine->pens[Colour[color]];
                    else
						tmpbitmap->line[ey][x] = Machine->pens[Colour[color]];
                }

                data >>= 2;
            }
        }
    }
}

void wow_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
	/* copy the character mapped graphics */

	copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -