1 /***************************************************************************
2 
3   Snow Brothers by ToaPlan - GFX driver.
4   GFX processor - PX79C480FP-3 (KANEKO, Pandora-Chip)
5 
6 ***************************************************************************/
7 
8 #include "driver.h"
9 #include "vidhrdw/generic.h"
10 
11 
WRITE16_HANDLER(snowbros_flipscreen_w)12 WRITE16_HANDLER( snowbros_flipscreen_w )
13 {
14 	if (ACCESSING_MSB)
15 		flip_screen_set(~data & 0x8000);
16 }
17 
18 
VIDEO_UPDATE(snowbros)19 VIDEO_UPDATE( snowbros )
20 {
21 	int sx=0, sy=0, x=0, y=0, offs;
22 
23 
24 	/*
25 	 * Sprite Tile Format
26 	 * ------------------
27 	 *
28 	 * Byte | Bit(s)   | Use
29 	 * -----+-76543210-+----------------
30 	 *	0-5	| -------- | ?
31 	 *	6	| -------- | ?
32 	 *	7	| xxxx.... | Palette Bank
33 	 *	7	| .......x | XPos - Sign Bit
34 	 *	9	| xxxxxxxx | XPos
35 	 *	7	| ......x. | YPos - Sign Bit
36 	 *	B	| xxxxxxxx | YPos
37 	 *	7	| .....x.. | Use Relative offsets
38 	 *	C	| -------- | ?
39 	 *	D	| xxxxxxxx | Sprite Number (low 8 bits)
40 	 *	E	| -------- | ?
41 	 *	F	| ....xxxx | Sprite Number (high 4 bits)
42 	 *	F	| x....... | Flip Sprite Y-Axis
43 	 *	F	| .x...... | Flip Sprite X-Axis
44 	 */
45 
46 	/* This clears & redraws the entire screen each pass */
47 
48 	fillbitmap(bitmap,0xf0,&Machine->visible_area);
49 
50 	for (offs = 0;offs < spriteram_size/2;offs += 8)
51 	{
52 		int dx = spriteram16[offs+4] & 0xff;
53 		int dy = spriteram16[offs+5] & 0xff;
54 		int tilecolour = spriteram16[offs+3];
55 		int attr = spriteram16[offs+7];
56 		int flipx =   attr & 0x80;
57 		int flipy =  (attr & 0x40) << 1;
58 		int tile  = ((attr & 0x3f) << 8) + (spriteram16[offs+6] & 0xff);
59 
60 		if (tilecolour & 1) dx = -1 - (dx ^ 0xff);
61 		if (tilecolour & 2) dy = -1 - (dy ^ 0xff);
62 		if (tilecolour & 4)
63 		{
64 			x += dx;
65 			y += dy;
66 		}
67 		else
68 		{
69 			x = dx;
70 			y = dy;
71 		}
72 
73 		if (x > 511) x &= 0x1ff;
74 		if (y > 511) y &= 0x1ff;
75 
76 		if (flip_screen)
77 		{
78 			sx = 240 - x;
79 			sy = 240 - y;
80 			flipx = !flipx;
81 			flipy = !flipy;
82 		}
83 		else
84 		{
85 			sx = x;
86 			sy = y;
87 		}
88 
89 		drawgfx(bitmap,Machine->gfx[0],
90 				tile,
91 				(tilecolour & 0xf0) >> 4,
92 				flipx, flipy,
93 				sx,sy,
94 				&Machine->visible_area,TRANSPARENCY_PEN,0);
95 	}
96 }
97 
VIDEO_UPDATE(wintbob)98 VIDEO_UPDATE( wintbob )
99 {
100 	int offs;
101 
102 	fillbitmap(bitmap,get_black_pen(),&Machine->visible_area);
103 
104 	for (offs = 0;offs < spriteram_size/2;offs += 8)
105 	{
106 		int xpos  = spriteram16[offs] & 0xff;
107 		int ypos  = spriteram16[offs+4] & 0xff;
108 /*		int unk1  = spriteram16[offs+1] & 0x01;*/  /* Unknown .. Set for the Bottom Left part of Sprites */
109 		int disbl = spriteram16[offs+1] & 0x02;
110 /*		int unk2  = spriteram16[offs+1] & 0x04;*/  /* Unknown .. Set for most things */
111 		int wrapr = spriteram16[offs+1] & 0x08;
112 		int colr  = (spriteram16[offs+1] & 0xf0) >> 4;
113 		int tilen = (spriteram16[offs+2] << 8) + (spriteram16[offs+3] & 0xff);
114 		int flipx = spriteram16[offs+2] & 0x80;
115 		int flipy = (spriteram16[offs+2] & 0x40) << 1;
116 
117 		if (wrapr == 8) xpos -= 256;
118 
119 		if (flip_screen)
120 		{
121 			xpos = 240 - xpos;
122 			ypos = 240 - ypos;
123 			flipx = !flipx;
124 			flipy = !flipy;
125 		}
126 
127 		if ((xpos > -16) && (ypos > 0) && (xpos < 256) && (ypos < 240) && (disbl !=2))
128 		{
129 			drawgfx(bitmap,Machine->gfx[0],
130 					tilen,
131 					colr,
132 					flipx, flipy,
133 					xpos,ypos,
134 					&Machine->visible_area,TRANSPARENCY_PEN,0);
135 		}
136 	}
137 }
138