trunk/src/mame/video/spbactn.c
| r30594 | r30595 | |
| 3 | 3 | #include "includes/spbactn.h" |
| 4 | 4 | |
| 5 | 5 | |
| 6 | | static void blendbitmaps(palette_device &palette, |
| 7 | | bitmap_rgb32 &dest,bitmap_ind16 &src1,bitmap_ind16 &src2, |
| 8 | | const rectangle &cliprect) |
| 9 | | { |
| 10 | | int y,x; |
| 11 | | const pen_t *paldata = palette.pens(); |
| 12 | 6 | |
| 13 | | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 14 | | { |
| 15 | | UINT32 *dd = &dest.pix32(y); |
| 16 | | UINT16 *sd1 = &src1.pix16(y); |
| 17 | | UINT16 *sd2 = &src2.pix16(y); |
| 18 | | |
| 19 | | for (x = cliprect.min_x; x <= cliprect.max_x; x++) |
| 20 | | { |
| 21 | | if (sd2[x]) |
| 22 | | { |
| 23 | | if (sd2[x] & 0x1000) |
| 24 | | dd[x] = paldata[sd1[x] & 0x07ff] + paldata[sd2[x]]; |
| 25 | | else |
| 26 | | dd[x] = paldata[sd2[x]]; |
| 27 | | } |
| 28 | | else |
| 29 | | dd[x] = paldata[sd1[x]]; |
| 30 | | } |
| 31 | | } |
| 32 | | } |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | 7 | WRITE16_MEMBER(spbactn_state::bg_videoram_w) |
| 37 | 8 | { |
| 38 | 9 | COMBINE_DATA(&m_bgvideoram[offset]); |
| r30594 | r30595 | |
| 43 | 14 | { |
| 44 | 15 | int attr = m_bgvideoram[tile_index]; |
| 45 | 16 | int tileno = m_bgvideoram[tile_index+0x2000]; |
| 46 | | SET_TILE_INFO_MEMBER(1, tileno, ((attr & 0x00f0)>>4)+0x80, 0); |
| 17 | SET_TILE_INFO_MEMBER(1, tileno, ((attr & 0x00f0)>>4), 0); |
| 47 | 18 | } |
| 48 | 19 | |
| 49 | 20 | |
| r30594 | r30595 | |
| 62 | 33 | |
| 63 | 34 | /* blending */ |
| 64 | 35 | if (attr & 0x0008) |
| 65 | | color += 0x00f0; |
| 66 | | else |
| 67 | | color |= 0x0080; |
| 36 | color += 0x0010; |
| 68 | 37 | |
| 69 | 38 | SET_TILE_INFO_MEMBER(0, tileno, color, 0); |
| 70 | 39 | } |
| r30594 | r30595 | |
| 149 | 118 | |
| 150 | 119 | int spbactn_state::draw_video(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, bool alt_sprites) |
| 151 | 120 | { |
| 121 | m_tile_bitmap_bg.fill(0, cliprect); |
| 152 | 122 | m_tile_bitmap_fg.fill(0, cliprect); |
| 153 | 123 | m_sprite_bitmap.fill(0, cliprect); |
| 154 | | |
| 155 | | #if 1 |
| 156 | | m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 124 | bitmap.fill(0, cliprect); |
| 157 | 125 | |
| 158 | | |
| 159 | | if (m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 0, m_tile_bitmap_bg)) |
| 160 | | { |
| 161 | | m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0); |
| 162 | | } |
| 163 | | |
| 164 | | m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 1, m_tile_bitmap_bg); |
| 165 | | |
| 126 | m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), -2, m_sprite_bitmap); |
| 127 | m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0); |
| 166 | 128 | m_fg_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 0); |
| 167 | 129 | |
| 168 | | m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 2, m_tile_bitmap_fg); |
| 169 | | m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 3, m_tile_bitmap_fg); |
| 170 | 130 | |
| 171 | | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 172 | | blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect); |
| 173 | | #else |
| 174 | | bitmap.fill(0, cliprect); |
| 175 | 131 | |
| 176 | | m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), -2, m_sprite_bitmap); |
| 132 | //int frame = (screen.frame_number()) & 1; |
| 133 | // note this game has no tx layer, comments relate to other drivers |
| 177 | 134 | |
| 178 | | |
| 179 | 135 | int y, x; |
| 180 | 136 | const pen_t *paldata = m_palette->pens(); |
| 181 | 137 | |
| r30594 | r30595 | |
| 183 | 139 | { |
| 184 | 140 | UINT32 *dd = &bitmap.pix32(y); |
| 185 | 141 | UINT16 *sd2 = &m_sprite_bitmap.pix16(y); |
| 142 | UINT16 *fg = &m_tile_bitmap_fg.pix16(y); |
| 143 | UINT16 *bg = &m_tile_bitmap_bg.pix16(y); |
| 186 | 144 | |
| 187 | 145 | for (x = cliprect.min_x; x <= cliprect.max_x; x++) |
| 188 | 146 | { |
| 189 | | UINT16 pixel = (sd2[x] & 0xff) + 0x800; |
| 147 | UINT16 sprpixel = (sd2[x]); |
| 190 | 148 | |
| 191 | | if (pixel & 0xf) dd[x] = paldata[pixel]; |
| 149 | UINT16 sprpri = (sprpixel & 0x0300) >> 8; |
| 150 | UINT16 sprbln = (sprpixel & 0x0400) >> 8; |
| 151 | sprpixel &= 0xff; |
| 152 | |
| 153 | UINT16 fgpixel = (fg[x]); |
| 154 | UINT16 fgbln = (fgpixel & 0x0100) >> 8; |
| 155 | fgpixel &= 0xff; |
| 156 | |
| 157 | UINT16 bgpixel = (bg[x]); |
| 158 | bgpixel &= 0xff; |
| 159 | |
| 160 | if (sprpixel&0xf) |
| 161 | { |
| 162 | switch (sprpri) |
| 163 | { |
| 164 | case 0: // behind all |
| 165 | |
| 166 | |
| 167 | if (fgpixel & 0xf) // is the fg used? |
| 168 | { |
| 169 | if (fgbln) |
| 170 | { |
| 171 | dd[x] = rand(); |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | // solid FG |
| 176 | dd[x] = paldata[fgpixel + 0x800 + 0x200]; |
| 177 | } |
| 178 | } |
| 179 | else if (bgpixel & 0x0f) |
| 180 | { |
| 181 | // solid BG |
| 182 | dd[x] = paldata[bgpixel + 0x800 + 0x300]; |
| 183 | } |
| 184 | else |
| 185 | { |
| 186 | if (sprbln) |
| 187 | { // sprite is blended with bgpen? |
| 188 | dd[x] = rand(); |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | // solid sprite |
| 193 | dd[x] = paldata[sprpixel + 0x800 + 0x000]; |
| 194 | } |
| 195 | |
| 196 | } |
| 197 | |
| 198 | break; |
| 199 | |
| 200 | case 1: // above bg, behind tx, fg |
| 201 | |
| 202 | if (fgpixel & 0xf) // is the fg used? |
| 203 | { |
| 204 | if (fgbln) |
| 205 | { |
| 206 | if (sprbln) |
| 207 | { |
| 208 | // needs if bgpixel & 0xf check? |
| 209 | |
| 210 | // fg is used and blended with sprite, sprite is used and blended with bg? -- used on 'trail' of ball when ball is under the transparent area |
| 211 | dd[x] = paldata[bgpixel + 0x0000 + 0x300] + paldata[sprpixel + 0x1000 + 0x000]; // WRONG?? |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | // fg is used and blended with opaque sprite |
| 216 | dd[x] = paldata[fgpixel + 0x1000 + 0x100] + paldata[sprpixel + 0x000 + 0x000]; |
| 217 | } |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | // fg is used and opaque |
| 222 | dd[x] = paldata[fgpixel + 0x800 + 0x200]; |
| 223 | } |
| 224 | |
| 225 | } |
| 226 | else |
| 227 | { |
| 228 | if (sprbln) |
| 229 | { |
| 230 | // needs if bgpixel & 0xf check? |
| 231 | |
| 232 | //fg isn't used, sprite is used and blended with bg? -- used on trail of ball / flippers |
| 233 | dd[x] = paldata[bgpixel + 0x0000 + 0x300];/* +paldata[sprpixel + 0x1000 + 0x000];*/ // WRONG?? |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | // fg isn't used, sprite is used and is opaque |
| 238 | dd[x] = paldata[sprpixel + 0x800 + 0x000]; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | |
| 243 | break; |
| 244 | |
| 245 | case 2: // above bg,fg, behind tx |
| 246 | |
| 247 | if (sprbln) |
| 248 | { |
| 249 | // unusued by this game? |
| 250 | dd[x] = 0;// rand(); |
| 251 | |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | dd[x] = paldata[sprpixel + 0x800 + 0x000]; |
| 256 | //dd[x] = rand(); |
| 257 | } |
| 258 | break; |
| 259 | |
| 260 | case 3: // above all? |
| 261 | |
| 262 | if (sprbln) |
| 263 | { |
| 264 | // unusued by this game? |
| 265 | dd[x] = rand(); |
| 266 | } |
| 267 | else |
| 268 | { |
| 269 | dd[x] = paldata[sprpixel + 0x800 + 0x000]; |
| 270 | } |
| 271 | |
| 272 | break; |
| 273 | |
| 274 | } |
| 275 | } |
| 276 | else // NON SPRITE CASES |
| 277 | { |
| 278 | if (fgpixel & 0x0f) |
| 279 | { |
| 280 | if (fgbln) |
| 281 | { |
| 282 | // needs if bgpixel & 0xf check? |
| 283 | dd[x] = paldata[fgpixel + 0x1000 + 0x100] + paldata[bgpixel + 0x0000+0x300]; |
| 284 | |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | dd[x] = paldata[fgpixel + 0x800 + 0x200]; |
| 289 | } |
| 290 | |
| 291 | } |
| 292 | else /*if (bgpixel & 0x0f) */ |
| 293 | { |
| 294 | dd[x] = paldata[bgpixel + 0x800 + 0x300]; |
| 295 | } |
| 296 | } |
| 192 | 297 | } |
| 193 | 298 | } |
| 194 | 299 | |
| 195 | | #endif |
| 300 | |
| 196 | 301 | return 0; |
| 197 | 302 | } |
| 198 | 303 | |