src/mame/video/snes.c
| r7301 | r7302 | |
| 74 | 74 | #include "profiler.h" |
| 75 | 75 | #include "includes/snes.h" |
| 76 | 76 | |
| 77 | | #define MAINSCREEN 0 |
| 78 | | #define SUBSCREEN 1 |
| 79 | | #define SNES_BLEND_NONE 0 |
| 80 | | #define SNES_BLEND_ADD 1 |
| 81 | | #define SNES_BLEND_SUB 2 |
| 82 | | #define SNES_CLIP_ALL 0 |
| 83 | | #define SNES_CLIP_IN 1 |
| 84 | | #define SNES_CLIP_OUT 2 |
| 85 | | #define SNES_CLIP_ALL2 3 |
| 77 | #define SNES_MAINSCREEN 0 |
| 78 | #define SNES_SUBSCREEN 1 |
| 79 | #define SNES_CLIP_ALL 0 |
| 80 | #define SNES_CLIP_IN 1 |
| 81 | #define SNES_CLIP_OUT 2 |
| 82 | #define SNES_CLIP_ALL2 3 |
| 86 | 83 | |
| 87 | 84 | #ifdef MAME_DEBUG |
| 88 | 85 | struct DEBUGOPTS |
| r7301 | r7302 | |
| 90 | 87 | UINT8 input_count; |
| 91 | 88 | UINT8 bg_disabled[6]; |
| 92 | 89 | UINT8 mode_disabled[8]; |
| 93 | | UINT8 draw_subscreen; |
| 90 | UINT8 draw_SNES_SUBSCREEN; |
| 94 | 91 | UINT8 windows_disabled; |
| 95 | 92 | UINT8 transparency_disabled; |
| 96 | 93 | }; |
| r7301 | r7302 | |
| 137 | 134 | * Routine for additive/subtractive blending |
| 138 | 135 | * between the main and sub screens. |
| 139 | 136 | *****************************************/ |
| 140 | | INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 clip, UINT8 black_pen_clip ) |
| 137 | INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip ) |
| 141 | 138 | { |
| 142 | | if( (black_pen_clip == SNES_CLIP_ALL2) || |
| 139 | if ((black_pen_clip == SNES_CLIP_ALL2) || |
| 143 | 140 | (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 144 | 141 | (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 145 | 142 | *colour = 0; //clip to black before color math |
| r7301 | r7302 | |
| 148 | 145 | return; |
| 149 | 146 | |
| 150 | 147 | #ifdef MAME_DEBUG |
| 151 | | if( !debug_options.transparency_disabled ) |
| 148 | if (!debug_options.transparency_disabled) |
| 152 | 149 | #endif /* MAME_DEBUG */ |
| 153 | | if( (clip == SNES_CLIP_ALL) || |
| 150 | if ((clip == SNES_CLIP_ALL) || |
| 154 | 151 | (clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) || |
| 155 | | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset]) ) |
| 152 | (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset])) |
| 156 | 153 | { |
| 157 | 154 | UINT16 r, g, b; |
| 155 | int clip_max = 0; // if add then clip to 0x1f, if sub then clip to 0 |
| 158 | 156 | |
| 159 | | if( mode == SNES_BLEND_ADD ) |
| 157 | if (snes_ppu.sub_add_mode) /* SNES_SUBSCREEN*/ |
| 160 | 158 | { |
| 161 | | if( snes_ppu.sub_add_mode ) /* Subscreen*/ |
| 159 | switch (snes_ppu.color_modes & 0x80) |
| 162 | 160 | { |
| 163 | | r = (*colour & 0x1f) + (scanlines[SUBSCREEN].buffer[offset] & 0x1f); |
| 164 | | g = ((*colour & 0x3e0) >> 5) + ((scanlines[SUBSCREEN].buffer[offset] & 0x3e0) >> 5); |
| 165 | | b = ((*colour & 0x7c00) >> 10) + ((scanlines[SUBSCREEN].buffer[offset] & 0x7c00) >> 10); |
| 166 | | |
| 167 | | /* don't halve for the back colour */ |
| 168 | | if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR])) |
| 169 | | { |
| 170 | | r >>= 1; |
| 171 | | g >>= 1; |
| 172 | | b >>= 1; |
| 173 | | } |
| 161 | case 0x00: /* add */ |
| 162 | r = (*colour & 0x1f) + (scanlines[SNES_SUBSCREEN].buffer[offset] & 0x1f); |
| 163 | g = ((*colour & 0x3e0) >> 5) + ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x3e0) >> 5); |
| 164 | b = ((*colour & 0x7c00) >> 10) + ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x7c00) >> 10); |
| 165 | clip_max = 1; |
| 166 | break; |
| 167 | case 0x80: /* sub */ |
| 168 | r = (*colour & 0x1f) - (scanlines[SNES_SUBSCREEN].buffer[offset] & 0x1f); |
| 169 | g = ((*colour & 0x3e0) >> 5) - ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x3e0) >> 5); |
| 170 | b = ((*colour & 0x7c00) >> 10) - ((scanlines[SNES_SUBSCREEN].buffer[offset] & 0x7c00) >> 10); |
| 171 | if (r > 0x1f) r = 0; |
| 172 | if (g > 0x1f) g = 0; |
| 173 | if (b > 0x1f) b = 0; |
| 174 | break; |
| 174 | 175 | } |
| 175 | | else /* Fixed colour */ |
| 176 | /* only halve if the color is not the back colour */ |
| 177 | if ((snes_ppu.color_modes & 0x40) && (scanlines[SNES_SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR])) |
| 176 | 178 | { |
| 177 | | r = (*colour & 0x1f) + (snes_cgram[FIXED_COLOUR] & 0x1f); |
| 178 | | g = ((*colour & 0x3e0) >> 5) + ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5); |
| 179 | | b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10); |
| 180 | | |
| 181 | | /* don't halve for the back colour */ |
| 182 | | if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR])) |
| 183 | | { |
| 184 | | r >>= 1; |
| 185 | | g >>= 1; |
| 186 | | b >>= 1; |
| 187 | | } |
| 179 | r >>= 1; |
| 180 | g >>= 1; |
| 181 | b >>= 1; |
| 188 | 182 | } |
| 189 | | if( r > 0x1f ) r = 0x1f; |
| 190 | | if( g > 0x1f ) g = 0x1f; |
| 191 | | if( b > 0x1f ) b = 0x1f; |
| 192 | | *colour = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); |
| 193 | 183 | } |
| 194 | | else if( mode == SNES_BLEND_SUB ) |
| 184 | else /* Fixed colour */ |
| 195 | 185 | { |
| 196 | | if( snes_ppu.sub_add_mode ) /* Subscreen */ |
| 186 | switch (snes_ppu.color_modes & 0x80) |
| 197 | 187 | { |
| 198 | | r = (*colour & 0x1f) - (scanlines[SUBSCREEN].buffer[offset] & 0x1f); |
| 199 | | g = ((*colour & 0x3e0) >> 5) - ((scanlines[SUBSCREEN].buffer[offset] & 0x3e0) >> 5); |
| 200 | | b = ((*colour & 0x7c00) >> 10) - ((scanlines[SUBSCREEN].buffer[offset] & 0x7c00) >> 10); |
| 201 | | if( r > 0x1f ) r = 0; |
| 202 | | if( g > 0x1f ) g = 0; |
| 203 | | if( b > 0x1f ) b = 0; |
| 204 | | |
| 205 | | /* don't halve for the back colour */ |
| 206 | | if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR])) |
| 207 | | { |
| 208 | | r >>= 1; |
| 209 | | g >>= 1; |
| 210 | | b >>= 1; |
| 211 | | } |
| 212 | | } |
| 213 | | else /* Fixed colour */ |
| 214 | | { |
| 188 | case 0x00: /* add */ |
| 189 | r = (*colour & 0x1f) + (snes_cgram[FIXED_COLOUR] & 0x1f); |
| 190 | g = ((*colour & 0x3e0) >> 5) + ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5); |
| 191 | b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10); |
| 192 | clip_max = 1; |
| 193 | break; |
| 194 | case 0x80: /* sub */ |
| 215 | 195 | r = (*colour & 0x1f) - (snes_cgram[FIXED_COLOUR] & 0x1f); |
| 216 | 196 | g = ((*colour & 0x3e0) >> 5) - ((snes_cgram[FIXED_COLOUR] & 0x3e0) >> 5); |
| 217 | 197 | b = ((*colour & 0x7c00) >> 10) - ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10); |
| 218 | | if( r > 0x1f ) r = 0; |
| 219 | | if( g > 0x1f ) g = 0; |
| 220 | | if( b > 0x1f ) b = 0; |
| 221 | | |
| 222 | | /* don't halve for the back colour */ |
| 223 | | if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR])) |
| 224 | | { |
| 225 | | r >>= 1; |
| 226 | | g >>= 1; |
| 227 | | b >>= 1; |
| 228 | | } |
| 198 | if (r > 0x1f) r = 0; |
| 199 | if (g > 0x1f) g = 0; |
| 200 | if (b > 0x1f) b = 0; |
| 201 | break; |
| 229 | 202 | } |
| 230 | | *colour = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); |
| 203 | /* halve if necessary */ |
| 204 | if (snes_ppu.color_modes & 0x40) |
| 205 | { |
| 206 | r >>= 1; |
| 207 | g >>= 1; |
| 208 | b >>= 1; |
| 209 | } |
| 231 | 210 | } |
| 211 | |
| 212 | /* according to anomie's docs, after addition has been performed, division by 2 happens *before* clipping to max, hence we clip now */ |
| 213 | if (clip_max) |
| 214 | { |
| 215 | if (r > 0x1f) r = 0x1f; |
| 216 | if (g > 0x1f) g = 0x1f; |
| 217 | if (b > 0x1f) b = 0x1f; |
| 218 | } |
| 219 | |
| 220 | *colour = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); |
| 232 | 221 | } |
| 233 | 222 | } |
| 234 | 223 | |
| r7301 | r7302 | |
| 274 | 263 | } |
| 275 | 264 | |
| 276 | 265 | #ifdef MAME_DEBUG |
| 277 | | if(!debug_options.windows_disabled) |
| 266 | if (!debug_options.windows_disabled) |
| 278 | 267 | #endif /* MAME_DEBUG */ |
| 279 | 268 | /* Clip to windows */ |
| 280 | | window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 269 | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 281 | 270 | if (window_enabled) |
| 282 | 271 | colour &= snes_ppu.clipmasks[layer][ii]; |
| 283 | 272 | |
| r7301 | r7302 | |
| 286 | 275 | { |
| 287 | 276 | if ((scanlines[screen].zbuf[ii] <= priority) && (ii >= 0)) |
| 288 | 277 | { |
| 289 | | if(direct_colors) |
| 278 | if (direct_colors) |
| 290 | 279 | { |
| 291 | 280 | /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ |
| 292 | 281 | c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7); |
| r7301 | r7302 | |
| 295 | 284 | else |
| 296 | 285 | c = snes_cgram[pal + colour]; |
| 297 | 286 | |
| 298 | | if (screen == MAINSCREEN) /* Only blend main screens */ |
| 299 | | snes_draw_blend(ii/snes_htmult, &c, snes_ppu.layer[layer].blend, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 287 | /* Only blend main screens and only if the layer is subject to color_math */ |
| 288 | if (screen == SNES_MAINSCREEN && snes_ppu.layer[layer].color_math) |
| 289 | snes_draw_blend(ii/snes_htmult, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 300 | 290 | if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic |
| 301 | 291 | { |
| 302 | 292 | int x_mos; |
| r7301 | r7302 | |
| 326 | 316 | *****************************************/ |
| 327 | 317 | 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 ) |
| 328 | 318 | { |
| 329 | | if( flip ) |
| 319 | if (flip) |
| 330 | 320 | { |
| 331 | 321 | snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors); |
| 332 | 322 | snes_draw_tile(screen, planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors); |
| r7301 | r7302 | |
| 385 | 375 | if (!debug_options.windows_disabled) |
| 386 | 376 | #endif /* MAME_DEBUG */ |
| 387 | 377 | /* Clip to windows */ |
| 388 | | window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 378 | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled; |
| 389 | 379 | if (window_enabled) |
| 390 | 380 | colour &= snes_ppu.clipmasks[SNES_OAM][ii]; |
| 391 | 381 | |
| r7301 | r7302 | |
| 395 | 385 | if (ii >= 0) |
| 396 | 386 | { |
| 397 | 387 | c = snes_cgram[pal + colour]; |
| 398 | | if (blend && screen == MAINSCREEN) /* Only blend main screens */ |
| 399 | | snes_draw_blend(ii/snes_htmult, &c, snes_ppu.layer[SNES_OAM].blend, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 388 | if (blend && screen == SNES_MAINSCREEN && snes_ppu.layer[SNES_OAM].color_math) /* Only blend main screens */ |
| 389 | snes_draw_blend(ii/snes_htmult, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 400 | 390 | |
| 401 | 391 | scanlines[screen].buffer[ii] = c; |
| 402 | 392 | scanlines[screen].zbuf[ii] = priority; |
| r7301 | r7302 | |
| 445 | 435 | if (snes_ppu.layer[layer].mosaic_enabled) |
| 446 | 436 | curline -= (curline % (snes_ppu.mosaic_size + 1)); |
| 447 | 437 | |
| 448 | | if((snes_ppu.interlace == 2) && !hires) |
| 449 | | curline/=2; |
| 438 | if ((snes_ppu.interlace == 2) && !hires) |
| 439 | curline /= 2; |
| 450 | 440 | |
| 451 | 441 | /* Find the size of the tiles (8x8 or 16x16) */ |
| 452 | 442 | tile_size = snes_ppu.layer[layer].tile_size; |
| r7301 | r7302 | |
| 465 | 455 | vtilescroll++; /* pretend we scrolled by 1 tile line */ |
| 466 | 456 | line -= (8 << tile_size); |
| 467 | 457 | } |
| 468 | | if( vtilescroll >= 128 ) |
| 458 | if (vtilescroll >= 128) |
| 469 | 459 | vtilescroll -= 128; |
| 470 | 460 | |
| 471 | 461 | /* Jump to base map address */ |
| r7301 | r7302 | |
| 708 | 698 | colour &= 0x7f; |
| 709 | 699 | } |
| 710 | 700 | |
| 711 | | window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 701 | window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled; |
| 712 | 702 | if (window_enabled) |
| 713 | 703 | colour &= snes_ppu.clipmasks[layer][xpos]; |
| 714 | 704 | |
| r7301 | r7302 | |
| 725 | 715 | else |
| 726 | 716 | clr = snes_cgram[colour]; |
| 727 | 717 | /* Only blend main screens */ |
| 728 | | if (screen == MAINSCREEN) |
| 729 | | snes_draw_blend(xpos, &clr, snes_ppu.layer[layer].blend, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); /* FIXME: Need to support clip mode */ |
| 718 | if (screen == SNES_MAINSCREEN && snes_ppu.layer[layer].color_math) |
| 719 | snes_draw_blend(xpos, &clr, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); /* FIXME: Need to support clip mode */ |
| 730 | 720 | |
| 731 | 721 | scanlines[screen].buffer[xpos] = clr; |
| 732 | 722 | scanlines[screen].zbuf[xpos] = priority; |
| r7301 | r7302 | |
| 766 | 756 | }; |
| 767 | 757 | |
| 768 | 758 | #ifdef MAME_DEBUG |
| 769 | | if( debug_options.bg_disabled[4] ) |
| 759 | if (debug_options.bg_disabled[4]) |
| 770 | 760 | return; |
| 771 | 761 | #endif /* MAME_DEBUG */ |
| 772 | 762 | |
| 773 | | if( snes_ppu.mode == 5 || snes_ppu.mode == 6 ) |
| 763 | if (snes_ppu.mode == 5 || snes_ppu.mode == 6) |
| 774 | 764 | widemode = 1; |
| 775 | 765 | |
| 776 | 766 | curline/=snes_ppu.interlace; |
| r7301 | r7302 | |
| 779 | 769 | oam = 0x1ff; |
| 780 | 770 | oam_extra = oam + 0x20; |
| 781 | 771 | extra = 0; |
| 782 | | for( i = 128; i > 0; i-- ) |
| 772 | for (i = 128; i > 0; i--) |
| 783 | 773 | { |
| 784 | | if( (i % 4) == 0 ) |
| 774 | if ((i % 4) == 0) |
| 785 | 775 | extra = oamram[oam_extra--]; |
| 786 | 776 | |
| 787 | 777 | vflip = (oamram[oam] & 0x80) >> 7; |
| r7301 | r7302 | |
| 799 | 789 | y*=snes_ppu.obj_interlace; |
| 800 | 790 | |
| 801 | 791 | /* Adjust if past maximum position */ |
| 802 | | if( y >= snes_ppu.beam.last_visible_line*snes_ppu.interlace ) |
| 792 | if (y >= snes_ppu.beam.last_visible_line*snes_ppu.interlace) |
| 803 | 793 | y -= 256*snes_ppu.interlace; |
| 804 | | if( x > 255 ) |
| 794 | if (x > 255) |
| 805 | 795 | x -= 512; |
| 806 | 796 | |
| 807 | 797 | /* Draw sprite if it intersects the current line */ |
| 808 | | if( curline >= y && curline < (y + (snes_ppu.oam.size[size] << 3)) ) |
| 798 | if (curline >= y && curline < (y + (snes_ppu.oam.size[size] << 3))) |
| 809 | 799 | { |
| 810 | 800 | /* Only objects using palettes 4-7 can be transparent */ |
| 811 | 801 | blend = (pal < 192) ? 0 : 1; |
| r7301 | r7302 | |
| 815 | 805 | |
| 816 | 806 | ys = (curline - y) >> 3; |
| 817 | 807 | line = (curline - y) % 8; |
| 818 | | if( vflip ) |
| 808 | if (vflip) |
| 819 | 809 | { |
| 820 | 810 | ys = snes_ppu.oam.size[size] - ys - 1; |
| 821 | 811 | line = (-1 * line) + 7; |
| 822 | 812 | } |
| 823 | 813 | line <<= 1; |
| 824 | 814 | tile <<= 5; |
| 825 | | if( hflip ) |
| 815 | if (hflip) |
| 826 | 816 | { |
| 827 | 817 | UINT8 count = 0; |
| 828 | | for( xs = (snes_ppu.oam.size[size] - 1); xs >= 0; xs-- ) |
| 818 | for (xs = (snes_ppu.oam.size[size] - 1); xs >= 0; xs--) |
| 829 | 819 | { |
| 830 | | if( (x + (count << 3) < SNES_SCR_WIDTH + 8) ) |
| 820 | if ((x + (count << 3) < SNES_SCR_WIDTH + 8)) |
| 831 | 821 | { |
| 832 | | if( widemode ) |
| 822 | if (widemode) |
| 833 | 823 | snes_draw_tile_object(screen, snes_ppu.layer[SNES_OAM].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1); |
| 834 | 824 | else |
| 835 | 825 | snes_draw_tile_object(screen, snes_ppu.layer[SNES_OAM].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0); |
| r7301 | r7302 | |
| 839 | 829 | } |
| 840 | 830 | else |
| 841 | 831 | { |
| 842 | | for( xs = 0; xs < snes_ppu.oam.size[size]; xs++ ) |
| 832 | for (xs = 0; xs < snes_ppu.oam.size[size]; xs++) |
| 843 | 833 | { |
| 844 | | if( (x + (xs << 3) < SNES_SCR_WIDTH + 8) ) |
| 834 | if ((x + (xs << 3) < SNES_SCR_WIDTH + 8)) |
| 845 | 835 | { |
| 846 | | if( widemode ) |
| 836 | if (widemode) |
| 847 | 837 | snes_draw_tile_object(screen, snes_ppu.layer[SNES_OAM].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1); |
| 848 | 838 | else |
| 849 | 839 | snes_draw_tile_object(screen, snes_ppu.layer[SNES_OAM].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0); |
| r7301 | r7302 | |
| 880 | 870 | static void snes_update_mode_0( UINT8 screen, UINT16 curline ) |
| 881 | 871 | { |
| 882 | 872 | UINT8 *bg_enabled; |
| 883 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 873 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 884 | 874 | |
| 885 | 875 | if (bg_enabled[4]) snes_update_objects(screen, 0, curline); |
| 886 | 876 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, 0, curline, 0, 0); |
| r7301 | r7302 | |
| 892 | 882 | static void snes_update_mode_1( UINT8 screen, UINT16 curline ) |
| 893 | 883 | { |
| 894 | 884 | UINT8 *bg_enabled; |
| 895 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 885 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 896 | 886 | |
| 897 | 887 | if (!snes_ppu.bg3_priority_bit) |
| 898 | 888 | { |
| r7301 | r7302 | |
| 913 | 903 | static void snes_update_mode_2( UINT8 screen, UINT16 curline ) |
| 914 | 904 | { |
| 915 | 905 | UINT8 *bg_enabled; |
| 916 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 906 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 917 | 907 | |
| 918 | 908 | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 919 | 909 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, 0, curline, 1, 0); |
| r7301 | r7302 | |
| 923 | 913 | static void snes_update_mode_3( UINT8 screen, UINT16 curline ) |
| 924 | 914 | { |
| 925 | 915 | UINT8 *bg_enabled; |
| 926 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 916 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 927 | 917 | |
| 928 | 918 | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 929 | 919 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline, 0, snes_ppu.direct_color); |
| r7301 | r7302 | |
| 933 | 923 | static void snes_update_mode_4( UINT8 screen, UINT16 curline ) |
| 934 | 924 | { |
| 935 | 925 | UINT8 *bg_enabled; |
| 936 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 926 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 937 | 927 | |
| 938 | 928 | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 939 | 929 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline, 0, snes_ppu.direct_color); |
| r7301 | r7302 | |
| 943 | 933 | static void snes_update_mode_5( UINT8 screen, UINT16 curline ) |
| 944 | 934 | { |
| 945 | 935 | UINT8 *bg_enabled; |
| 946 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 936 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 947 | 937 | |
| 948 | 938 | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 949 | 939 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, 0, curline, 0, 0); |
| r7301 | r7302 | |
| 953 | 943 | static void snes_update_mode_6( UINT8 screen, UINT16 curline ) |
| 954 | 944 | { |
| 955 | 945 | UINT8 *bg_enabled; |
| 956 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 946 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 957 | 947 | |
| 958 | 948 | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 959 | 949 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, 0, curline, 1, 0); |
| r7301 | r7302 | |
| 962 | 952 | static void snes_update_mode_7( UINT8 screen, UINT16 curline ) |
| 963 | 953 | { |
| 964 | 954 | UINT8 *bg_enabled; |
| 965 | | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 955 | bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 966 | 956 | |
| 967 | 957 | if (!snes_ppu.mode7.extbg) |
| 968 | 958 | { |
| r7301 | r7302 | |
| 1060 | 1050 | break; |
| 1061 | 1051 | } |
| 1062 | 1052 | } |
| 1063 | | else if( w1 >= 0 ) |
| 1053 | else if (w1 >= 0) |
| 1064 | 1054 | snes_ppu.clipmasks[jj][ii] = w1 ? 0x00 : 0xff; |
| 1065 | | else if( w2 >= 0 ) |
| 1055 | else if (w2 >= 0) |
| 1066 | 1056 | snes_ppu.clipmasks[jj][ii] = w2 ? 0x00 : 0xff; |
| 1067 | 1057 | } |
| 1068 | 1058 | |
| r7301 | r7302 | |
| 1122 | 1112 | static void snes_update_offsets(void) |
| 1123 | 1113 | { |
| 1124 | 1114 | int ii; |
| 1125 | | for( ii = 0; ii < 4; ii++ ) |
| 1115 | for (ii = 0; ii < 4; ii++) |
| 1126 | 1116 | { |
| 1127 | 1117 | snes_ppu.layer[ii].offset.tile_horz = (snes_ppu.layer[ii].offset.horizontal & 0x3ff) >> (3 + snes_ppu.layer[ii].tile_size); |
| 1128 | 1118 | snes_ppu.layer[ii].offset.shift_horz = snes_ppu.layer[ii].offset.horizontal & ((8 << snes_ppu.layer[ii].tile_size) - 1); |
| r7301 | r7302 | |
| 1171 | 1161 | snes_update_offsets(); |
| 1172 | 1162 | |
| 1173 | 1163 | /* Clear zbuffers */ |
| 1174 | | memset(scanlines[MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2); |
| 1175 | | memset(scanlines[SUBSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2); |
| 1164 | memset(scanlines[SNES_MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2); |
| 1165 | memset(scanlines[SNES_SUBSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2); |
| 1176 | 1166 | |
| 1177 | | /* Clear subscreen and draw back colour */ |
| 1167 | /* Clear SNES_SUBSCREEN and draw back colour */ |
| 1178 | 1168 | for (ii = 0; ii < SNES_SCR_WIDTH * 2; ii++) |
| 1179 | 1169 | { |
| 1180 | 1170 | /* Not sure if this is correct behaviour, but a few games seem to |
| 1181 | 1171 | * require it. (SMW, Zelda etc) */ |
| 1182 | | scanlines[SUBSCREEN].buffer[ii] = snes_cgram[FIXED_COLOUR]; |
| 1172 | scanlines[SNES_SUBSCREEN].buffer[ii] = snes_cgram[FIXED_COLOUR]; |
| 1183 | 1173 | /* Draw back colour */ |
| 1184 | | scanlines[MAINSCREEN].buffer[ii] = snes_cgram[0]; |
| 1174 | scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0]; |
| 1185 | 1175 | } |
| 1186 | 1176 | |
| 1187 | | /* Draw subscreen */ |
| 1188 | | snes_draw_screen(SUBSCREEN, curline); |
| 1177 | /* Draw SNES_SUBSCREEN */ |
| 1178 | snes_draw_screen(SNES_SUBSCREEN, curline); |
| 1189 | 1179 | |
| 1190 | 1180 | /* Draw the back plane */ |
| 1191 | 1181 | #ifdef MAME_DEBUG |
| 1192 | 1182 | if (!debug_options.bg_disabled[5]) |
| 1193 | 1183 | #endif /* MAME_DEBUG */ |
| 1194 | | if (snes_ram[CGADSUB] & 0x20) |
| 1184 | if (snes_ppu.colour.color_math) |
| 1195 | 1185 | { |
| 1196 | | for(ii = 0; ii < SNES_SCR_WIDTH * snes_htmult; ii++) |
| 1186 | for (ii = 0; ii < SNES_SCR_WIDTH * snes_htmult; ii++) |
| 1197 | 1187 | { |
| 1198 | | snes_draw_blend(ii/snes_htmult, &scanlines[MAINSCREEN].buffer[ii], (snes_ppu.color_modes & 0x80) ? SNES_BLEND_SUB : SNES_BLEND_ADD, snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1188 | snes_draw_blend(ii/snes_htmult, &scanlines[SNES_MAINSCREEN].buffer[ii], snes_ppu.sub_color_mask, snes_ppu.main_color_mask); |
| 1199 | 1189 | } |
| 1200 | 1190 | } |
| 1201 | 1191 | |
| 1202 | | /* Draw mainscreen */ |
| 1203 | | snes_draw_screen(MAINSCREEN, curline); |
| 1192 | /* Draw SNES_MAINSCREEN */ |
| 1193 | snes_draw_screen(SNES_MAINSCREEN, curline); |
| 1204 | 1194 | |
| 1205 | 1195 | #ifdef MAME_DEBUG |
| 1206 | 1196 | if (snes_dbg_video(machine, bitmap, curline)) |
| r7301 | r7302 | |
| 1209 | 1199 | return; |
| 1210 | 1200 | } |
| 1211 | 1201 | |
| 1212 | | /* Toggle drawing of subscreen or mainscreen */ |
| 1213 | | if (debug_options.draw_subscreen) |
| 1214 | | scanline = &scanlines[SUBSCREEN]; |
| 1202 | /* Toggle drawing of SNES_SUBSCREEN or SNES_MAINSCREEN */ |
| 1203 | if (debug_options.draw_SNES_SUBSCREEN) |
| 1204 | scanline = &scanlines[SNES_SUBSCREEN]; |
| 1215 | 1205 | else |
| 1216 | 1206 | #endif /* MAME_DEBUG */ |
| 1217 | | scanline = &scanlines[MAINSCREEN]; |
| 1207 | scanline = &scanlines[SNES_MAINSCREEN]; |
| 1218 | 1208 | |
| 1219 | 1209 | /* Phew! Draw the line to screen */ |
| 1220 | 1210 | fade = snes_ppu.screen_brightness; |
| r7301 | r7302 | |
| 1225 | 1215 | int g = (((scanline->buffer[x] & 0x3e0) >> 5) * fade) >> 4; |
| 1226 | 1216 | int b = (((scanline->buffer[x] & 0x7c00) >> 10) * fade) >> 4; |
| 1227 | 1217 | |
| 1228 | | if(snes_htmult == 1) |
| 1218 | if (snes_htmult == 1) |
| 1229 | 1219 | { |
| 1230 | 1220 | *BITMAP_ADDR32(bitmap, curline, x*2+0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| 1231 | 1221 | *BITMAP_ADDR32(bitmap, curline, x*2+1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)); |
| r7301 | r7302 | |
| 1268 | 1258 | INT8 line; |
| 1269 | 1259 | |
| 1270 | 1260 | tmap += (curline >> 3) * 64; |
| 1271 | | for( ii = 0; ii < 64; ii += 2 ) |
| 1261 | for (ii = 0; ii < 64; ii += 2) |
| 1272 | 1262 | { |
| 1273 | 1263 | vflip = (snes_vram[tmap + ii + 1] & 0x80); |
| 1274 | 1264 | hflip = snes_vram[tmap + ii + 1] & 0x40; |
| r7301 | r7302 | |
| 1276 | 1266 | tile = (snes_vram[tmap + ii + 1] & 0x3) << 8; |
| 1277 | 1267 | tile |= snes_vram[tmap + ii]; |
| 1278 | 1268 | line = curline % 8; |
| 1279 | | if( vflip ) |
| 1269 | if (vflip) |
| 1280 | 1270 | line = -line + 7; |
| 1281 | 1271 | |
| 1282 | | if( tile != 0 ) |
| 1272 | if (tile != 0) |
| 1283 | 1273 | { |
| 1284 | | switch( bpl ) |
| 1274 | switch (bpl) |
| 1285 | 1275 | { |
| 1286 | 1276 | case 1: |
| 1287 | | snes_draw_tile(MAINSCREEN, 2, layer, snes_ppu.layer[layer].data + (tile << 4) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1277 | snes_draw_tile(SNES_MAINSCREEN, 2, layer, snes_ppu.layer[layer].data + (tile << 4) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1288 | 1278 | break; |
| 1289 | 1279 | case 2: |
| 1290 | 1280 | pal <<= 2; |
| 1291 | | snes_draw_tile(MAINSCREEN, 4, layer, snes_ppu.layer[layer].data + (tile << 5) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1281 | snes_draw_tile(SNES_MAINSCREEN, 4, layer, snes_ppu.layer[layer].data + (tile << 5) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1292 | 1282 | break; |
| 1293 | 1283 | case 4: |
| 1294 | 1284 | pal <<= 0; // n/a |
| 1295 | | snes_draw_tile(MAINSCREEN, 8, layer, snes_ppu.layer[layer].data + (tile << 6) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1285 | snes_draw_tile(SNES_MAINSCREEN, 8, layer, snes_ppu.layer[layer].data + (tile << 6) + ((curline % 8) * 2), (ii >> 1) * 8, 255, hflip, pal, 0); |
| 1296 | 1286 | break; |
| 1297 | 1287 | } |
| 1298 | 1288 | } |
| r7301 | r7302 | |
| 1307 | 1297 | UINT16 ii, jj, kk; |
| 1308 | 1298 | UINT32 addr = tileaddr; |
| 1309 | 1299 | |
| 1310 | | for( jj = 0; jj < 32; jj++ ) |
| 1300 | for (jj = 0; jj < 32; jj++) |
| 1311 | 1301 | { |
| 1312 | 1302 | addr = tileaddr + (jj * bpl * 16 * 32); |
| 1313 | | for( kk = 0; kk < 8; kk++ ) |
| 1303 | for (kk = 0; kk < 8; kk++) |
| 1314 | 1304 | { |
| 1315 | 1305 | UINT32 *destline = BITMAP_ADDR32(bitmap, jj * 8 + kk, 0); |
| 1316 | 1306 | |
| 1317 | 1307 | /* Clear buffers */ |
| 1318 | | memset( scanlines[MAINSCREEN].buffer, 0, SNES_SCR_WIDTH * 2 ); |
| 1319 | | memset( scanlines[MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2 ); |
| 1320 | | for( ii = 0; ii < 32; ii++ ) |
| 1308 | memset(scanlines[SNES_MAINSCREEN].buffer, 0, SNES_SCR_WIDTH * 2); |
| 1309 | memset(scanlines[SNES_MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2); |
| 1310 | for (ii = 0; ii < 32; ii++) |
| 1321 | 1311 | { |
| 1322 | | switch( bpl ) |
| 1312 | switch (bpl) |
| 1323 | 1313 | { |
| 1324 | 1314 | case 1: |
| 1325 | | snes_draw_tile(MAINSCREEN, 2, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1315 | snes_draw_tile(SNES_MAINSCREEN, 2, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1326 | 1316 | break; |
| 1327 | 1317 | case 2: |
| 1328 | | snes_draw_tile(MAINSCREEN, 4, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1318 | snes_draw_tile(SNES_MAINSCREEN, 4, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1329 | 1319 | break; |
| 1330 | 1320 | case 4: |
| 1331 | | snes_draw_tile(MAINSCREEN, 8, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1321 | snes_draw_tile(SNES_MAINSCREEN, 8, 0, addr, ii * 8, 255, 0, pal, 0); |
| 1332 | 1322 | break; |
| 1333 | 1323 | } |
| 1334 | 1324 | addr += (bpl * 16); |
| 1335 | 1325 | } |
| 1336 | 1326 | for (ii = 0; ii < SNES_SCR_WIDTH * 2; ii++) |
| 1337 | 1327 | { |
| 1338 | | int pixdata = scanlines[MAINSCREEN].buffer[ii]; |
| 1328 | int pixdata = scanlines[SNES_MAINSCREEN].buffer[ii]; |
| 1339 | 1329 | if (pixdata != 200) |
| 1340 | 1330 | destline[ii] = machine->pens[pixdata]; |
| 1341 | 1331 | } |
| r7301 | r7302 | |
| 1354 | 1344 | #define SNES_DBG_HORZ_POS 545 |
| 1355 | 1345 | |
| 1356 | 1346 | /* Check if the user has enabled or disabled stuff */ |
| 1357 | | if( curline == 0 ) |
| 1347 | if (curline == 0) |
| 1358 | 1348 | { |
| 1359 | 1349 | //UINT16 y = 1; |
| 1360 | 1350 | static const char WINLOGIC[4] = { '|', '&', '^', '!' }; |
| 1361 | 1351 | |
| 1362 | | if( !debug_options.input_count-- ) |
| 1352 | if (!debug_options.input_count--) |
| 1363 | 1353 | { |
| 1364 | 1354 | UINT8 toggles = input_port_read_safe(machine, "DEBUG2", 0); |
| 1365 | | if( toggles & 0x1 ) |
| 1355 | if (toggles & 0x01) |
| 1366 | 1356 | debug_options.bg_disabled[0] = !debug_options.bg_disabled[0]; |
| 1367 | | if( toggles & 0x2 ) |
| 1357 | if (toggles & 0x02) |
| 1368 | 1358 | debug_options.bg_disabled[1] = !debug_options.bg_disabled[1]; |
| 1369 | | if( toggles & 0x4 ) |
| 1359 | if (toggles & 0x04) |
| 1370 | 1360 | debug_options.bg_disabled[2] = !debug_options.bg_disabled[2]; |
| 1371 | | if( toggles & 0x8 ) |
| 1361 | if (toggles & 0x08) |
| 1372 | 1362 | debug_options.bg_disabled[3] = !debug_options.bg_disabled[3]; |
| 1373 | | if( toggles & 0x10 ) |
| 1363 | if (toggles & 0x10) |
| 1374 | 1364 | debug_options.bg_disabled[4] = !debug_options.bg_disabled[4]; |
| 1375 | | if( toggles & 0x20 ) |
| 1376 | | debug_options.draw_subscreen = !debug_options.draw_subscreen; |
| 1377 | | if( toggles & 0x40 ) |
| 1365 | if (toggles & 0x20) |
| 1366 | debug_options.draw_SNES_SUBSCREEN = !debug_options.draw_SNES_SUBSCREEN; |
| 1367 | if (toggles & 0x40) |
| 1378 | 1368 | debug_options.bg_disabled[5] = !debug_options.bg_disabled[5]; |
| 1379 | | if( toggles & 0x80 ) |
| 1369 | if (toggles & 0x80) |
| 1380 | 1370 | debug_options.windows_disabled = !debug_options.windows_disabled; |
| 1381 | 1371 | toggles = input_port_read_safe(machine, "DEBUG4", 0); |
| 1382 | | if( toggles & 0x01 ) |
| 1372 | if (toggles & 0x01) |
| 1383 | 1373 | debug_options.mode_disabled[0] = !debug_options.mode_disabled[0]; |
| 1384 | | if( toggles & 0x02 ) |
| 1374 | if (toggles & 0x02) |
| 1385 | 1375 | debug_options.mode_disabled[1] = !debug_options.mode_disabled[1]; |
| 1386 | | if( toggles & 0x04 ) |
| 1376 | if (toggles & 0x04) |
| 1387 | 1377 | debug_options.mode_disabled[2] = !debug_options.mode_disabled[2]; |
| 1388 | | if( toggles & 0x08 ) |
| 1378 | if (toggles & 0x08) |
| 1389 | 1379 | debug_options.mode_disabled[3] = !debug_options.mode_disabled[3]; |
| 1390 | | if( toggles & 0x10 ) |
| 1380 | if (toggles & 0x10) |
| 1391 | 1381 | debug_options.mode_disabled[4] = !debug_options.mode_disabled[4]; |
| 1392 | | if( toggles & 0x20 ) |
| 1382 | if (toggles & 0x20) |
| 1393 | 1383 | debug_options.mode_disabled[5] = !debug_options.mode_disabled[5]; |
| 1394 | | if( toggles & 0x40 ) |
| 1384 | if (toggles & 0x40) |
| 1395 | 1385 | debug_options.mode_disabled[6] = !debug_options.mode_disabled[6]; |
| 1396 | | if( toggles & 0x80 ) |
| 1386 | if (toggles & 0x80) |
| 1397 | 1387 | debug_options.mode_disabled[7] = !debug_options.mode_disabled[7]; |
| 1398 | 1388 | toggles = input_port_read_safe(machine, "DEBUG3", 0); |
| 1399 | | if( toggles & 0x4 ) |
| 1389 | if (toggles & 0x4) |
| 1400 | 1390 | debug_options.transparency_disabled = !debug_options.transparency_disabled; |
| 1401 | 1391 | debug_options.input_count = 5; |
| 1402 | 1392 | } |
| r7301 | r7302 | |
| 1510 | 1500 | UINT8 inp = input_port_read_safe(machine, "DEBUG3", 0); |
| 1511 | 1501 | UINT8 dt = 1 << ((dip & 0x3) - 1); |
| 1512 | 1502 | UINT8 dm = 1 << (((dip & 0xc) >> 2) - 1); |
| 1513 | | if( dt ) |
| 1503 | if (dt) |
| 1514 | 1504 | { |
| 1515 | 1505 | static INT16 pal = 0; |
| 1516 | 1506 | static UINT32 addr = 0; |
| 1517 | | if( curline == 0 ) |
| 1507 | if (curline == 0) |
| 1518 | 1508 | { |
| 1519 | | if( adjust & 0x1 ) addr += (dt * 16); |
| 1520 | | if( adjust & 0x2 ) addr -= (dt * 16); |
| 1521 | | if( adjust & 0x4 ) addr += (dt * 16 * 32); |
| 1522 | | if( adjust & 0x8 ) addr -= (dt * 16 * 32); |
| 1523 | | if( inp & 0x1 ) pal -= 1; |
| 1524 | | if( inp & 0x2 ) pal += 1; |
| 1525 | | if( pal < 0 ) pal = 0; |
| 1526 | | if( pal > 8 ) pal = 8; |
| 1527 | | for( ii = 0; ii < SNES_SCR_WIDTH; ii++ ) |
| 1509 | if (adjust & 0x1) addr += (dt * 16); |
| 1510 | if (adjust & 0x2) addr -= (dt * 16); |
| 1511 | if (adjust & 0x4) addr += (dt * 16 * 32); |
| 1512 | if (adjust & 0x8) addr -= (dt * 16 * 32); |
| 1513 | if (inp & 0x1) pal -= 1; |
| 1514 | if (inp & 0x2) pal += 1; |
| 1515 | if (pal < 0) pal = 0; |
| 1516 | if (pal > 8) pal = 8; |
| 1517 | for (ii = 0; ii < SNES_SCR_WIDTH; ii++) |
| 1528 | 1518 | { |
| 1529 | | scanlines[MAINSCREEN].buffer[ii] = 0; |
| 1519 | scanlines[SNES_MAINSCREEN].buffer[ii] = 0; |
| 1530 | 1520 | } |
| 1531 | 1521 | snes_dbg_draw_all_tiles(machine, bitmap, addr, dt, pal * 16 ); |
| 1532 | 1522 | } |
| 1533 | 1523 | return 1; |
| 1534 | 1524 | } |
| 1535 | | if( dm ) |
| 1525 | if (dm) |
| 1536 | 1526 | { |
| 1537 | 1527 | static UINT32 tmaddr = 0; |
| 1538 | 1528 | static INT8 tmbg = 0; |
| 1539 | 1529 | UINT32 *destline = BITMAP_ADDR32(bitmap, curline, 0); |
| 1540 | | if( curline == 0 ) |
| 1530 | if (curline == 0) |
| 1541 | 1531 | { |
| 1542 | | if( adjust & 0x1 ) tmaddr += 2; |
| 1543 | | if( adjust & 0x2 ) tmaddr -= 2; |
| 1544 | | if( adjust & 0x4 ) tmaddr += 64; |
| 1545 | | if( adjust & 0x8 ) tmaddr -= 64; |
| 1546 | | if( inp & 0x1 ) tmbg -= 1; |
| 1547 | | if( inp & 0x2 ) tmbg += 1; |
| 1548 | | if( tmbg < 0 ) tmbg = 0; |
| 1549 | | if( tmbg > 3 ) tmbg = 3; |
| 1532 | if (adjust & 0x1) tmaddr += 2; |
| 1533 | if (adjust & 0x2) tmaddr -= 2; |
| 1534 | if (adjust & 0x4) tmaddr += 64; |
| 1535 | if (adjust & 0x8) tmaddr -= 64; |
| 1536 | if (inp & 0x1) tmbg -= 1; |
| 1537 | if (inp & 0x2) tmbg += 1; |
| 1538 | if (tmbg < 0) tmbg = 0; |
| 1539 | if (tmbg > 3) tmbg = 3; |
| 1550 | 1540 | } |
| 1551 | 1541 | /* Clear zbuffer */ |
| 1552 | | memset( scanlines[MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH ); |
| 1542 | memset( scanlines[SNES_MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH ); |
| 1553 | 1543 | /* Draw back colour */ |
| 1554 | | for( ii = 0; ii < SNES_SCR_WIDTH; ii++ ) |
| 1555 | | scanlines[MAINSCREEN].buffer[ii] = machine->pens[0]; |
| 1544 | for (ii = 0; ii < SNES_SCR_WIDTH; ii++) |
| 1545 | scanlines[SNES_MAINSCREEN].buffer[ii] = machine->pens[0]; |
| 1556 | 1546 | snes_dbg_draw_maps(bitmap, tmaddr, dm, curline, tmbg ); |
| 1557 | 1547 | for (ii = 0; ii < SNES_SCR_WIDTH; ii++) |
| 1558 | 1548 | { |
| 1559 | | int pixdata = scanlines[MAINSCREEN].buffer[ii]; |
| 1549 | int pixdata = scanlines[SNES_MAINSCREEN].buffer[ii]; |
| 1560 | 1550 | if (pixdata != 200) |
| 1561 | 1551 | destline[ii] = machine->pens[pixdata]; |
| 1562 | 1552 | } |
| r7301 | r7302 | |
| 1570 | 1560 | *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 22) = machine->pens[dbg_mode_colours[snes_ram[BGMODE] & 0x7]]; |
| 1571 | 1561 | *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 12) = machine->pens[32767]; |
| 1572 | 1562 | *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767]; |
| 1573 | | for( ii = 0; ii < 5; ii++ ) |
| 1563 | for (ii = 0; ii < 5; ii++) |
| 1574 | 1564 | { |
| 1575 | 1565 | *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0]; |
| 1576 | 1566 | *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 9 + ii) = snes_cgram[FIXED_COLOUR]; |
| 1577 | 1567 | } |
| 1578 | 1568 | /* Draw window positions */ |
| 1579 | | scanlines[MAINSCREEN].buffer[snes_ram[WH0]] = machine->pens[dbg_mode_colours[0]]; |
| 1580 | | scanlines[MAINSCREEN].buffer[snes_ram[WH1]] = machine->pens[dbg_mode_colours[0]]; |
| 1581 | | scanlines[MAINSCREEN].buffer[snes_ram[WH2]] = machine->pens[dbg_mode_colours[2]]; |
| 1582 | | scanlines[MAINSCREEN].buffer[snes_ram[WH3]] = machine->pens[dbg_mode_colours[2]]; |
| 1569 | scanlines[SNES_MAINSCREEN].buffer[snes_ram[WH0]] = machine->pens[dbg_mode_colours[0]]; |
| 1570 | scanlines[SNES_MAINSCREEN].buffer[snes_ram[WH1]] = machine->pens[dbg_mode_colours[0]]; |
| 1571 | scanlines[SNES_MAINSCREEN].buffer[snes_ram[WH2]] = machine->pens[dbg_mode_colours[2]]; |
| 1572 | scanlines[SNES_MAINSCREEN].buffer[snes_ram[WH3]] = machine->pens[dbg_mode_colours[2]]; |
| 1583 | 1573 | #endif |
| 1584 | 1574 | return 0; |
| 1585 | 1575 | } |