From 9643ea2a4405d159491ca38955cdf35894129ba3 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 16 Mar 2010 08:19:23 +0000 Subject: [PATCH] not worth mention: snes.c: improved sprite overlap, simplified oam address handling, fixed sprite blend exception --- src/mame/machine/snes.c | 18 +++++------------- src/mame/video/snes.c | 42 ++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c index 4f04d692626..789ba3b9ea0 100644 --- a/src/mame/machine/snes.c +++ b/src/mame/machine/snes.c @@ -461,8 +461,7 @@ READ8_HANDLER( snes_r_io ) if (snes_ram[OAMDATA] == 0) { snes_ppu.oam.address++; - snes_ppu.oam.address_low = snes_ram[OAMADDL] = snes_ppu.oam.address & 0xff; - snes_ppu.oam.address_high = snes_ram[OAMADDH] = (snes_ppu.oam.address >> 8) & 0x1; + snes_ppu.oam.address &= 0x1ff; snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0; } return snes_ppu.ppu1_open_bus; @@ -687,11 +686,7 @@ READ8_HANDLER( snes_r_io ) #ifndef MESS case 0x4100: /* NSS Dip-Switches */ -#ifdef MAME_DEBUG - return input_port_read_safe(space->machine, "DEBUG1", 0); -#else return input_port_read(space->machine, "DSW"); -#endif /* MAME_DEBUG */ // case 0x4101: //PC: a104 - a10e - a12a //only nss_actr // case 0x420c: //PC: 9c7d - 8fab //only nss_ssoc @@ -705,7 +700,7 @@ READ8_HANDLER( snes_r_io ) /* Unsupported reads returns open bus */ // printf("%02x %02x\n",offset,snes_open_bus_r(space,0)); - return snes_open_bus_r(space,0); + return snes_open_bus_r(space, 0); } /* @@ -818,16 +813,14 @@ WRITE8_HANDLER( snes_w_io ) break; } case OAMADDL: /* Address for accessing OAM (low) */ - snes_ppu.oam.address_low = data; snes_ppu.oam.saved_address_low = data; - snes_ppu.oam.address = ((snes_ppu.oam.address_high & 0x1) << 8) + data; + snes_ppu.oam.address = (snes_ppu.oam.address & 0xff00) + data; snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0; snes_ram[OAMDATA] = 0; break; case OAMADDH: /* Address for accessing OAM (high) */ - snes_ppu.oam.address_high = data & 0x1; snes_ppu.oam.saved_address_high = data; - snes_ppu.oam.address = ((data & 0x1) << 8) + snes_ppu.oam.address_low; + snes_ppu.oam.address = (snes_ppu.oam.address & 0x00ff) | ((data & 0x01) << 8); snes_ppu.oam.priority_rotation = BIT(data, 7); snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0; snes_ram[OAMDATA] = 0; @@ -867,8 +860,7 @@ WRITE8_HANDLER( snes_w_io ) { snes_ram[OAMDATA] = 0; snes_ppu.oam.address++; - snes_ppu.oam.address_low = snes_ram[OAMADDL] = snes_ppu.oam.address & 0xff; - snes_ppu.oam.address_high = snes_ram[OAMADDH] = (snes_ppu.oam.address >> 8) & 0x1; + snes_ppu.oam.address &= 0x1ff; snes_ppu.oam.first_sprite = snes_ppu.oam.priority_rotation ? (snes_ppu.oam.address >> 1) & 127 : 0; } return; diff --git a/src/mame/video/snes.c b/src/mame/video/snes.c index de56cb8b8f5..9822a85507a 100644 --- a/src/mame/video/snes.c +++ b/src/mame/video/snes.c @@ -514,10 +514,11 @@ INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 * that it takes a blend parameter. *****************************************/ -INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) +INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal ) { UINT8 mask, plane[4]; UINT16 c; + int blend; INT16 ii, jj; plane[0] = snes_vram[tileaddr]; @@ -548,9 +549,11 @@ INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UIN mask >>= 1; } - if (ii >= 0 && ii < SNES_SCR_WIDTH && scanlines[SNES_MAINSCREEN].enable) + INT16 pos = ii & 0x1ff; + + if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_MAINSCREEN].enable) { - if (scanlines[SNES_MAINSCREEN].priority[ii] <= priority) + if (scanlines[SNES_MAINSCREEN].priority[pos] <= priority) { UINT8 clr = colour; @@ -559,24 +562,25 @@ INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UIN #endif /* SNES_LAYER_DEBUG */ /* Clip to windows */ if (scanlines[SNES_MAINSCREEN].clip) - clr &= snes_ppu.clipmasks[SNES_OAM][ii]; + clr &= snes_ppu.clipmasks[SNES_OAM][pos]; /* Only draw if we have a colour (0 == transparent) */ if (clr) { c = snes_cgram[(pal + clr) % FIXED_COLOUR]; + blend = (pal + clr < 192) ? 1 : 0; - scanlines[SNES_MAINSCREEN].buffer[ii] = c; - scanlines[SNES_MAINSCREEN].priority[ii] = priority; - scanlines[SNES_MAINSCREEN].layer[ii] = SNES_OAM; - scanlines[SNES_MAINSCREEN].blend_exception[ii] = blend; + scanlines[SNES_MAINSCREEN].buffer[pos] = c; + scanlines[SNES_MAINSCREEN].priority[pos] = priority; + scanlines[SNES_MAINSCREEN].layer[pos] = SNES_OAM; + scanlines[SNES_MAINSCREEN].blend_exception[pos] = blend; } } } - if (ii >= 0 && ii < SNES_SCR_WIDTH && scanlines[SNES_SUBSCREEN].enable) + if (pos >= 0 && pos < SNES_SCR_WIDTH && scanlines[SNES_SUBSCREEN].enable) { - if (scanlines[SNES_SUBSCREEN].priority[ii] <= priority) + if (scanlines[SNES_SUBSCREEN].priority[pos] <= priority) { UINT8 clr = colour; @@ -585,17 +589,18 @@ INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UIN #endif /* SNES_LAYER_DEBUG */ /* Clip to windows */ if (scanlines[SNES_SUBSCREEN].clip) - clr &= snes_ppu.clipmasks[SNES_OAM][ii]; + clr &= snes_ppu.clipmasks[SNES_OAM][pos]; /* Only draw if we have a colour (0 == transparent) */ if (clr) { c = snes_cgram[(pal + clr) % FIXED_COLOUR]; + blend = (pal + clr < 192) ? 1 : 0; - scanlines[SNES_SUBSCREEN].buffer[ii] = c; - scanlines[SNES_SUBSCREEN].priority[ii] = priority; - scanlines[SNES_SUBSCREEN].layer[ii] = SNES_OAM; - scanlines[SNES_SUBSCREEN].blend_exception[ii] = blend; + scanlines[SNES_SUBSCREEN].buffer[pos] = c; + scanlines[SNES_SUBSCREEN].priority[pos] = priority; + scanlines[SNES_SUBSCREEN].layer[pos] = SNES_OAM; + scanlines[SNES_SUBSCREEN].blend_exception[pos] = blend; } } } @@ -1226,7 +1231,7 @@ static void snes_update_objects_rto( UINT16 curline ) static void snes_update_objects( UINT8 priority_tbl ) { - UINT8 blend, priority; + UINT8 priority; UINT32 charaddr; int i; static const UINT8 table_obj_priority[10][4] = { @@ -1263,9 +1268,8 @@ static void snes_update_objects( UINT8 priority_tbl ) if (oam_tilelist[i].tileaddr == 0xffff) continue; - blend = (oam_tilelist[i].pal < 192) ? 1 : 0; priority = table_obj_priority[priority_tbl][oam_tilelist[i].priority]; - snes_draw_tile_object(charaddr + oam_tilelist[i].tileaddr, oam_tilelist[i].x, priority, oam_tilelist[i].hflip, oam_tilelist[i].pal, blend); + snes_draw_tile_object(charaddr + oam_tilelist[i].tileaddr, oam_tilelist[i].x, priority, oam_tilelist[i].hflip, oam_tilelist[i].pal); } } @@ -1356,8 +1360,8 @@ static void snes_update_mode_5( UINT16 curline ) return; #endif /* SNES_LAYER_DEBUG */ - snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0); snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0); + snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0); snes_update_objects(5); }