src/mame/video/snes.c
| r7501 | r7502 | |
| 108 | 108 | { (96*32), (96*32)+32, (96*32)+64, (96*32)+96, (96*32)+128, (96*32)+160, (96*32)+192, (96*32)+224 }, |
| 109 | 109 | { (112*32), (112*32)+32, (112*32)+64, (112*32)+96, (112*32)+128, (112*32)+160, (112*32)+192, (112*32)+224 } |
| 110 | 110 | }; |
| 111 | | /* Scroll tables 32x32 64x32 32x64 64x64 */ |
| 112 | | static const UINT16 table_hscroll[4][4] = { {0,0,0,0}, {0,0x800,0,0x800}, {0,0,0,0}, {0,0x800,0,0x800} }; |
| 113 | | static const UINT16 table_vscroll[4][4] = { {0,0,0,0}, {0,0,0,0}, {0,0x800,0,0x800}, {0,0x1000,0,0x1000} }; |
| 114 | 111 | |
| 115 | 112 | struct SCANLINE |
| 116 | 113 | { |
| 117 | | UINT16 buffer[(SNES_SCR_WIDTH * 2) + 16]; |
| 118 | | UINT8 priority[(SNES_SCR_WIDTH * 2) + 16]; |
| 119 | | UINT8 layer[(SNES_SCR_WIDTH * 2) + 16]; |
| 120 | | UINT8 blend_exception[(SNES_SCR_WIDTH * 2) + 16]; |
| 114 | int enable, clip; |
| 115 | |
| 116 | UINT16 buffer[(SNES_SCR_WIDTH * 2)]; |
| 117 | UINT8 priority[(SNES_SCR_WIDTH * 2)]; |
| 118 | UINT8 layer[(SNES_SCR_WIDTH * 2)]; |
| 119 | UINT8 blend_exception[(SNES_SCR_WIDTH * 2)]; |
| 121 | 120 | }; |
| 122 | 121 | |
| 123 | 122 | static struct SCANLINE scanlines[2]; |
| r7501 | r7502 | |
| 136 | 135 | * Routine for additive/subtractive blending |
| 137 | 136 | * between the main and sub screens. |
| 138 | 137 | *****************************************/ |
| 139 | | INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 factor, UINT8 clip, UINT8 black_pen_clip ) |
| 138 | |
| 139 | INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 140 | 140 | { |
| 141 | 141 | if ((black_pen_clip == SNES_CLIP_ALL2) || |
| 142 | | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset / factor]) || |
| 143 | | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset / factor])) |
| 142 | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 143 | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 144 | 144 | *colour = 0; //clip to black before color math |
| 145 | 145 | |
| 146 | 146 | if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF |
| r7501 | r7502 | |
| 150 | 150 | if (!debug_options.transparency_disabled) |
| 151 | 151 | #endif /* SNES_LAYER_DEBUG */ |
| 152 | 152 | if ((clip == SNES_CLIP_ALL) || |
| 153 | | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset / factor]) || |
| 154 | | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset / factor])) |
| 153 | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 154 | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 155 | 155 | { |
| 156 | 156 | UINT16 r, g, b; |
| 157 | 157 | int clip_max = 0; // if add then clip to 0x1f, if sub then clip to 0 |
| r7501 | r7502 | |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | | INLINE void snes_draw_blend_lores(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 229 | | { |
| 230 | | snes_draw_blend(offset, colour, 1, clip, black_pen_clip); |
| 231 | | } |
| 232 | | |
| 233 | | INLINE void snes_draw_blend_hires(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 234 | | { |
| 235 | | snes_draw_blend(offset, colour, 2, clip, black_pen_clip); |
| 236 | | } |
| 237 | | |
| 238 | 228 | /***************************************** |
| 239 | 229 | * snes_draw_tile() |
| 240 | 230 | * |
| 241 | 231 | * Draw tiles with variable bit planes |
| 242 | 232 | *****************************************/ |
| 243 | | INLINE void snes_draw_tile(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors ) |
| 233 | |
| 234 | INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 244 | 235 | { |
| 245 | | UINT8 mask, plane[8], window_enabled = 0; |
| 236 | UINT8 mask, plane[8]; |
| 246 | 237 | UINT16 c; |
| 247 | 238 | INT16 ii, jj; |
| 248 | 239 | |
| r7501 | r7502 | |
| 275 | 266 | mask >>= 1; |
| 276 | 267 | } |
| 277 | 268 | |
| 269 | |
| 270 | if (!hires) |
| 271 | { |
| 272 | if (scanlines[SNES_MAINSCREEN].enable) |
| 273 | { |
| 274 | |
| 278 | 275 | #ifdef SNES_LAYER_DEBUG |
| 279 | | if (!debug_options.windows_disabled) |
| 276 | if (!debug_options.windows_disabled) |
| 280 | 277 | #endif /* SNES_LAYER_DEBUG */ |
| 281 | | /* Clip to windows */ |
| 282 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 283 | | if (window_enabled) |
| 284 | | colour &= snes_ppu.clipmasks[layer][ii]; |
| 278 | /* Clip to windows */ |
| 279 | if (scanlines[SNES_MAINSCREEN].clip) |
| 280 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 285 | 281 | |
| 286 | | /* Only draw if we have a colour (0 == transparent) */ |
| 287 | | if (colour) |
| 288 | | { |
| 289 | | if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0)) |
| 282 | /* Only draw if we have a colour (0 == transparent) */ |
| 283 | if (colour) |
| 284 | { |
| 285 | if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 286 | { |
| 287 | if (direct_colors) |
| 288 | { |
| 289 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 290 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 291 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 292 | } |
| 293 | else |
| 294 | c = snes_cgram[pal + colour]; |
| 295 | |
| 296 | if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 297 | { |
| 298 | int x_mos; |
| 299 | |
| 300 | //TODO: 512 modes has the h values doubled. |
| 301 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 302 | { |
| 303 | scanlines[SNES_MAINSCREEN].buffer[ii + x_mos] = c; |
| 304 | scanlines[SNES_MAINSCREEN].priority[ii + x_mos] = priority; |
| 305 | scanlines[SNES_MAINSCREEN].layer[ii + x_mos] = layer; |
| 306 | } |
| 307 | |
| 308 | ii += x_mos - 1; |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 313 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| 314 | scanlines[SNES_MAINSCREEN].layer[ii] = layer; |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | if (scanlines[SNES_SUBSCREEN].enable) |
| 290 | 321 | { |
| 291 | | if (direct_colors) |
| 322 | #ifdef SNES_LAYER_DEBUG |
| 323 | if (!debug_options.windows_disabled) |
| 324 | #endif /* SNES_LAYER_DEBUG */ |
| 325 | /* Clip to windows */ |
| 326 | if (scanlines[SNES_SUBSCREEN].clip) |
| 327 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 328 | |
| 329 | /* Only draw if we have a colour (0 == transparent) */ |
| 330 | if (colour) |
| 292 | 331 | { |
| 293 | | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 294 | | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 295 | | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 332 | if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 333 | { |
| 334 | if (direct_colors) |
| 335 | { |
| 336 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 337 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 338 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 339 | } |
| 340 | else |
| 341 | c = snes_cgram[pal + colour]; |
| 342 | |
| 343 | if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic |
| 344 | { |
| 345 | int x_mos; |
| 346 | |
| 347 | //TODO: 512 modes has the h values doubled. |
| 348 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 349 | { |
| 350 | scanlines[SNES_SUBSCREEN].buffer[ii + x_mos] = c; |
| 351 | scanlines[SNES_SUBSCREEN].priority[ii + x_mos] = priority; |
| 352 | scanlines[SNES_SUBSCREEN].layer[ii + x_mos] = layer; |
| 353 | } |
| 354 | |
| 355 | ii += x_mos - 1; |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 360 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| 361 | scanlines[SNES_SUBSCREEN].layer[ii] = layer; |
| 362 | } |
| 363 | } |
| 296 | 364 | } |
| 297 | | else |
| 298 | | c = snes_cgram[pal + colour]; |
| 365 | } |
| 366 | } |
| 299 | 367 | |
| 300 | | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 368 | else /* hires */ |
| 369 | { |
| 370 | #ifdef SNES_LAYER_DEBUG |
| 371 | if (!debug_options.windows_disabled) |
| 372 | #endif /* SNES_LAYER_DEBUG */ |
| 373 | /* Clip to windows */ |
| 374 | if (scanlines[SNES_MAINSCREEN].clip) |
| 375 | colour &= snes_ppu.clipmasks[layer][ii >> hires]; |
| 376 | |
| 377 | /* Only draw if we have a colour (0 == transparent) */ |
| 378 | if (colour) |
| 379 | { |
| 380 | if ((scanlines[SNES_MAINSCREEN].priority[ii >> hires] <= priority) && (ii >= 0)) |
| 301 | 381 | { |
| 302 | | int x_mos; |
| 382 | if (direct_colors) |
| 383 | { |
| 384 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 385 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 386 | c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); |
| 387 | } |
| 388 | else |
| 389 | c = snes_cgram[pal + colour]; |
| 303 | 390 | |
| 304 | | //TODO: 512 modes has the h values doubled. |
| 305 | | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 391 | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 306 | 392 | { |
| 307 | | scanlines[screen].buffer[ii + x_mos] = c; |
| 308 | | scanlines[screen].priority[ii + x_mos] = priority; |
| 309 | | scanlines[screen].layer[ii + x_mos] = layer; |
| 393 | int x_mos; |
| 394 | |
| 395 | //TODO: 512 modes has the h values doubled. |
| 396 | for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++) |
| 397 | { |
| 398 | if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable) |
| 399 | { |
| 400 | scanlines[SNES_MAINSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 401 | scanlines[SNES_MAINSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 402 | scanlines[SNES_MAINSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 403 | } |
| 404 | else if (scanlines[SNES_SUBSCREEN].enable) |
| 405 | { |
| 406 | scanlines[SNES_SUBSCREEN].buffer[(ii + x_mos) >> 1] = c; |
| 407 | scanlines[SNES_SUBSCREEN].priority[(ii + x_mos) >> 1] = priority; |
| 408 | scanlines[SNES_SUBSCREEN].layer[(ii + x_mos) >> 1] = layer; |
| 409 | } |
| 410 | } |
| 411 | ii += x_mos - 1; |
| 310 | 412 | } |
| 311 | | ii += x_mos - 1; |
| 413 | else |
| 414 | { |
| 415 | if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable) |
| 416 | { |
| 417 | scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c; |
| 418 | scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority; |
| 419 | scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer; |
| 420 | } |
| 421 | else if (scanlines[SNES_SUBSCREEN].enable) |
| 422 | { |
| 423 | scanlines[SNES_SUBSCREEN].buffer[ii >> 1] = c; |
| 424 | scanlines[SNES_SUBSCREEN].priority[ii >> 1] = priority; |
| 425 | scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer; |
| 426 | } |
| 427 | } |
| 312 | 428 | } |
| 313 | | else |
| 314 | | { |
| 315 | | scanlines[screen].buffer[ii] = c; |
| 316 | | scanlines[screen].priority[ii] = priority; |
| 317 | | scanlines[screen].layer[ii] = layer; |
| 318 | | } |
| 319 | 429 | } |
| 320 | 430 | } |
| 321 | 431 | } |
| r7501 | r7502 | |
| 326 | 436 | * |
| 327 | 437 | * Draw 2 tiles with variable bit planes |
| 328 | 438 | *****************************************/ |
| 329 | | INLINE void snes_draw_tile_x2(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors ) |
| 439 | |
| 440 | INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires ) |
| 330 | 441 | { |
| 331 | 442 | if (flip) |
| 332 | 443 | { |
| 333 | | snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors); |
| 334 | | snes_draw_tile(screen, planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors); |
| 444 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors, hires); |
| 445 | snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors, hires); |
| 335 | 446 | } |
| 336 | 447 | else |
| 337 | 448 | { |
| 338 | | snes_draw_tile(screen, planes, layer, tileaddr, x, priority, flip, pal, direct_colors); |
| 339 | | snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors); |
| 449 | snes_draw_tile(planes, layer, tileaddr, x, priority, flip, pal, direct_colors, hires); |
| 450 | snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors, hires); |
| 340 | 451 | } |
| 341 | 452 | } |
| 342 | 453 | |
| r7501 | r7502 | |
| 347 | 458 | * The same as snes_draw_tile_4() except |
| 348 | 459 | * that it takes a blend parameter. |
| 349 | 460 | *****************************************/ |
| 350 | | INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend, UINT8 wide ) |
| 461 | |
| 462 | INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) |
| 351 | 463 | { |
| 352 | | UINT8 mask, plane[4], window_enabled = 0; |
| 464 | UINT8 mask, plane[4]; |
| 353 | 465 | UINT16 c; |
| 354 | 466 | INT16 ii; |
| 355 | | UINT8 x_shift = wide ? 1 : 0; |
| 356 | | UINT8 size = wide ? 16 : 8; |
| 357 | | UINT8 step = wide ? 1 : 0; |
| 358 | 467 | |
| 359 | 468 | plane[0] = snes_vram[tileaddr]; |
| 360 | 469 | plane[1] = snes_vram[tileaddr + 1]; |
| r7501 | r7502 | |
| 366 | 475 | else |
| 367 | 476 | mask = 0x80; |
| 368 | 477 | |
| 369 | | x <<= x_shift; |
| 370 | | for (ii = x; ii < (x + size); ii += 1 + step) |
| 478 | for (ii = x; ii < (x + 8); ii++) |
| 371 | 479 | { |
| 372 | 480 | UINT8 colour; |
| 373 | 481 | if (flip) |
| r7501 | r7502 | |
| 383 | 491 | mask >>= 1; |
| 384 | 492 | } |
| 385 | 493 | |
| 494 | if (scanlines[SNES_MAINSCREEN].enable) |
| 495 | { |
| 496 | |
| 386 | 497 | #ifdef SNES_LAYER_DEBUG |
| 387 | | if (!debug_options.windows_disabled) |
| 498 | if (!debug_options.windows_disabled) |
| 388 | 499 | #endif /* SNES_LAYER_DEBUG */ |
| 389 | | /* Clip to windows */ |
| 390 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[SNES_OAM].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 391 | | if (window_enabled) |
| 392 | | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 500 | /* Clip to windows */ |
| 501 | if (scanlines[SNES_MAINSCREEN].clip) |
| 502 | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 393 | 503 | |
| 394 | | /* Only draw if we have a colour (0 == transparent) */ |
| 395 | | if (colour) |
| 504 | /* Only draw if we have a colour (0 == transparent) */ |
| 505 | if (colour) |
| 506 | { |
| 507 | if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 508 | { |
| 509 | c = snes_cgram[pal + colour]; |
| 510 | |
| 511 | scanlines[SNES_MAINSCREEN].buffer[ii] = c; |
| 512 | scanlines[SNES_MAINSCREEN].priority[ii] = priority; |
| 513 | scanlines[SNES_MAINSCREEN].layer[ii] = SNES_OAM; |
| 514 | scanlines[SNES_MAINSCREEN].blend_exception[ii] = blend; |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | if (scanlines[SNES_SUBSCREEN].enable) |
| 396 | 520 | { |
| 397 | | if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0)) |
| 521 | |
| 522 | #ifdef SNES_LAYER_DEBUG |
| 523 | if (!debug_options.windows_disabled) |
| 524 | #endif /* SNES_LAYER_DEBUG */ |
| 525 | /* Clip to windows */ |
| 526 | if (scanlines[SNES_SUBSCREEN].clip) |
| 527 | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 528 | |
| 529 | /* Only draw if we have a colour (0 == transparent) */ |
| 530 | if (colour) |
| 398 | 531 | { |
| 399 | | c = snes_cgram[pal + colour]; |
| 532 | if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0)) |
| 533 | { |
| 534 | c = snes_cgram[pal + colour]; |
| 400 | 535 | |
| 401 | | scanlines[screen].buffer[ii] = c; |
| 402 | | scanlines[screen].priority[ii] = priority; |
| 403 | | scanlines[screen].layer[ii] = SNES_OAM; |
| 404 | | scanlines[screen].blend_exception[ii] = blend; |
| 405 | | if (wide) |
| 406 | | { |
| 407 | | scanlines[screen].buffer[ii + 1] = c; |
| 408 | | scanlines[screen].priority[ii + 1] = priority; |
| 409 | | scanlines[screen].layer[ii + 1] = SNES_OAM; |
| 410 | | scanlines[screen].blend_exception[ii + 1] = blend; |
| 536 | scanlines[SNES_SUBSCREEN].buffer[ii] = c; |
| 537 | scanlines[SNES_SUBSCREEN].priority[ii] = priority; |
| 538 | scanlines[SNES_SUBSCREEN].layer[ii] = SNES_OAM; |
| 539 | scanlines[SNES_SUBSCREEN].blend_exception[ii] = blend; |
| 411 | 540 | } |
| 412 | 541 | } |
| 413 | 542 | } |
| r7501 | r7502 | |
| 419 | 548 | * |
| 420 | 549 | * Update an entire line of tiles. |
| 421 | 550 | *********************************************/ |
| 422 | | INLINE void snes_update_line( UINT8 screen, UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors ) |
| 551 | |
| 552 | INLINE UINT32 snes_get_tmap( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y ) |
| 423 | 553 | { |
| 424 | | UINT32 tmap, tile; |
| 425 | | UINT16 ii, vflip, hflip, pal; |
| 554 | UINT32 res = base; |
| 555 | x >>= (3 + tile_size); |
| 556 | y >>= (3 + tile_size); |
| 557 | |
| 558 | res += (snes_ppu.layer[layer].tilemap_size & 2) ? ((y & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0; |
| 559 | /* Scroll vertically */ |
| 560 | res += (y & 0x1f) << 6; |
| 561 | /* Offset horizontally */ |
| 562 | res += (snes_ppu.layer[layer].tilemap_size & 1) ? ((x & 0x20) << 6) : 0; |
| 563 | /* Scroll horizontally */ |
| 564 | res += (x & 0x1f) << 1; |
| 565 | |
| 566 | return res; |
| 567 | } |
| 568 | |
| 569 | INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors ) |
| 570 | { |
| 571 | UINT32 tmap, tile, xoff, yoff; |
| 572 | UINT16 ii = 0, vflip, hflip, pal; |
| 426 | 573 | INT8 tile_line; |
| 427 | 574 | UINT8 priority; |
| 428 | 575 | /* scrolling */ |
| 429 | | UINT32 basevmap, charaddr; |
| 576 | UINT32 charaddr; |
| 430 | 577 | UINT16 vscroll, hscroll; |
| 431 | | // UINT16 offset_per_tile_valid; |
| 432 | | // UINT8 offset_per_tile_mode; |
| 578 | UINT16 opt_bit = (layer == SNES_BG1) ? 13 : (layer == SNES_BG2) ? 14 : 0; |
| 433 | 579 | UINT8 vshift, hshift, tile_size; |
| 434 | 580 | /* variables depending on color_depth */ |
| 435 | 581 | UINT8 color_shift = 0; |
| 436 | 582 | UINT8 color_planes = 2; |
| 437 | 583 | UINT8 tile_divider = 1; |
| 438 | | UINT8 wrap_around_x; //helper for wrap-around |
| 439 | 584 | |
| 440 | 585 | #ifdef SNES_LAYER_DEBUG |
| 441 | 586 | if (debug_options.bg_disabled[layer]) |
| 442 | 587 | return; |
| 588 | #endif /* SNES_LAYER_DEBUG */ |
| 443 | 589 | |
| 444 | | if (debug_options.mode_disabled[snes_ppu.mode]) |
| 590 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 591 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 592 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 593 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 594 | |
| 595 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 445 | 596 | return; |
| 446 | | #endif /* SNES_LAYER_DEBUG */ |
| 447 | 597 | |
| 448 | 598 | /* Handle Mosaic effects */ |
| 449 | 599 | if (snes_ppu.layer[layer].mosaic_enabled) |
| r7501 | r7502 | |
| 461 | 611 | vscroll = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) >> (3 + tile_size); |
| 462 | 612 | vshift = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) & ((8 << tile_size) - 1); |
| 463 | 613 | |
| 614 | xoff = snes_ppu.layer[layer].hoffs; |
| 615 | yoff = snes_ppu.layer[layer].voffs; |
| 616 | |
| 464 | 617 | /* figure out which line to draw */ |
| 465 | 618 | if (vshift > ((8 << tile_size) - 1)) /* scrolled into the next tile */ |
| 466 | 619 | { |
| r7501 | r7502 | |
| 474 | 627 | tmap = snes_ppu.layer[layer].tilemap << 9; |
| 475 | 628 | charaddr = snes_ppu.layer[layer].charmap << 13; |
| 476 | 629 | |
| 477 | | /* Offset vertically */ |
| 478 | | tmap += (snes_ppu.layer[layer].tilemap_size & 2) ? ((vscroll & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0; |
| 479 | | /* Scroll vertically */ |
| 480 | | tmap += (vscroll & 0x1f) << 6; |
| 481 | | /* Remember this position */ |
| 482 | | basevmap = tmap; |
| 483 | | /* Offset horizontally */ |
| 484 | | tmap += (snes_ppu.layer[layer].tilemap_size & 1) ? ((hscroll & 0x20) << 6) : 0; |
| 485 | | /* Scroll horizontally */ |
| 486 | | tmap += (hscroll & 0x1f) << 1; |
| 487 | | |
| 488 | 630 | /* set a couple of variables depending on color_dept */ |
| 489 | 631 | switch (color_depth) |
| 490 | 632 | { |
| r7501 | r7502 | |
| 505 | 647 | break; |
| 506 | 648 | } |
| 507 | 649 | |
| 508 | | wrap_around_x = 1; |
| 509 | | |
| 510 | | for (ii = 0; ii < (66*(hires+1) >> tile_size); ii += 2) |
| 650 | while (ii < 256) |
| 511 | 651 | { |
| 512 | | /* Have we scrolled into the next map? */ |
| 513 | | if (wrap_around_x && ((ii >> 1) >= 32 - (hscroll & 0x1f))) |
| 514 | | { |
| 515 | | tmap = basevmap + table_hscroll[snes_ppu.layer[layer].tilemap_size & 3][((hscroll >> 5) + 1) & 3]; |
| 516 | | tmap -= ii; |
| 517 | | wrap_around_x = 0; /* Make sure we don't do this again */ |
| 518 | | } |
| 519 | | //if (tmap > 0x10000) |
| 520 | | // tmap %= 0x10000; |
| 521 | | |
| 522 | 652 | /* |
| 523 | 653 | Tilemap format |
| 524 | 654 | vhopppcc cccccccc |
| r7501 | r7502 | |
| 528 | 658 | ppp = Tile palette. The number of entries in the palette depends on the Mode and the BG. |
| 529 | 659 | cccccccccc = Tile number. |
| 530 | 660 | */ |
| 531 | | UINT16 tilemap = snes_vram[tmap + ii] | (snes_vram[tmap + ii + 1] << 8); |
| 661 | |
| 662 | // determine the horizontal position (Bishojo Janshi Suchi Pai & Desert Figther have tile_size & hires == 1) |
| 663 | UINT32 xpos = xoff + (ii << (tile_size * hires)); |
| 664 | UINT32 ypos = yoff + curline; |
| 665 | |
| 666 | if (offset_per_tile != SNES_OPT_NONE) |
| 667 | { |
| 668 | int opt_x = ii + (xoff & 7); |
| 669 | UINT32 haddr = 0, vaddr = 0; |
| 670 | UINT16 hval = 0, vval = 0; |
| 671 | |
| 672 | if (opt_x >= 8) |
| 673 | { |
| 674 | switch (offset_per_tile) |
| 675 | { |
| 676 | case SNES_OPT_MODE2: |
| 677 | case SNES_OPT_MODE6: |
| 678 | haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff)); |
| 679 | vaddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff) + 8); |
| 680 | hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8); |
| 681 | vval = snes_vram[vaddr] | (snes_vram[vaddr + 1] << 8); |
| 682 | if (BIT(hval, opt_bit)) |
| 683 | xpos = opt_x + (hval & ~7); |
| 684 | if (BIT(vval, opt_bit)) |
| 685 | ypos = curline + vval; |
| 686 | break; |
| 687 | case SNES_OPT_MODE4: |
| 688 | haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff)); |
| 689 | hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8); |
| 690 | if (BIT(hval, opt_bit)) |
| 691 | { |
| 692 | if (!BIT(hval, 15)) |
| 693 | xpos = opt_x + (hval & ~7); |
| 694 | else |
| 695 | ypos = curline + hval; |
| 696 | } |
| 697 | break; |
| 698 | } |
| 699 | |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | UINT32 addr = snes_get_tmap(layer, tile_size, tmap, xpos, ypos); |
| 704 | UINT16 tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8); |
| 532 | 705 | vflip = BIT(tilemap, 15); |
| 533 | 706 | hflip = BIT(tilemap, 14); |
| 534 | 707 | priority = BIT(tilemap, 13) ? priority_b : priority_a; |
| r7501 | r7502 | |
| 568 | 741 | tile_line <<= 1; |
| 569 | 742 | |
| 570 | 743 | /* below, only color_planes depends on color_depth */ |
| 571 | | if (tile_size) |
| 744 | if (hires) /* Hi-Res: 2bpp & 4bpp */ |
| 572 | 745 | { |
| 573 | | snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal, direct_colors); |
| 746 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii * 2, priority, hflip, pal, direct_colors, hires); |
| 747 | ii += 8; |
| 574 | 748 | } |
| 575 | 749 | else /* tile_size = 0 */ |
| 576 | 750 | { |
| 577 | | if (hires) /* Hi-Res: 2bpp & 4bpp */ |
| 578 | | snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal, direct_colors); |
| 751 | if (tile_size) |
| 752 | { |
| 753 | snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 754 | ii += 16; |
| 755 | } |
| 579 | 756 | else /* No Hi-Res: 2bpp, 4bpp & 8bpp */ |
| 580 | | snes_draw_tile(screen, color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal, direct_colors); |
| 757 | { |
| 758 | snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires); |
| 759 | ii += 8; |
| 760 | } |
| 581 | 761 | } |
| 582 | 762 | } |
| 583 | 763 | } |
| r7501 | r7502 | |
| 588 | 768 | * |
| 589 | 769 | * Update an entire line of mode7 tiles. |
| 590 | 770 | *********************************************/ |
| 771 | |
| 591 | 772 | #define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff)) |
| 592 | 773 | |
| 593 | | static void snes_update_line_mode7(UINT8 screen, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline ) |
| 774 | static void snes_update_line_mode7( UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline ) |
| 594 | 775 | { |
| 595 | 776 | UINT32 tiled; |
| 596 | 777 | INT16 ma, mb, mc, md; |
| 597 | 778 | INT32 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir, x0, y0; |
| 598 | 779 | UINT8 priority = priority_a; |
| 599 | | UINT8 colour = 0, window_enabled = 0; |
| 780 | UINT8 colour = 0; |
| 600 | 781 | UINT16 *mosaic_x, *mosaic_y; |
| 601 | 782 | |
| 602 | 783 | #ifdef SNES_LAYER_DEBUG |
| 603 | 784 | if (debug_options.bg_disabled[layer]) |
| 604 | 785 | return; |
| 786 | #endif /* SNES_LAYER_DEBUG */ |
| 605 | 787 | |
| 606 | | if (debug_options.mode_disabled[snes_ppu.mode]) |
| 788 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer]; |
| 789 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer]; |
| 790 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled; |
| 791 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled; |
| 792 | |
| 793 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 607 | 794 | return; |
| 608 | | #endif /* SNES_LAYER_DEBUG */ |
| 609 | 795 | |
| 610 | 796 | ma = snes_ppu.mode7.matrix_a; |
| 611 | 797 | mb = snes_ppu.mode7.matrix_b; |
| r7501 | r7502 | |
| 701 | 887 | colour &= 0x7f; |
| 702 | 888 | } |
| 703 | 889 | |
| 704 | | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 705 | | if (window_enabled) |
| 706 | | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 890 | if (scanlines[SNES_MAINSCREEN].enable) |
| 891 | { |
| 892 | if (scanlines[SNES_MAINSCREEN].clip) |
| 893 | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 707 | 894 | |
| 708 | | /* Draw pixel if appropriate */ |
| 709 | | if (scanlines[screen].priority[xpos] <= priority && colour > 0) |
| 895 | /* Draw pixel if appropriate */ |
| 896 | if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && colour > 0) |
| 897 | { |
| 898 | UINT16 clr; |
| 899 | /* Direct select, but only outside EXTBG! */ |
| 900 | if (snes_ppu.direct_color && layer == 0) |
| 901 | { |
| 902 | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 903 | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 904 | } |
| 905 | else |
| 906 | clr = snes_cgram[colour]; |
| 907 | |
| 908 | scanlines[SNES_MAINSCREEN].buffer[xpos] = clr; |
| 909 | scanlines[SNES_MAINSCREEN].priority[xpos] = priority; |
| 910 | scanlines[SNES_MAINSCREEN].layer[xpos] = layer; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | if (scanlines[SNES_SUBSCREEN].enable) |
| 710 | 915 | { |
| 711 | | UINT16 clr; |
| 712 | | /* Direct select, but only outside EXTBG! */ |
| 713 | | if (snes_ppu.direct_color && layer == 0) |
| 916 | if (scanlines[SNES_SUBSCREEN].clip) |
| 917 | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 918 | |
| 919 | /* Draw pixel if appropriate */ |
| 920 | if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && colour > 0) |
| 714 | 921 | { |
| 715 | | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 716 | | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 922 | UINT16 clr; |
| 923 | /* Direct select, but only outside EXTBG! */ |
| 924 | if (snes_ppu.direct_color && layer == 0) |
| 925 | { |
| 926 | /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */ |
| 927 | clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| 928 | } |
| 929 | else |
| 930 | clr = snes_cgram[colour]; |
| 931 | |
| 932 | scanlines[SNES_SUBSCREEN].buffer[xpos] = clr; |
| 933 | scanlines[SNES_SUBSCREEN].priority[xpos] = priority; |
| 934 | scanlines[SNES_SUBSCREEN].layer[xpos] = layer; |
| 717 | 935 | } |
| 718 | | else |
| 719 | | clr = snes_cgram[colour]; |
| 720 | | |
| 721 | | scanlines[screen].buffer[xpos] = clr; |
| 722 | | scanlines[screen].priority[xpos] = priority; |
| 723 | | scanlines[screen].layer[xpos] = layer; |
| 724 | 936 | } |
| 725 | 937 | } |
| 726 | 938 | } |
| r7501 | r7502 | |
| 731 | 943 | * Update an entire line of sprites. |
| 732 | 944 | * FIXME: We need to support high priority bit |
| 733 | 945 | *********************************************/ |
| 734 | | static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curline ) |
| 946 | |
| 947 | static void snes_update_objects( UINT8 priority_tbl, UINT16 curline ) |
| 735 | 948 | { |
| 736 | 949 | INT8 xs, ys; |
| 737 | | UINT8 line, widemode = 0; |
| 950 | UINT8 line; |
| 738 | 951 | UINT16 oam_extra, extra; |
| 739 | 952 | INT16 oam; |
| 740 | 953 | UINT8 range_over = 0, time_over = 0; |
| r7501 | r7502 | |
| 757 | 970 | }; |
| 758 | 971 | |
| 759 | 972 | #ifdef SNES_LAYER_DEBUG |
| 760 | | if (debug_options.bg_disabled[4]) |
| 973 | if (debug_options.bg_disabled[SNES_OAM]) |
| 761 | 974 | return; |
| 762 | 975 | #endif /* SNES_LAYER_DEBUG */ |
| 763 | 976 | |
| 764 | | if (snes_ppu.mode == 5 || snes_ppu.mode == 6) |
| 765 | | widemode = 1; |
| 977 | scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[SNES_OAM]; |
| 978 | scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[SNES_OAM]; |
| 979 | scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[SNES_OAM].main_window_enabled; |
| 980 | scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 766 | 981 | |
| 982 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 983 | return; |
| 984 | |
| 767 | 985 | curline /= snes_ppu.interlace; |
| 768 | 986 | curline *= snes_ppu.obj_interlace; |
| 769 | 987 | |
| r7501 | r7502 | |
| 789 | 1007 | extra <<= 1; |
| 790 | 1008 | x |= ((extra & 0x80) << 1); |
| 791 | 1009 | extra <<= 1; |
| 792 | | y*=snes_ppu.obj_interlace; |
| 1010 | y *= snes_ppu.obj_interlace; |
| 793 | 1011 | |
| 794 | 1012 | /* Adjust if past maximum position */ |
| 795 | 1013 | if (y >= snes_ppu.beam.last_visible_line*snes_ppu.interlace) |
| r7501 | r7502 | |
| 822 | 1040 | { |
| 823 | 1041 | if ((x + (count << 3) < SNES_SCR_WIDTH + 8)) |
| 824 | 1042 | { |
| 825 | | if (widemode) |
| 826 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1); |
| 827 | | else |
| 828 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0); |
| 1043 | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend); |
| 829 | 1044 | } |
| 830 | 1045 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 831 | 1046 | } |
| r7501 | r7502 | |
| 836 | 1051 | { |
| 837 | 1052 | if ((x + (xs << 3) < SNES_SCR_WIDTH + 8)) |
| 838 | 1053 | { |
| 839 | | if (widemode) |
| 840 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1); |
| 841 | | else |
| 842 | | snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0); |
| 1054 | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend); |
| 843 | 1055 | } |
| 844 | 1056 | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 845 | 1057 | } |
| r7501 | r7502 | |
| 870 | 1082 | * |
| 871 | 1083 | * Update Mode X line. |
| 872 | 1084 | *********************************************/ |
| 873 | | static void snes_update_mode_0( UINT8 screen, UINT16 curline ) |
| 1085 | |
| 1086 | static void snes_update_mode_0( UINT16 curline ) |
| 874 | 1087 | { |
| 875 | | UINT8 *bg_enabled; |
| 876 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1088 | #ifdef SNES_LAYER_DEBUG |
| 1089 | if (debug_options.mode_disabled[0]) |
| 1090 | return; |
| 1091 | #endif /* SNES_LAYER_DEBUG */ |
| 877 | 1092 | |
| 878 | | if (bg_enabled[4]) snes_update_objects(screen, 0, curline); |
| 879 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0); |
| 880 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0); |
| 881 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0); |
| 882 | | if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0); |
| 1093 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, SNES_OPT_NONE, 0); |
| 1094 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1095 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1096 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1097 | snes_update_objects(0, curline); |
| 883 | 1098 | } |
| 884 | 1099 | |
| 885 | | static void snes_update_mode_1( UINT8 screen, UINT16 curline ) |
| 1100 | static void snes_update_mode_1( UINT16 curline ) |
| 886 | 1101 | { |
| 887 | | UINT8 *bg_enabled; |
| 888 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1102 | #ifdef SNES_LAYER_DEBUG |
| 1103 | if (debug_options.mode_disabled[1]) |
| 1104 | return; |
| 1105 | #endif /* SNES_LAYER_DEBUG */ |
| 889 | 1106 | |
| 890 | 1107 | if (!snes_ppu.bg3_priority_bit) |
| 891 | 1108 | { |
| 892 | | if (bg_enabled[4]) snes_update_objects(screen, 1, curline); |
| 893 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0); |
| 894 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0); |
| 895 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0); |
| 1109 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1110 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1111 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1112 | snes_update_objects(1, curline); |
| 896 | 1113 | } |
| 897 | 1114 | else |
| 898 | 1115 | { |
| 899 | | if (bg_enabled[4]) snes_update_objects(screen, 9, curline); |
| 900 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0); |
| 901 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0); |
| 902 | | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0); |
| 1116 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1117 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1118 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1119 | snes_update_objects(9, curline); |
| 903 | 1120 | } |
| 904 | 1121 | } |
| 905 | 1122 | |
| 906 | | static void snes_update_mode_2( UINT8 screen, UINT16 curline ) |
| 1123 | static void snes_update_mode_2( UINT16 curline ) |
| 907 | 1124 | { |
| 908 | | UINT8 *bg_enabled; |
| 909 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1125 | #ifdef SNES_LAYER_DEBUG |
| 1126 | if (debug_options.mode_disabled[2]) |
| 1127 | return; |
| 1128 | #endif /* SNES_LAYER_DEBUG */ |
| 910 | 1129 | |
| 911 | | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 912 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0); |
| 913 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0); |
| 1130 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE2, 0); |
| 1131 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE2, 0); |
| 1132 | snes_update_objects(2, curline); |
| 914 | 1133 | } |
| 915 | 1134 | |
| 916 | | static void snes_update_mode_3( UINT8 screen, UINT16 curline ) |
| 1135 | static void snes_update_mode_3( UINT16 curline ) |
| 917 | 1136 | { |
| 918 | | UINT8 *bg_enabled; |
| 919 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1137 | #ifdef SNES_LAYER_DEBUG |
| 1138 | if (debug_options.mode_disabled[3]) |
| 1139 | return; |
| 1140 | #endif /* SNES_LAYER_DEBUG */ |
| 920 | 1141 | |
| 921 | | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 922 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 923 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 1142 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1143 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, snes_ppu.direct_color); |
| 1144 | snes_update_objects(3, curline); |
| 924 | 1145 | } |
| 925 | 1146 | |
| 926 | | static void snes_update_mode_4( UINT8 screen, UINT16 curline ) |
| 1147 | static void snes_update_mode_4( UINT16 curline ) |
| 927 | 1148 | { |
| 928 | | UINT8 *bg_enabled; |
| 929 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1149 | #ifdef SNES_LAYER_DEBUG |
| 1150 | if (debug_options.mode_disabled[4]) |
| 1151 | return; |
| 1152 | #endif /* SNES_LAYER_DEBUG */ |
| 930 | 1153 | |
| 931 | | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 932 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color); |
| 933 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0); |
| 1154 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE4, 0); |
| 1155 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE4, snes_ppu.direct_color); |
| 1156 | snes_update_objects(4, curline); |
| 934 | 1157 | } |
| 935 | 1158 | |
| 936 | | static void snes_update_mode_5( UINT8 screen, UINT16 curline ) |
| 1159 | static void snes_update_mode_5( UINT16 curline ) |
| 937 | 1160 | { |
| 938 | | UINT8 *bg_enabled; |
| 939 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1161 | #ifdef SNES_LAYER_DEBUG |
| 1162 | if (debug_options.mode_disabled[5]) |
| 1163 | return; |
| 1164 | #endif /* SNES_LAYER_DEBUG */ |
| 940 | 1165 | |
| 941 | | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 942 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0); |
| 943 | | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0); |
| 1166 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1167 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1168 | snes_update_objects(5, curline); |
| 944 | 1169 | } |
| 945 | 1170 | |
| 946 | | static void snes_update_mode_6( UINT8 screen, UINT16 curline ) |
| 1171 | static void snes_update_mode_6( UINT16 curline ) |
| 947 | 1172 | { |
| 948 | | UINT8 *bg_enabled; |
| 949 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1173 | #ifdef SNES_LAYER_DEBUG |
| 1174 | if (debug_options.mode_disabled[6]) |
| 1175 | return; |
| 1176 | #endif /* SNES_LAYER_DEBUG */ |
| 950 | 1177 | |
| 951 | | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 952 | | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0); |
| 1178 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, SNES_OPT_MODE6, 0); |
| 1179 | snes_update_objects(6, curline); |
| 953 | 1180 | } |
| 954 | 1181 | |
| 955 | | static void snes_update_mode_7( UINT8 screen, UINT16 curline ) |
| 1182 | static void snes_update_mode_7( UINT16 curline ) |
| 956 | 1183 | { |
| 957 | | UINT8 *bg_enabled; |
| 958 | | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 1184 | #ifdef SNES_LAYER_DEBUG |
| 1185 | if (debug_options.mode_disabled[7]) |
| 1186 | return; |
| 1187 | #endif /* SNES_LAYER_DEBUG */ |
| 959 | 1188 | |
| 960 | 1189 | if (!snes_ppu.mode7.extbg) |
| 961 | 1190 | { |
| 962 | | if (bg_enabled[4]) snes_update_objects(screen, 7, curline); |
| 963 | | if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline); |
| 1191 | snes_update_line_mode7(1, 1, SNES_BG1, curline); |
| 1192 | snes_update_objects(7, curline); |
| 964 | 1193 | } |
| 965 | 1194 | else |
| 966 | 1195 | { |
| 967 | | if (bg_enabled[4]) snes_update_objects(screen, 8, curline); |
| 968 | | if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline); |
| 969 | | if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline); |
| 1196 | snes_update_line_mode7(0, 4, SNES_BG2, curline); |
| 1197 | snes_update_line_mode7(2, 2, SNES_BG1, curline); |
| 1198 | snes_update_objects(8, curline); |
| 970 | 1199 | } |
| 971 | 1200 | } |
| 972 | 1201 | |
| 973 | 1202 | /********************************************* |
| 974 | | * snes_draw_screen() |
| 1203 | * snes_draw_screens() |
| 975 | 1204 | * |
| 976 | 1205 | * Draw the whole screen (Mode 0 -> 7). |
| 977 | 1206 | *********************************************/ |
| 978 | | static void snes_draw_screen( UINT8 screen, UINT16 curline ) |
| 1207 | |
| 1208 | static void snes_draw_screens( UINT16 curline ) |
| 979 | 1209 | { |
| 980 | 1210 | switch (snes_ppu.mode) |
| 981 | 1211 | { |
| 982 | | case 0: snes_update_mode_0(screen, curline); break; /* Mode 0 */ |
| 983 | | case 1: snes_update_mode_1(screen, curline); break; /* Mode 1 */ |
| 984 | | case 2: snes_update_mode_2(screen, curline); break; /* Mode 2 - Supports offset per tile */ |
| 985 | | case 3: snes_update_mode_3(screen, curline); break; /* Mode 3 - Supports direct colour */ |
| 986 | | case 4: snes_update_mode_4(screen, curline); break; /* Mode 4 - Supports offset per tile and direct colour */ |
| 987 | | case 5: snes_update_mode_5(screen, curline); break; /* Mode 5 - Supports hires */ |
| 988 | | case 6: snes_update_mode_6(screen, curline); break; /* Mode 6 - Supports offset per tile and hires */ |
| 989 | | case 7: snes_update_mode_7(screen, curline); break; /* Mode 7 - Supports direct colour */ |
| 1212 | case 0: snes_update_mode_0(curline); break; /* Mode 0 */ |
| 1213 | case 1: snes_update_mode_1(curline); break; /* Mode 1 */ |
| 1214 | case 2: snes_update_mode_2(curline); break; /* Mode 2 - Supports offset per tile */ |
| 1215 | case 3: snes_update_mode_3(curline); break; /* Mode 3 - Supports direct colour */ |
| 1216 | case 4: snes_update_mode_4(curline); break; /* Mode 4 - Supports offset per tile and direct colour */ |
| 1217 | case 5: snes_update_mode_5(curline); break; /* Mode 5 - Supports hires */ |
| 1218 | case 6: snes_update_mode_6(curline); break; /* Mode 6 - Supports offset per tile and hires */ |
| 1219 | case 7: snes_update_mode_7(curline); break; /* Mode 7 - Supports direct colour */ |
| 990 | 1220 | } |
| 991 | 1221 | } |
| 992 | 1222 | |
| r7501 | r7502 | |
| 1002 | 1232 | * XOR: ...###..###... ###...##...### |
| 1003 | 1233 | * XNOR: ###...##...### ...###..###... |
| 1004 | 1234 | *********************************************/ |
| 1005 | | static void snes_update_windowmasks(void) |
| 1235 | |
| 1236 | static void snes_update_windowmasks( void ) |
| 1006 | 1237 | { |
| 1007 | 1238 | UINT16 ii, jj; |
| 1008 | 1239 | INT8 w1, w2; |
| r7501 | r7502 | |
| 1073 | 1304 | * |
| 1074 | 1305 | * Update the offsets with the latest changes. |
| 1075 | 1306 | *********************************************/ |
| 1076 | | static void snes_update_offsets(void) |
| 1307 | |
| 1308 | static void snes_update_offsets( void ) |
| 1077 | 1309 | { |
| 1078 | 1310 | int ii; |
| 1079 | 1311 | for (ii = 0; ii < 4; ii++) |
| r7501 | r7502 | |
| 1087 | 1319 | * |
| 1088 | 1320 | * Redraw the current line. |
| 1089 | 1321 | *********************************************/ |
| 1322 | |
| 1090 | 1323 | static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, UINT16 curline ) |
| 1091 | 1324 | { |
| 1092 | 1325 | UINT16 ii; |
| r7501 | r7502 | |
| 1133 | 1366 | scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0]; |
| 1134 | 1367 | } |
| 1135 | 1368 | |
| 1136 | | /* Draw SNES_SUBSCREEN */ |
| 1137 | | snes_draw_screen(SNES_SUBSCREEN, curline); |
| 1369 | /* Draw screens */ |
| 1370 | snes_draw_screens(curline); |
| 1138 | 1371 | |
| 1139 | | /* Draw SNES_MAINSCREEN */ |
| 1140 | | snes_draw_screen(SNES_MAINSCREEN, curline); |
| 1141 | | |
| 1142 | 1372 | #ifdef SNES_LAYER_DEBUG |
| 1143 | 1373 | if (snes_dbg_video(machine, bitmap, curline)) |
| 1144 | 1374 | { |
| r7501 | r7502 | |
| 1156 | 1386 | /* Phew! Draw the line to screen */ |
| 1157 | 1387 | fade = snes_ppu.screen_brightness; |
| 1158 | 1388 | |
| 1159 | | for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2) |
| 1389 | for (x = 0; x < SNES_SCR_WIDTH * 2; x++) |
| 1160 | 1390 | { |
| 1161 | | if (snes_ppu.mode != 5 && snes_ppu.mode != 6) |
| 1162 | | { |
| 1163 | | int r, g, b; |
| 1164 | | c = scanline->buffer[x]; |
| 1391 | int r, g, b, hires; |
| 1392 | UINT16 temp_col; |
| 1393 | hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1; |
| 1394 | c = scanline->buffer[x]; |
| 1395 | temp_col = scanline->buffer[x]; |
| 1165 | 1396 | |
| 1166 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1167 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1168 | | snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1397 | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1398 | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1399 | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1169 | 1400 | |
| 1170 | | r = ((c & 0x1f) * fade) >> 4; |
| 1171 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1172 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1401 | r = ((c & 0x1f) * fade) >> 4; |
| 1402 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1403 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1173 | 1404 | |
| 1174 | | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1405 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1406 | |
| 1407 | if (!hires) |
| 1175 | 1408 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1176 | | |
| 1177 | | c = scanline->buffer[x + 1]; |
| 1178 | | |
| 1179 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1180 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math) |
| 1181 | | snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1182 | | |
| 1183 | | r = ((c & 0x1f) * fade) >> 4; |
| 1184 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1185 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1186 | | |
| 1187 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1188 | | *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1189 | | |
| 1190 | | } |
| 1191 | 1409 | else |
| 1192 | 1410 | { |
| 1193 | | int r, g, b; |
| 1194 | | UINT16 temp_col; |
| 1195 | | c = scanline->buffer[x]; |
| 1196 | | temp_col = scanline->buffer[x]; |
| 1197 | | |
| 1198 | | /* perform color math if the layer wants it (except if it's an object > 192) */ |
| 1199 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1200 | | snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1201 | | |
| 1202 | | r = ((c & 0x1f) * fade) >> 4; |
| 1203 | | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1204 | | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1205 | | |
| 1206 | | *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1207 | | |
| 1208 | 1411 | c = scanlines[SNES_SUBSCREEN].buffer[x]; |
| 1209 | 1412 | scanlines[SNES_SUBSCREEN].buffer[x] = temp_col; |
| 1210 | 1413 | |
| 1211 | | /* perform color math only if it's been done on the previous pixel */ |
| 1212 | | if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1213 | | snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1414 | if (!scanlines[SNES_SUBSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math) |
| 1415 | snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1214 | 1416 | |
| 1215 | 1417 | r = ((c & 0x1f) * fade) >> 4; |
| 1216 | 1418 | g = (((c & 0x3e0) >> 5) * fade) >> 4; |
| 1217 | 1419 | b = (((c & 0x7c00) >> 10) * fade) >> 4; |
| 1218 | 1420 | |
| 1219 | | *BITMAP_ADDR32(bitmap, curline, x + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1421 | *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1220 | 1422 | } |
| 1221 | 1423 | } |
| 1222 | 1424 | } |