src/mame/machine/snes.c
| r5379 | r5380 | |
| 738 | 738 | snes_ppu.update_offsets = 1; |
| 739 | 739 | break; |
| 740 | 740 | case MOSAIC: /* Size and screen designation for mosaic */ |
| 741 | | /* FIXME: We don't support horizontal mosaic yet */ |
| 741 | /* FIXME: We support horizontal mosaic only partially */ |
| 742 | 742 | snes_ppu.mosaic_size = (data & 0xf0) >> 4; |
| 743 | 743 | snes_ppu.layer[0].mosaic_enabled = data & 0x01; |
| 744 | 744 | snes_ppu.layer[1].mosaic_enabled = data & 0x02; |
| r5379 | r5380 | |
| 939 | 939 | break; |
| 940 | 940 | case TM: /* Main screen designation */ |
| 941 | 941 | case TS: /* Subscreen designation */ |
| 942 | break; |
| 942 | 943 | case TMW: /* Window mask for main screen designation */ |
| 944 | snes_ppu.layer[0].main_window_enabled = data & 0x01; |
| 945 | snes_ppu.layer[1].main_window_enabled = data & 0x02; |
| 946 | snes_ppu.layer[2].main_window_enabled = data & 0x04; |
| 947 | snes_ppu.layer[3].main_window_enabled = data & 0x08; |
| 948 | snes_ppu.layer[4].main_window_enabled = data & 0x10; |
| 949 | break; |
| 943 | 950 | case TSW: /* Window mask for subscreen designation */ |
| 951 | snes_ppu.layer[0].sub_window_enabled = data & 0x01; |
| 952 | snes_ppu.layer[1].sub_window_enabled = data & 0x02; |
| 953 | snes_ppu.layer[2].sub_window_enabled = data & 0x04; |
| 954 | snes_ppu.layer[3].sub_window_enabled = data & 0x08; |
| 955 | snes_ppu.layer[4].sub_window_enabled = data & 0x10; |
| 944 | 956 | break; |
| 945 | 957 | case CGWSEL: /* Initial settings for Fixed colour addition or screen addition */ |
| 946 | 958 | /* FIXME: We don't support direct select for modes 3 & 4 or subscreen window stuff */ |
| r5379 | r5380 | |
| 1021 | 1033 | // external latch |
| 1022 | 1034 | snes_latch_counters(space->machine); |
| 1023 | 1035 | } |
| 1036 | break; |
| 1024 | 1037 | case WRMPYA: /* Multiplier A */ |
| 1025 | 1038 | break; |
| 1026 | 1039 | case WRMPYB: /* Multiplier B */ |
src/mame/video/snes.c
| r5379 | r5380 | |
| 228 | 228 | *****************************************/ |
| 229 | 229 | INLINE void snes_draw_tile(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) |
| 230 | 230 | { |
| 231 | | UINT8 mask, plane[8]; |
| 231 | UINT8 mask, plane[8], window_enabled = 0; |
| 232 | 232 | UINT16 c; |
| 233 | 233 | INT16 ii, jj; |
| 234 | 234 | |
| r5379 | r5380 | |
| 265 | 265 | if(!debug_options.windows_disabled) |
| 266 | 266 | #endif /* MAME_DEBUG */ |
| 267 | 267 | /* Clip to windows */ |
| 268 | | if ((screen == MAINSCREEN && (snes_ram[TMW] & (0x1 << layer))) || (screen == SUBSCREEN && (snes_ram[TSW] & (0x1 << layer)))) |
| 268 | window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 269 | if (window_enabled) |
| 269 | 270 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 270 | 271 | |
| 271 | 272 | /* Only draw if we have a colour (0 == transparent) */ |
| r5379 | r5380 | |
| 324 | 325 | * The same as snes_draw_tile_4() except |
| 325 | 326 | * that it takes a blend parameter. |
| 326 | 327 | *****************************************/ |
| 327 | | INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) |
| 328 | INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend, UINT8 wide ) |
| 328 | 329 | { |
| 329 | | UINT8 mask, plane[4]; |
| 330 | UINT8 mask, plane[4], window_enabled = 0; |
| 330 | 331 | UINT16 c; |
| 331 | 332 | INT16 ii; |
| 333 | UINT8 x_shift = wide ? 1 : 0; |
| 334 | UINT8 size = wide ? 16 : 8; |
| 335 | UINT8 step = wide ? 1 : 0; |
| 332 | 336 | |
| 333 | 337 | plane[0] = snes_vram[tileaddr]; |
| 334 | 338 | plane[1] = snes_vram[tileaddr + 1]; |
| 335 | 339 | plane[2] = snes_vram[tileaddr + 16]; |
| 336 | 340 | plane[3] = snes_vram[tileaddr + 17]; |
| 337 | 341 | |
| 338 | | if( flip ) |
| 339 | | mask = 0x1; |
| 342 | if (flip) |
| 343 | mask = 0x01; |
| 340 | 344 | else |
| 341 | 345 | mask = 0x80; |
| 342 | 346 | |
| 343 | | for( ii = x; ii < (x + 8); ii++ ) |
| 347 | x <<= x_shift; |
| 348 | for (ii = x; ii < (x + size); ii += 1 + step) |
| 344 | 349 | { |
| 345 | 350 | UINT8 colour; |
| 346 | | if( flip ) |
| 351 | if (flip) |
| 347 | 352 | { |
| 348 | 353 | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| 349 | 354 | (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0); |
| r5379 | r5380 | |
| 357 | 362 | } |
| 358 | 363 | |
| 359 | 364 | #ifdef MAME_DEBUG |
| 360 | | if( !debug_options.windows_disabled ) |
| 365 | if (!debug_options.windows_disabled) |
| 361 | 366 | #endif /* MAME_DEBUG */ |
| 362 | 367 | /* Clip to windows */ |
| 363 | | if( (screen == MAINSCREEN && (snes_ram[TMW] & 0x10)) || (screen == SUBSCREEN && (snes_ram[TSW] & 0x10))) |
| 368 | window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[4].sub_window_enabled; |
| 369 | if (window_enabled) |
| 364 | 370 | colour &= snes_ppu.clipmasks[4][ii]; |
| 365 | 371 | |
| 366 | 372 | /* Only draw if we have a colour (0 == transparent) */ |
| 367 | | if( colour ) |
| 373 | if (colour) |
| 368 | 374 | { |
| 369 | | if( ii >= 0 ) |
| 375 | if (ii >= 0) |
| 370 | 376 | { |
| 371 | 377 | c = snes_cgram[pal + colour]; |
| 372 | | if( blend && screen == MAINSCREEN ) /* Only blend main screens */ |
| 378 | if (blend && screen == MAINSCREEN) /* Only blend main screens */ |
| 373 | 379 | snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4); |
| 374 | 380 | |
| 375 | 381 | scanlines[screen].buffer[ii] = c; |
| 376 | 382 | scanlines[screen].zbuf[ii] = priority; |
| 383 | if (wide) |
| 384 | { |
| 385 | scanlines[screen].buffer[ii + 1] = c; |
| 386 | scanlines[screen].zbuf[ii + 1] = priority; |
| 387 | } |
| 377 | 388 | } |
| 378 | 389 | } |
| 379 | 390 | } |
| 380 | 391 | } |
| 381 | 392 | |
| 382 | | /***************************************** |
| 383 | | * snes_draw_tile_object_w() |
| 384 | | * |
| 385 | | * Draw tiles with 4 bit planes(16 colors) |
| 386 | | * The same as snes_draw_tile_4() except |
| 387 | | * that it takes a blend parameter. |
| 388 | | * Wide version. |
| 389 | | *****************************************/ |
| 390 | | INLINE void snes_draw_tile_object_w(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) |
| 391 | | { |
| 392 | | UINT8 mask, plane[4]; |
| 393 | | UINT16 c; |
| 394 | | INT16 ii; |
| 395 | | |
| 396 | | plane[0] = snes_vram[tileaddr]; |
| 397 | | plane[1] = snes_vram[tileaddr + 1]; |
| 398 | | plane[2] = snes_vram[tileaddr + 16]; |
| 399 | | plane[3] = snes_vram[tileaddr + 17]; |
| 400 | | |
| 401 | | if( flip ) |
| 402 | | mask = 0x1; |
| 403 | | else |
| 404 | | mask = 0x80; |
| 405 | | |
| 406 | | x <<= 1; |
| 407 | | for( ii = x; ii < (x + 16); ii += 2 ) |
| 408 | | { |
| 409 | | UINT8 colour; |
| 410 | | if( flip ) |
| 411 | | { |
| 412 | | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| 413 | | (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0); |
| 414 | | mask <<= 1; |
| 415 | | } |
| 416 | | else |
| 417 | | { |
| 418 | | colour = (plane[0] & mask ? 1 : 0) | (plane[1] & mask ? 2 : 0) | |
| 419 | | (plane[2] & mask ? 4 : 0) | (plane[3] & mask ? 8 : 0); |
| 420 | | mask >>= 1; |
| 421 | | } |
| 422 | | |
| 423 | | #ifdef MAME_DEBUG |
| 424 | | if( !debug_options.windows_disabled ) |
| 425 | | #endif /* MAME_DEBUG */ |
| 426 | | /* Clip to windows */ |
| 427 | | if( (screen == MAINSCREEN && (snes_ram[TMW] & 0x10)) || (screen == SUBSCREEN && (snes_ram[TSW] & 0x10))) |
| 428 | | colour &= snes_ppu.clipmasks[4][ii]; |
| 429 | | |
| 430 | | /* Only draw if we have a colour (0 == transparent) */ |
| 431 | | if( colour ) |
| 432 | | { |
| 433 | | if( ii >= 0 ) |
| 434 | | { |
| 435 | | c = snes_cgram[pal + colour]; |
| 436 | | if( blend && screen == MAINSCREEN ) /* Only blend main screens */ |
| 437 | | snes_draw_blend(ii, &c, snes_ppu.layer[4].blend, (snes_ram[CGWSEL] & 0x30) >> 4); |
| 438 | | |
| 439 | | scanlines[screen].buffer[ii] = c; |
| 440 | | scanlines[screen].zbuf[ii] = priority; |
| 441 | | scanlines[screen].buffer[ii + 1] = c; |
| 442 | | scanlines[screen].zbuf[ii + 1] = priority; |
| 443 | | } |
| 444 | | } |
| 445 | | } |
| 446 | | } |
| 447 | | |
| 448 | 393 | /********************************************* |
| 449 | 394 | * snes_update_line() |
| 450 | 395 | * |
| r5379 | r5380 | |
| 741 | 686 | UINT16 clr; |
| 742 | 687 | /* Direct select, but only outside EXTBG! */ |
| 743 | 688 | if (snes_ppu.direct_color && layer == 1) |
| 744 | | clr = ((colour & 0x7) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 689 | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 745 | 690 | else |
| 746 | 691 | clr = snes_cgram[colour]; |
| 747 | 692 | /* Only blend main screens */ |
| r5379 | r5380 | |
| 846 | 791 | if( (x + (count << 3) < SNES_SCR_WIDTH + 8) ) |
| 847 | 792 | { |
| 848 | 793 | if( widemode ) |
| 849 | | snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); |
| 794 | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1); |
| 850 | 795 | else |
| 851 | | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend ); |
| 796 | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0); |
| 852 | 797 | } |
| 853 | 798 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 854 | 799 | } |
| r5379 | r5380 | |
| 860 | 805 | if( (x + (xs << 3) < SNES_SCR_WIDTH + 8) ) |
| 861 | 806 | { |
| 862 | 807 | if( widemode ) |
| 863 | | snes_draw_tile_object_w(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); |
| 808 | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1); |
| 864 | 809 | else |
| 865 | | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend ); |
| 810 | snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0); |
| 866 | 811 | } |
| 867 | 812 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 868 | 813 | } |