trunk/src/mess/drivers/vii.c
| r20903 | r20904 | |
| 152 | 152 | protected: |
| 153 | 153 | optional_memory_region m_region_cart; |
| 154 | 154 | required_ioport m_io_p1; |
| 155 | |
| 156 | void vii_blit(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile); |
| 157 | void vii_blit_page(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs); |
| 158 | void vii_blit_sprite(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr); |
| 159 | void vii_blit_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth); |
| 155 | 160 | }; |
| 156 | 161 | |
| 157 | 162 | enum |
| r20903 | r20904 | |
| 225 | 230 | state->m_screen[offset].b = expand_rgb5_to_rgb8(rgb); |
| 226 | 231 | } |
| 227 | 232 | |
| 228 | | static void vii_blit(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile) |
| 233 | void vii_state::vii_blit(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile) |
| 229 | 234 | { |
| 230 | | vii_state *state = machine.driver_data<vii_state>(); |
| 231 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 235 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 232 | 236 | |
| 233 | 237 | UINT32 h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT); |
| 234 | 238 | UINT32 w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT); |
| r20903 | r20904 | |
| 272 | 276 | |
| 273 | 277 | if((ctrl & 0x0010) && yy < 240) |
| 274 | 278 | { |
| 275 | | xx = (xx - (INT16)state->m_p_rowscroll[yy]) & 0x01ff; |
| 279 | xx = (xx - (INT16)m_p_rowscroll[yy]) & 0x01ff; |
| 276 | 280 | } |
| 277 | 281 | |
| 278 | 282 | if(xx < 320 && yy < 240) |
| 279 | 283 | { |
| 280 | | UINT16 rgb = state->m_p_palette[pal]; |
| 284 | UINT16 rgb = m_p_palette[pal]; |
| 281 | 285 | if(!(rgb & 0x8000)) |
| 282 | 286 | { |
| 283 | 287 | if (attr & 0x4000) |
| 284 | 288 | { |
| 285 | | vii_mix_pixel(state, xx + 320*yy, rgb); |
| 289 | vii_mix_pixel(this, xx + 320*yy, rgb); |
| 286 | 290 | } |
| 287 | 291 | else |
| 288 | 292 | { |
| 289 | | vii_set_pixel(state, xx + 320*yy, rgb); |
| 293 | vii_set_pixel(this, xx + 320*yy, rgb); |
| 290 | 294 | } |
| 291 | 295 | } |
| 292 | 296 | } |
| r20903 | r20904 | |
| 294 | 298 | } |
| 295 | 299 | } |
| 296 | 300 | |
| 297 | | static void vii_blit_page(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs) |
| 301 | void vii_state::vii_blit_page(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs) |
| 298 | 302 | { |
| 299 | 303 | UINT32 x0, y0; |
| 300 | 304 | UINT32 xscroll = regs[0]; |
| r20903 | r20904 | |
| 304 | 308 | UINT32 tilemap = regs[4]; |
| 305 | 309 | UINT32 palette_map = regs[5]; |
| 306 | 310 | UINT32 h, w, hn, wn; |
| 307 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 311 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 308 | 312 | |
| 309 | 313 | if(!(ctrl & PAGE_ENABLE_MASK)) |
| 310 | 314 | { |
| r20903 | r20904 | |
| 358 | 362 | yy = ((h*y0 - yscroll + 0x10) & 0xff) - 0x10; |
| 359 | 363 | xx = (w*x0 - xscroll) & 0x1ff; |
| 360 | 364 | |
| 361 | | vii_blit(machine, bitmap, cliprect, xx, yy, tileattr, tilectrl, bitmap_addr, tile); |
| 365 | vii_blit(bitmap, cliprect, xx, yy, tileattr, tilectrl, bitmap_addr, tile); |
| 362 | 366 | } |
| 363 | 367 | } |
| 364 | 368 | } |
| 365 | 369 | |
| 366 | | static void vii_blit_sprite(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr) |
| 370 | void vii_state::vii_blit_sprite(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr) |
| 367 | 371 | { |
| 368 | | vii_state *state = machine.driver_data<vii_state>(); |
| 369 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 372 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 370 | 373 | UINT16 tile, attr; |
| 371 | 374 | INT16 x, y; |
| 372 | 375 | UINT32 h, w; |
| 373 | | UINT32 bitmap_addr = 0x40 * state->m_video_regs[0x22]; |
| 376 | UINT32 bitmap_addr = 0x40 * m_video_regs[0x22]; |
| 374 | 377 | |
| 375 | 378 | tile = space.read_word((base_addr + 0) << 1); |
| 376 | 379 | x = space.read_word((base_addr + 1) << 1); |
| r20903 | r20904 | |
| 387 | 390 | return; |
| 388 | 391 | } |
| 389 | 392 | |
| 390 | | if(state->m_centered_coordinates) |
| 393 | if(m_centered_coordinates) |
| 391 | 394 | { |
| 392 | 395 | x = 160 + x; |
| 393 | 396 | y = 120 - y; |
| r20903 | r20904 | |
| 402 | 405 | x &= 0x01ff; |
| 403 | 406 | y &= 0x01ff; |
| 404 | 407 | |
| 405 | | vii_blit(machine, bitmap, cliprect, x, y, attr, 0, bitmap_addr, tile); |
| 408 | vii_blit(bitmap, cliprect, x, y, attr, 0, bitmap_addr, tile); |
| 406 | 409 | } |
| 407 | 410 | |
| 408 | | static void vii_blit_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth) |
| 411 | void vii_state::vii_blit_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth) |
| 409 | 412 | { |
| 410 | | vii_state *state = machine.driver_data<vii_state>(); |
| 411 | 413 | UINT32 n; |
| 412 | 414 | |
| 413 | | if (!(state->m_video_regs[0x42] & 1)) |
| 415 | if (!(m_video_regs[0x42] & 1)) |
| 414 | 416 | { |
| 415 | 417 | return; |
| 416 | 418 | } |
| r20903 | r20904 | |
| 419 | 421 | { |
| 420 | 422 | //if(space.read_word((0x2c00 + 4*n) << 1)) |
| 421 | 423 | { |
| 422 | | vii_blit_sprite(machine, bitmap, cliprect, depth, 0x2c00 + 4*n); |
| 424 | vii_blit_sprite(bitmap, cliprect, depth, 0x2c00 + 4*n); |
| 423 | 425 | } |
| 424 | 426 | } |
| 425 | 427 | } |
| r20903 | r20904 | |
| 434 | 436 | |
| 435 | 437 | for(i = 0; i < 4; i++) |
| 436 | 438 | { |
| 437 | | vii_blit_page(machine(), bitmap, cliprect, i, 0x40 * m_video_regs[0x20], m_video_regs + 0x10); |
| 438 | | vii_blit_page(machine(), bitmap, cliprect, i, 0x40 * m_video_regs[0x21], m_video_regs + 0x16); |
| 439 | | vii_blit_sprites(machine(), bitmap, cliprect, i); |
| 439 | vii_blit_page(bitmap, cliprect, i, 0x40 * m_video_regs[0x20], m_video_regs + 0x10); |
| 440 | vii_blit_page(bitmap, cliprect, i, 0x40 * m_video_regs[0x21], m_video_regs + 0x16); |
| 441 | vii_blit_sprites(bitmap, cliprect, i); |
| 440 | 442 | } |
| 441 | 443 | |
| 442 | 444 | for(y = 0; y < 240; y++) |