trunk/src/mame/includes/stv.h
| r20791 | r20792 | |
| 295 | 295 | INT32 u1, INT32 u2, INT32 slu1, INT32 slu2, INT32 *nu1, INT32 *nu2, |
| 296 | 296 | INT32 v1, INT32 v2, INT32 slv1, INT32 slv2, INT32 *nv1, INT32 *nv2, |
| 297 | 297 | INT32 _y1, INT32 y2); |
| 298 | void stv_vdp1_setup_shading_for_line(INT32 y, INT32 x1, INT32 x2, |
| 299 | INT32 r1, INT32 g1, INT32 b1, |
| 300 | INT32 r2, INT32 g2, INT32 b2); |
| 301 | void stv_vdp1_setup_shading_for_slope( |
| 302 | INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 *nx1, INT32 *nx2, |
| 303 | INT32 r1, INT32 r2, INT32 slr1, INT32 slr2, INT32 *nr1, INT32 *nr2, |
| 304 | INT32 g1, INT32 g2, INT32 slg1, INT32 slg2, INT32 *ng1, INT32 *ng2, |
| 305 | INT32 b1, INT32 b2, INT32 slb1, INT32 slb2, INT32 *nb1, INT32 *nb2, |
| 306 | INT32 _y1, INT32 y2); |
| 307 | UINT16 stv_vdp1_apply_gouraud_shading( int x, int y, UINT16 pix ); |
| 298 | 308 | void stv_vdp1_setup_shading(const struct spoint* q, const rectangle &cliprect); |
| 299 | 309 | UINT8 stv_read_gouraud_table( void ); |
| 310 | void stv_clear_gouraud_shading(void); |
| 311 | |
| 300 | 312 | void stv_clear_framebuffer( int which_framebuffer ); |
| 301 | 313 | void stv_vdp1_state_save_postload( void ); |
| 302 | 314 | int stv_vdp1_start ( void ); |
| 303 | 315 | |
| 316 | struct stv_vdp1_poly_scanline |
| 317 | { |
| 318 | INT32 x[2]; |
| 319 | INT32 b[2]; |
| 320 | INT32 g[2]; |
| 321 | INT32 r[2]; |
| 322 | INT32 db; |
| 323 | INT32 dg; |
| 324 | INT32 dr; |
| 325 | }; |
| 304 | 326 | |
| 327 | struct stv_vdp1_poly_scanline_data |
| 328 | { |
| 329 | INT32 sy, ey; |
| 330 | struct stv_vdp1_poly_scanline scanline[512]; |
| 331 | }; |
| 332 | |
| 333 | struct stv_vdp1_poly_scanline_data* stv_vdp1_shading_data; |
| 334 | |
| 335 | struct stv_vdp2_sprite_list |
| 336 | { |
| 337 | int CMDCTRL, CMDLINK, CMDPMOD, CMDCOLR, CMDSRCA, CMDSIZE, CMDGRDA; |
| 338 | int CMDXA, CMDYA; |
| 339 | int CMDXB, CMDYB; |
| 340 | int CMDXC, CMDYC; |
| 341 | int CMDXD, CMDYD; |
| 342 | |
| 343 | int ispoly; |
| 344 | |
| 345 | } stv2_current_sprite; |
| 346 | |
| 347 | /* Gouraud shading */ |
| 348 | |
| 349 | struct _stv_gouraud_shading |
| 350 | { |
| 351 | /* Gouraud shading table */ |
| 352 | UINT16 GA; |
| 353 | UINT16 GB; |
| 354 | UINT16 GC; |
| 355 | UINT16 GD; |
| 356 | } stv_gouraud_shading; |
| 357 | |
| 358 | UINT16 m_sprite_colorbank; |
| 359 | |
| 360 | /* VDP1 Framebuffer handling */ |
| 361 | int stv_sprite_priorities_used[8]; |
| 362 | int stv_sprite_priorities_usage_valid; |
| 363 | UINT8 stv_sprite_priorities_in_fb_line[512][8]; |
| 364 | |
| 365 | |
| 305 | 366 | /* VDP2 */ |
| 306 | 367 | |
| 307 | 368 | UINT8 get_vblank( void ); |
| r20791 | r20792 | |
| 333 | 394 | void stv_vdp2_copy_roz_bitmap(bitmap_rgb32 &bitmap, bitmap_rgb32 &roz_bitmap, const rectangle &cliprect, int iRP, int planesizex, int planesizey, int planerenderedsizex, int planerenderedsizey); |
| 334 | 395 | void stv_vdp2_fill_rotation_parameter_table( UINT8 rot_parameter ); |
| 335 | 396 | UINT8 stv_vdp2_check_vram_cycle_pattern_registers( UINT8 access_command_pnmdr, UINT8 access_command_cpdr, UINT8 bitmap_enable ); |
| 397 | UINT8 stv_vdp2_is_rotation_applied(void); |
| 398 | UINT8 stv_vdp2_are_map_registers_equal(void); |
| 399 | void stv_vdp2_get_map_page( int x, int y, int *_map, int *_page ); |
| 400 | |
| 336 | 401 | void stv_vdp2_draw_mosaic(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 is_roz); |
| 337 | | |
| 338 | 402 | void stv_vdp2_fade_effects( void ); |
| 339 | 403 | void stv_vdp2_compute_color_offset( int *r, int *g, int *b, int cor ); |
| 340 | 404 | void stv_vdp2_compute_color_offset_UINT32(UINT32 *rgb, int cor); |
| r20791 | r20792 | |
| 352 | 416 | void stv_vdp2_state_save_postload( void ); |
| 353 | 417 | void stv_vdp2_exit ( void ); |
| 354 | 418 | int stv_vdp2_start ( void ); |
| 419 | |
| 420 | UINT8 m_vdpdebug_roz; |
| 421 | |
| 422 | struct stv_vdp2_tilemap_capabilities |
| 423 | { |
| 424 | UINT8 enabled; |
| 425 | UINT8 transparency; |
| 426 | UINT8 colour_calculation_enabled; |
| 427 | UINT8 colour_depth; |
| 428 | UINT8 alpha; |
| 429 | UINT8 tile_size; |
| 430 | UINT8 bitmap_enable; |
| 431 | UINT8 bitmap_size; |
| 432 | UINT8 bitmap_palette_number; |
| 433 | UINT8 bitmap_map; |
| 434 | UINT16 map_offset[16]; |
| 435 | UINT8 map_count; |
| 436 | |
| 437 | UINT8 pattern_data_size; |
| 438 | UINT8 character_number_supplement; |
| 439 | UINT8 special_priority_register; |
| 440 | UINT8 special_colour_control_register; |
| 441 | UINT8 supplementary_palette_bits; |
| 442 | UINT8 supplementary_character_bits; |
| 443 | |
| 444 | INT16 scrollx; |
| 445 | INT16 scrolly; |
| 446 | UINT32 incx, incy; |
| 447 | |
| 448 | UINT8 linescroll_enable; |
| 449 | UINT8 linescroll_interval; |
| 450 | UINT32 linescroll_table_address; |
| 451 | UINT8 vertical_linescroll_enable; |
| 452 | UINT8 linezoom_enable; |
| 453 | |
| 454 | UINT8 plane_size; |
| 455 | UINT8 colour_ram_address_offset; |
| 456 | UINT8 fade_control; |
| 457 | UINT8 window_control; |
| 458 | |
| 459 | UINT8 line_screen_enabled; |
| 460 | UINT8 mosaic_screen_enabled; |
| 461 | |
| 462 | int layer_name; /* just to keep track */ |
| 463 | } stv2_current_tilemap; |
| 464 | |
| 465 | struct rotation_table |
| 466 | { |
| 467 | INT32 xst; |
| 468 | INT32 yst; |
| 469 | INT32 zst; |
| 470 | INT32 dxst; |
| 471 | INT32 dyst; |
| 472 | INT32 dx; |
| 473 | INT32 dy; |
| 474 | INT32 A; |
| 475 | INT32 B; |
| 476 | INT32 C; |
| 477 | INT32 D; |
| 478 | INT32 E; |
| 479 | INT32 F; |
| 480 | INT32 px; |
| 481 | INT32 py; |
| 482 | INT32 pz; |
| 483 | INT32 cx; |
| 484 | INT32 cy; |
| 485 | INT32 cz; |
| 486 | INT32 mx; |
| 487 | INT32 my; |
| 488 | INT32 kx; |
| 489 | INT32 ky; |
| 490 | UINT32 kast; |
| 491 | INT32 dkast; |
| 492 | INT32 dkax; |
| 493 | |
| 494 | } stv_current_rotation_parameter_table; |
| 495 | |
| 496 | struct _stv_vdp2_layer_data_placement |
| 497 | { |
| 498 | UINT32 map_offset_min; |
| 499 | UINT32 map_offset_max; |
| 500 | UINT32 tile_offset_min; |
| 501 | UINT32 tile_offset_max; |
| 502 | } stv_vdp2_layer_data_placement; |
| 503 | |
| 504 | struct _stv_rbg_cache_data |
| 505 | { |
| 506 | UINT8 watch_vdp2_vram_writes; |
| 507 | UINT8 is_cache_dirty; |
| 508 | |
| 509 | UINT32 map_offset_min[2]; |
| 510 | UINT32 map_offset_max[2]; |
| 511 | UINT32 tile_offset_min[2]; |
| 512 | UINT32 tile_offset_max[2]; |
| 513 | |
| 514 | struct stv_vdp2_tilemap_capabilities layer_data[2]; |
| 515 | |
| 516 | } stv_rbg_cache_data; |
| 517 | |
| 518 | |
| 355 | 519 | }; |
| 356 | 520 | |
| 357 | 521 | #define MASTER_CLOCK_352 57272720 |
trunk/src/mame/video/stvvdp1.c
| r20791 | r20792 | |
| 18 | 18 | |
| 19 | 19 | #define VDP1_LOG 0 |
| 20 | 20 | |
| 21 | | struct stv_vdp1_poly_scanline |
| 22 | | { |
| 23 | | INT32 x[2]; |
| 24 | | INT32 b[2]; |
| 25 | | INT32 g[2]; |
| 26 | | INT32 r[2]; |
| 27 | | INT32 db; |
| 28 | | INT32 dg; |
| 29 | | INT32 dr; |
| 30 | | }; |
| 31 | 21 | |
| 32 | | struct stv_vdp1_poly_scanline_data |
| 33 | | { |
| 34 | | INT32 sy, ey; |
| 35 | | struct stv_vdp1_poly_scanline scanline[512]; |
| 36 | | }; |
| 37 | | |
| 38 | | static struct stv_vdp1_poly_scanline_data* stv_vdp1_shading_data; |
| 39 | | |
| 40 | 22 | enum { FRAC_SHIFT = 16 }; |
| 41 | 23 | |
| 42 | 24 | struct spoint { |
| r20791 | r20792 | |
| 501 | 483 | |
| 502 | 484 | */ |
| 503 | 485 | |
| 504 | | static struct stv_vdp2_sprite_list |
| 486 | void saturn_state::stv_clear_gouraud_shading(void) |
| 505 | 487 | { |
| 506 | | int CMDCTRL, CMDLINK, CMDPMOD, CMDCOLR, CMDSRCA, CMDSIZE, CMDGRDA; |
| 507 | | int CMDXA, CMDYA; |
| 508 | | int CMDXB, CMDYB; |
| 509 | | int CMDXC, CMDYC; |
| 510 | | int CMDXD, CMDYD; |
| 511 | | |
| 512 | | int ispoly; |
| 513 | | |
| 514 | | } stv2_current_sprite; |
| 515 | | |
| 516 | | /* Gouraud shading */ |
| 517 | | |
| 518 | | static struct _stv_gouraud_shading |
| 519 | | { |
| 520 | | /* Gouraud shading table */ |
| 521 | | UINT16 GA; |
| 522 | | UINT16 GB; |
| 523 | | UINT16 GC; |
| 524 | | UINT16 GD; |
| 525 | | } stv_gouraud_shading; |
| 526 | | |
| 527 | | static void stv_clear_gouraud_shading(void) |
| 528 | | { |
| 529 | 488 | memset( &stv_gouraud_shading, 0, sizeof( stv_gouraud_shading ) ); |
| 530 | 489 | } |
| 531 | 490 | |
| r20791 | r20792 | |
| 559 | 518 | return color; |
| 560 | 519 | } |
| 561 | 520 | |
| 562 | | static UINT16 stv_vdp1_apply_gouraud_shading( int x, int y, UINT16 pix ) |
| 521 | UINT16 saturn_state::stv_vdp1_apply_gouraud_shading( int x, int y, UINT16 pix ) |
| 563 | 522 | { |
| 564 | 523 | INT32 r,g,b, msb; |
| 565 | 524 | |
| r20791 | r20792 | |
| 589 | 548 | return msb | b << 10 | g << 5 | r; |
| 590 | 549 | } |
| 591 | 550 | |
| 592 | | static void stv_vdp1_setup_shading_for_line(INT32 y, INT32 x1, INT32 x2, |
| 551 | void saturn_state::stv_vdp1_setup_shading_for_line(INT32 y, INT32 x1, INT32 x2, |
| 593 | 552 | INT32 r1, INT32 g1, INT32 b1, |
| 594 | 553 | INT32 r2, INT32 g2, INT32 b2) |
| 595 | 554 | { |
| r20791 | r20792 | |
| 643 | 602 | } |
| 644 | 603 | } |
| 645 | 604 | |
| 646 | | static void stv_vdp1_setup_shading_for_slope( |
| 605 | void saturn_state::stv_vdp1_setup_shading_for_slope( |
| 647 | 606 | INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 *nx1, INT32 *nx2, |
| 648 | 607 | INT32 r1, INT32 r2, INT32 slr1, INT32 slr2, INT32 *nr1, INT32 *nr2, |
| 649 | 608 | INT32 g1, INT32 g2, INT32 slg1, INT32 slg2, INT32 *ng1, INT32 *ng2, |
| r20791 | r20792 | |
| 866 | 825 | and if we skip the drawing the content could be incorrect when it reads it, although i have no idea |
| 867 | 826 | why they would want to */ |
| 868 | 827 | |
| 869 | | static UINT8* gfxdata; |
| 870 | | static UINT16 sprite_colorbank; |
| 871 | 828 | |
| 872 | | |
| 873 | 829 | static void (*drawpixel)(running_machine &machine, int x, int y, int patterndata, int offsetcnt); |
| 874 | 830 | |
| 875 | 831 | static void drawpixel_poly(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| r20791 | r20792 | |
| 880 | 836 | if(x >= 1024 || y >= 512) |
| 881 | 837 | return; |
| 882 | 838 | |
| 883 | | state->m_vdp1.framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR; |
| 839 | state->m_vdp1.framebuffer_draw_lines[y][x] = state->stv2_current_sprite.CMDCOLR; |
| 884 | 840 | } |
| 885 | 841 | |
| 886 | 842 | static void drawpixel_8bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| r20791 | r20792 | |
| 888 | 844 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 889 | 845 | UINT16 pix; |
| 890 | 846 | |
| 891 | | pix = gfxdata[patterndata+offsetcnt]; |
| 847 | pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt]; |
| 892 | 848 | if ( pix & 0xff ) |
| 893 | 849 | { |
| 894 | | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 850 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank; |
| 895 | 851 | } |
| 896 | 852 | } |
| 897 | 853 | |
| r20791 | r20792 | |
| 900 | 856 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 901 | 857 | UINT16 pix; |
| 902 | 858 | |
| 903 | | pix = gfxdata[patterndata+offsetcnt/2]; |
| 859 | pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt/2]; |
| 904 | 860 | pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ; |
| 905 | | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 861 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank; |
| 906 | 862 | } |
| 907 | 863 | |
| 908 | 864 | static void drawpixel_4bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| r20791 | r20792 | |
| 910 | 866 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 911 | 867 | UINT16 pix; |
| 912 | 868 | |
| 913 | | pix = gfxdata[patterndata+offsetcnt/2]; |
| 869 | pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt/2]; |
| 914 | 870 | pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ; |
| 915 | 871 | if ( pix ) |
| 916 | | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 872 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank; |
| 917 | 873 | } |
| 918 | 874 | |
| 919 | 875 | static void drawpixel_generic(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 920 | 876 | { |
| 921 | 877 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 922 | | int pix,mode,transmask, spd = stv2_current_sprite.CMDPMOD & 0x40; |
| 923 | | int mesh = stv2_current_sprite.CMDPMOD & 0x100; |
| 878 | int pix,mode,transmask, spd = state->stv2_current_sprite.CMDPMOD & 0x40; |
| 879 | int mesh = state->stv2_current_sprite.CMDPMOD & 0x100; |
| 924 | 880 | int pix2; |
| 925 | 881 | |
| 926 | 882 | if ( mesh && !((x ^ y) & 1) ) |
| r20791 | r20792 | |
| 928 | 884 | return; |
| 929 | 885 | } |
| 930 | 886 | |
| 931 | | if ( stv2_current_sprite.ispoly ) |
| 887 | if ( state->stv2_current_sprite.ispoly ) |
| 932 | 888 | { |
| 933 | | pix = stv2_current_sprite.CMDCOLR&0xffff; |
| 889 | pix = state->stv2_current_sprite.CMDCOLR&0xffff; |
| 934 | 890 | |
| 935 | 891 | transmask = 0xffff; |
| 936 | 892 | if ( pix & 0x8000 ) |
| r20791 | r20792 | |
| 944 | 900 | } |
| 945 | 901 | else |
| 946 | 902 | { |
| 947 | | switch (stv2_current_sprite.CMDPMOD&0x0038) |
| 903 | switch (state->stv2_current_sprite.CMDPMOD&0x0038) |
| 948 | 904 | { |
| 949 | 905 | case 0x0000: // mode 0 16 colour bank mode (4bits) (hanagumi blocks) |
| 950 | 906 | // most of the shienryu sprites use this mode |
| 951 | | pix = gfxdata[(patterndata+offsetcnt/2) & 0xfffff]; |
| 907 | pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff]; |
| 952 | 908 | pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ; |
| 953 | | pix = pix+((stv2_current_sprite.CMDCOLR&0xfff0)); |
| 909 | pix = pix+((state->stv2_current_sprite.CMDCOLR&0xfff0)); |
| 954 | 910 | mode = 0; |
| 955 | 911 | transmask = 0xf; |
| 956 | 912 | break; |
| 957 | 913 | case 0x0008: // mode 1 16 colour lookup table mode (4bits) |
| 958 | 914 | // shienryu explosisons (and some enemies) use this mode |
| 959 | | pix2 = gfxdata[(patterndata+offsetcnt/2) & 0xfffff]; |
| 915 | pix2 = state->m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff]; |
| 960 | 916 | pix2 = offsetcnt&1 ? (pix2 & 0x0f):((pix2 & 0xf0)>>4); |
| 961 | 917 | pix = pix2&1 ? |
| 962 | | ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0): |
| 963 | | ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16); |
| 918 | ((((state->m_vdp1_vram[(((state->stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0): |
| 919 | ((((state->m_vdp1_vram[(((state->stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16); |
| 964 | 920 | |
| 965 | 921 | mode = 5; |
| 966 | 922 | transmask = 0xffff; |
| r20791 | r20792 | |
| 978 | 934 | } |
| 979 | 935 | break; |
| 980 | 936 | case 0x0010: // mode 2 64 colour bank mode (8bits) (character select portraits on hanagumi) |
| 981 | | pix = gfxdata[(patterndata+offsetcnt) & 0xfffff]; |
| 937 | pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff]; |
| 982 | 938 | mode = 2; |
| 983 | | pix = pix+(stv2_current_sprite.CMDCOLR&0xffc0); |
| 939 | pix = pix+(state->stv2_current_sprite.CMDCOLR&0xffc0); |
| 984 | 940 | transmask = 0x3f; |
| 985 | 941 | break; |
| 986 | 942 | case 0x0018: // mode 3 128 colour bank mode (8bits) (little characters on hanagumi use this mode) |
| 987 | | pix = gfxdata[(patterndata+offsetcnt) & 0xfffff]; |
| 988 | | pix = pix+(stv2_current_sprite.CMDCOLR&0xff80); |
| 943 | pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff]; |
| 944 | pix = pix+(state->stv2_current_sprite.CMDCOLR&0xff80); |
| 989 | 945 | transmask = 0x7f; |
| 990 | 946 | mode = 3; |
| 991 | 947 | break; |
| 992 | 948 | case 0x0020: // mode 4 256 colour bank mode (8bits) (hanagumi title) |
| 993 | | pix = gfxdata[(patterndata+offsetcnt) & 0xfffff]; |
| 994 | | pix = pix+(stv2_current_sprite.CMDCOLR&0xff00); |
| 949 | pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff]; |
| 950 | pix = pix+(state->stv2_current_sprite.CMDCOLR&0xff00); |
| 995 | 951 | transmask = 0xff; |
| 996 | 952 | mode = 4; |
| 997 | 953 | break; |
| 998 | 954 | case 0x0028: // mode 5 32,768 colour RGB mode (16bits) |
| 999 | | pix = gfxdata[(patterndata+offsetcnt*2+1) & 0xfffff] | (gfxdata[(patterndata+offsetcnt*2) & 0xfffff]<<8) ; |
| 955 | pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt*2+1) & 0xfffff] | (state->m_vdp1.gfx_decode[(patterndata+offsetcnt*2) & 0xfffff]<<8) ; |
| 1000 | 956 | mode = 5; |
| 1001 | 957 | transmask = -1; /* TODO: check me */ |
| 1002 | 958 | break; |
| r20791 | r20792 | |
| 1009 | 965 | |
| 1010 | 966 | |
| 1011 | 967 | // preliminary end code disable support |
| 1012 | | if ( ((stv2_current_sprite.CMDPMOD & 0x80) == 0) && |
| 968 | if ( ((state->stv2_current_sprite.CMDPMOD & 0x80) == 0) && |
| 1013 | 969 | ((pix & transmask) == transmask) ) |
| 1014 | 970 | { |
| 1015 | 971 | return; |
| r20791 | r20792 | |
| 1017 | 973 | } |
| 1018 | 974 | |
| 1019 | 975 | /* MSBON */ |
| 1020 | | pix |= stv2_current_sprite.CMDPMOD & 0x8000; |
| 976 | pix |= state->stv2_current_sprite.CMDPMOD & 0x8000; |
| 1021 | 977 | if ( mode != 5 ) |
| 1022 | 978 | { |
| 1023 | 979 | if ( (pix & transmask) || spd ) |
| r20791 | r20792 | |
| 1029 | 985 | { |
| 1030 | 986 | if ( (pix & transmask) || spd ) |
| 1031 | 987 | { |
| 1032 | | switch( stv2_current_sprite.CMDPMOD & 0x7 ) |
| 988 | switch( state->stv2_current_sprite.CMDPMOD & 0x7 ) |
| 1033 | 989 | { |
| 1034 | 990 | case 0: /* replace */ |
| 1035 | 991 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| r20791 | r20792 | |
| 1054 | 1010 | } |
| 1055 | 1011 | break; |
| 1056 | 1012 | case 4: /* Gouraud shading */ |
| 1057 | | state->m_vdp1.framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix ); |
| 1013 | state->m_vdp1.framebuffer_draw_lines[y][x] = state->stv_vdp1_apply_gouraud_shading( x, y, pix ); |
| 1058 | 1014 | break; |
| 1059 | 1015 | default: |
| 1060 | 1016 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| r20791 | r20792 | |
| 1073 | 1029 | int mesh = stv2_current_sprite.CMDPMOD & 0x100; |
| 1074 | 1030 | int ecd = stv2_current_sprite.CMDPMOD & 0x80; |
| 1075 | 1031 | |
| 1076 | | gfxdata = m_vdp1.gfx_decode; |
| 1077 | | |
| 1078 | 1032 | if ( mesh || !ecd || ((stv2_current_sprite.CMDPMOD & 0x7) != 0) ) |
| 1079 | 1033 | { |
| 1080 | 1034 | drawpixel = drawpixel_generic; |
| r20791 | r20792 | |
| 1087 | 1041 | } |
| 1088 | 1042 | else if ( (sprite_mode == 0x20) && !spd ) |
| 1089 | 1043 | { |
| 1090 | | sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xff00); |
| 1044 | m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xff00); |
| 1091 | 1045 | drawpixel = drawpixel_8bpp_trans; |
| 1092 | 1046 | } |
| 1093 | 1047 | else if ((sprite_mode == 0x00) && spd) |
| 1094 | 1048 | { |
| 1095 | | sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0); |
| 1049 | m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0); |
| 1096 | 1050 | drawpixel = drawpixel_4bpp_notrans; |
| 1097 | 1051 | } |
| 1098 | 1052 | else if (sprite_mode == 0x00 && !spd ) |
| 1099 | 1053 | { |
| 1100 | | sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0); |
| 1054 | m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0); |
| 1101 | 1055 | drawpixel = drawpixel_4bpp_trans; |
| 1102 | 1056 | } |
| 1103 | 1057 | else |
trunk/src/mame/video/stvvdp2.c
| r20791 | r20792 | |
| 2081 | 2081 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2082 | 2082 | #define STV_VDP2_COBB (m_vdp2_regs[0x11e/2]) |
| 2083 | 2083 | |
| 2084 | | /*For Debug purposes only*/ |
| 2085 | | static struct stv_vdp2_debugging |
| 2086 | | { |
| 2087 | | UINT8 l_en; /*For Layer enable/disable*/ |
| 2088 | | UINT8 win; /*Enters into Window effect debug menu*/ |
| 2089 | | UINT32 error; /*bits for VDP2 error logging*/ |
| 2090 | | UINT8 roz; /*Debug roz on screen*/ |
| 2091 | | } vdpdebug; |
| 2092 | 2084 | |
| 2093 | | /* Not sure if to use this for the rotating tilemaps as well or just use different draw functions, might add too much bloat */ |
| 2094 | | static struct stv_vdp2_tilemap_capabilities |
| 2095 | | { |
| 2096 | | UINT8 enabled; |
| 2097 | | UINT8 transparency; |
| 2098 | | UINT8 colour_calculation_enabled; |
| 2099 | | UINT8 colour_depth; |
| 2100 | | UINT8 alpha; |
| 2101 | | UINT8 tile_size; |
| 2102 | | UINT8 bitmap_enable; |
| 2103 | | UINT8 bitmap_size; |
| 2104 | | UINT8 bitmap_palette_number; |
| 2105 | | UINT8 bitmap_map; |
| 2106 | | UINT16 map_offset[16]; |
| 2107 | | UINT8 map_count; |
| 2108 | | |
| 2109 | | UINT8 pattern_data_size; |
| 2110 | | UINT8 character_number_supplement; |
| 2111 | | UINT8 special_priority_register; |
| 2112 | | UINT8 special_colour_control_register; |
| 2113 | | UINT8 supplementary_palette_bits; |
| 2114 | | UINT8 supplementary_character_bits; |
| 2115 | | |
| 2116 | | INT16 scrollx; |
| 2117 | | INT16 scrolly; |
| 2118 | | UINT32 incx, incy; |
| 2119 | | |
| 2120 | | UINT8 linescroll_enable; |
| 2121 | | UINT8 linescroll_interval; |
| 2122 | | UINT32 linescroll_table_address; |
| 2123 | | UINT8 vertical_linescroll_enable; |
| 2124 | | UINT8 linezoom_enable; |
| 2125 | | |
| 2126 | | UINT8 plane_size; |
| 2127 | | UINT8 colour_ram_address_offset; |
| 2128 | | UINT8 fade_control; |
| 2129 | | UINT8 window_control; |
| 2130 | | |
| 2131 | | UINT8 line_screen_enabled; |
| 2132 | | UINT8 mosaic_screen_enabled; |
| 2133 | | |
| 2134 | | // UINT8 real_map_offset[16]; |
| 2135 | | |
| 2136 | | int layer_name; /* just to keep track */ |
| 2137 | | } stv2_current_tilemap; |
| 2138 | | |
| 2139 | 2085 | #define STV_VDP2_RBG_ROTATION_PARAMETER_A 1 |
| 2140 | 2086 | #define STV_VDP2_RBG_ROTATION_PARAMETER_B 2 |
| 2141 | 2087 | |
| 2142 | | static struct rotation_table |
| 2143 | | { |
| 2144 | | INT32 xst; |
| 2145 | | INT32 yst; |
| 2146 | | INT32 zst; |
| 2147 | | INT32 dxst; |
| 2148 | | INT32 dyst; |
| 2149 | | INT32 dx; |
| 2150 | | INT32 dy; |
| 2151 | | INT32 A; |
| 2152 | | INT32 B; |
| 2153 | | INT32 C; |
| 2154 | | INT32 D; |
| 2155 | | INT32 E; |
| 2156 | | INT32 F; |
| 2157 | | INT32 px; |
| 2158 | | INT32 py; |
| 2159 | | INT32 pz; |
| 2160 | | INT32 cx; |
| 2161 | | INT32 cy; |
| 2162 | | INT32 cz; |
| 2163 | | INT32 mx; |
| 2164 | | INT32 my; |
| 2165 | | INT32 kx; |
| 2166 | | INT32 ky; |
| 2167 | | UINT32 kast; |
| 2168 | | INT32 dkast; |
| 2169 | | INT32 dkax; |
| 2170 | 2088 | |
| 2171 | | } stv_current_rotation_parameter_table; |
| 2172 | | |
| 2173 | | static struct _stv_vdp2_layer_data_placement |
| 2174 | | { |
| 2175 | | UINT32 map_offset_min; |
| 2176 | | UINT32 map_offset_max; |
| 2177 | | UINT32 tile_offset_min; |
| 2178 | | UINT32 tile_offset_max; |
| 2179 | | } stv_vdp2_layer_data_placement; |
| 2180 | | |
| 2181 | | static struct _stv_rbg_cache_data |
| 2182 | | { |
| 2183 | | UINT8 watch_vdp2_vram_writes; |
| 2184 | | UINT8 is_cache_dirty; |
| 2185 | | |
| 2186 | | UINT32 map_offset_min[2]; |
| 2187 | | UINT32 map_offset_max[2]; |
| 2188 | | UINT32 tile_offset_min[2]; |
| 2189 | | UINT32 tile_offset_max[2]; |
| 2190 | | |
| 2191 | | struct stv_vdp2_tilemap_capabilities layer_data[2]; |
| 2192 | | |
| 2193 | | } stv_rbg_cache_data; |
| 2194 | | |
| 2195 | 2089 | #define mul_fixed32( a, b ) mul_32x32_shift( a, b, 16 ) |
| 2196 | 2090 | |
| 2197 | 2091 | void saturn_state::stv_vdp2_fill_rotation_parameter_table( UINT8 rot_parameter ) |
| r20791 | r20792 | |
| 2251 | 2145 | if(LOG_ROZ == 1) logerror( "kast = %x, dkast = %x, dkax = %x\n", RP.kast, RP.dkast, RP.dkax ); |
| 2252 | 2146 | |
| 2253 | 2147 | /*Attempt to show on screen the rotation table*/ |
| 2148 | #if 0 |
| 2254 | 2149 | if(LOG_ROZ == 2) |
| 2255 | 2150 | { |
| 2256 | 2151 | if(machine().input().code_pressed_once(JOYCODE_Y_UP_SWITCH)) |
| 2257 | | vdpdebug.roz++; |
| 2152 | m_vdpdebug_roz++; |
| 2258 | 2153 | |
| 2259 | 2154 | if(machine().input().code_pressed_once(JOYCODE_Y_DOWN_SWITCH)) |
| 2260 | | vdpdebug.roz--; |
| 2155 | m_vdpdebug_roz--; |
| 2261 | 2156 | |
| 2262 | | if(vdpdebug.roz > 10) |
| 2263 | | vdpdebug.roz = 10; |
| 2157 | if(m_vdpdebug_roz > 10) |
| 2158 | m_vdpdebug_roz = 10; |
| 2264 | 2159 | |
| 2265 | | switch(vdpdebug.roz) |
| 2160 | switch(m_vdpdebug_roz) |
| 2266 | 2161 | { |
| 2267 | 2162 | case 0: popmessage( "Rotation parameter Table (%d)", rot_parameter ); break; |
| 2268 | 2163 | case 1: popmessage( "xst = %x, yst = %x, zst = %x", RP.xst, RP.yst, RP.zst ); break; |
| r20791 | r20792 | |
| 2277 | 2172 | case 10: break; |
| 2278 | 2173 | } |
| 2279 | 2174 | } |
| 2175 | #endif |
| 2280 | 2176 | } |
| 2281 | 2177 | |
| 2282 | 2178 | /* check if RGB layer has rotation applied */ |
| 2283 | | static UINT8 stv_vdp2_is_rotation_applied(void) |
| 2179 | UINT8 saturn_state::stv_vdp2_is_rotation_applied(void) |
| 2284 | 2180 | { |
| 2285 | 2181 | #define _FIXED_1 (0x00010000) |
| 2286 | 2182 | #define _FIXED_0 (0x00000000) |
| r20791 | r20792 | |
| 2306 | 2202 | } |
| 2307 | 2203 | } |
| 2308 | 2204 | |
| 2309 | | static UINT8 stv_vdp2_are_map_registers_equal(void) |
| 2205 | UINT8 saturn_state::stv_vdp2_are_map_registers_equal(void) |
| 2310 | 2206 | { |
| 2311 | 2207 | int i; |
| 2312 | 2208 | |
| r20791 | r20792 | |
| 3522 | 3418 | |
| 3523 | 3419 | */ |
| 3524 | 3420 | |
| 3525 | | static void stv_vdp2_get_map_page( int x, int y, int *_map, int *_page ) |
| 3421 | void saturn_state::stv_vdp2_get_map_page( int x, int y, int *_map, int *_page ) |
| 3526 | 3422 | { |
| 3527 | 3423 | int page = 0; |
| 3528 | 3424 | int map = 0; |
| r20791 | r20792 | |
| 6004 | 5900 | machine().primary_screen->register_screen_bitmap(m_tmpbitmap); |
| 6005 | 5901 | stv_vdp2_start(); |
| 6006 | 5902 | stv_vdp1_start(); |
| 6007 | | vdpdebug.l_en = 0xff; |
| 6008 | | vdpdebug.error = 0xffffffff; |
| 6009 | | vdpdebug.roz = 0; |
| 5903 | m_vdpdebug_roz = 0; |
| 6010 | 5904 | machine().gfx[0]->set_source(m_vdp2.gfx_decode); |
| 6011 | 5905 | machine().gfx[1]->set_source(m_vdp2.gfx_decode); |
| 6012 | 5906 | machine().gfx[2]->set_source(m_vdp2.gfx_decode); |
| r20791 | r20792 | |
| 6312 | 6206 | } |
| 6313 | 6207 | } |
| 6314 | 6208 | |
| 6315 | | /* VDP1 Framebuffer handling */ |
| 6316 | | static int stv_sprite_priorities_used[8]; |
| 6317 | | static int stv_sprite_priorities_usage_valid; |
| 6318 | | static UINT8 stv_sprite_priorities_in_fb_line[512][8]; |
| 6319 | | |
| 6320 | 6209 | void saturn_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 pri) |
| 6321 | 6210 | { |
| 6322 | 6211 | int x,y,r,g,b; |