snes wip: added a couple of registers to snes_ppu struct and a few cosmetic cleanups

This commit is contained in:
Fabio Priuli 2010-02-10 08:38:59 +00:00
parent dab2213b59
commit f2bb738b9e
3 changed files with 457 additions and 422 deletions

View File

@ -376,6 +376,26 @@ HAS_SPC7110_RTC,
HAS_UNK
};
/* offset-per-tile modes */
enum
{
SNES_OPT_NONE = 0,
SNES_OPT_MODE2,
SNES_OPT_MODE4,
SNES_OPT_MODE6
};
/* layers */
enum
{
SNES_BG1 = 0,
SNES_BG2,
SNES_BG3,
SNES_BG4,
SNES_OAM,
SNES_COLOR
};
/*----------- defined in machine/snes.c -----------*/
extern DRIVER_INIT( snes );
@ -451,12 +471,14 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
UINT16 shift_vert;
} offset;
} layer[5]; // this is for the BG1 - BG2 - BG3 - BG4 - OBJ layers
struct
{
UINT8 window1_enabled, window1_invert;
UINT8 window2_enabled, window2_invert;
UINT8 wlog_mask;
} colour; // this is for the color (which is 'seen' as a layer by the window masking code)
struct
{
UINT8 address_low;
@ -471,11 +493,13 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
UINT8 flip;
UINT16 write_latch;
} oam;
struct
{
UINT16 horizontal[4];
UINT16 vertical[4];
} bgd_offset;
struct
{
UINT16 latch_horz;
@ -485,6 +509,7 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
UINT8 last_visible_line;
UINT8 interlace_count;
} beam;
struct
{
UINT8 repeat;
@ -498,7 +523,9 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
INT16 origin_y;
UINT16 hor_offset;
UINT16 ver_offset;
UINT8 extbg;
} mode7;
UINT8 mosaic_size;
UINT8 main_color_mask;
UINT8 sub_color_mask;
@ -522,6 +549,11 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
UINT8 mode;
UINT8 interlace; //doubles the visible resolution
UINT8 obj_interlace;
UINT8 screen_brightness;
UINT8 screen_disabled;
UINT8 pseudo_hires;
UINT8 color_modes;
UINT8 stat77_flags;
};
struct snes_cart_info

View File

@ -120,7 +120,7 @@ static TIMER_CALLBACK( snes_reset_oam_address )
// make sure we're in the 65816's context since we're messing with the OAM and stuff
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
if(!(snes_ram[INIDISP]&0x80)) //Reset OAM address, byuu says it happens at H=10
if (!(snes_ppu.screen_disabled)) //Reset OAM address, byuu says it happens at H=10
{
memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low ); /* Reset oam address */
memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high );
@ -248,8 +248,8 @@ static TIMER_CALLBACK( snes_scanline_tick )
{ /* VBlank is over, time for a new frame */
snes_ram[HVBJOY] &= 0x7f; /* Clear vblank bit */
snes_ram[RDNMI] &= 0x7f; /* Clear nmi occured bit */
snes_ram[STAT77] &= 0x3f; /* Clear Time Over and Range Over bits */
snes_ram[STAT78] ^= 0x80; /* Toggle field flag */
snes_ppu.stat77_flags &= 0x3f; /* Clear Time Over and Range Over bits */
cputag_set_input_line(machine, "maincpu", G65816_LINE_NMI, CLEAR_LINE );
}
@ -342,7 +342,7 @@ static void snes_dynamic_res_change( running_machine *machine )
visarea.max_x = (SNES_SCR_WIDTH * 2) - 1;
// fixme: should compensate for SNES_DBG_video
if( snes_ppu.mode == 5 || snes_ppu.mode == 6 )
if (snes_ram[SETINI] & 0x08 || snes_ppu.mode == 5 || snes_ppu.mode == 6 )
snes_htmult = 2;
else
snes_htmult = 1;
@ -597,11 +597,11 @@ READ8_HANDLER( snes_r_io )
return snes_ppu.ppu2_open_bus;
}
case STAT77: /* PPU status flag and version number */
value = snes_ram[offset] & 0xc0; // 0x80 & 0x40 are Time Over / Range Over Sprite flags, set by the video code
value = snes_ppu.stat77_flags & 0xc0; // 0x80 & 0x40 are Time Over / Range Over Sprite flags, set by the video code
// 0x20 - Master/slave mode select. Little is known about this bit. We always seem to read back 0 here.
value |= (snes_ppu.ppu1_open_bus & 0x10);
value |= (snes_ppu.ppu1_version & 0x0f);
snes_ram[offset] = value; // not sure if this is needed...
snes_ppu.stat77_flags = value; // not sure if this is needed...
snes_ppu.ppu1_open_bus = value;
return snes_ppu.ppu1_open_bus;
case STAT78: /* PPU status flag and version number */
@ -808,14 +808,16 @@ WRITE8_HANDLER( snes_w_io )
switch (offset)
{
case INIDISP: /* Initial settings for screen */
if((snes_ram[INIDISP] & 0x80) && (!(data & 0x80))) //a 1->0 force blank transition causes a reset OAM address
if ((snes_ppu.screen_disabled & 0x80) && (!(data & 0x80))) //a 1->0 force blank transition causes a reset OAM address
{
memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low);
memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high);
}
snes_ppu.screen_disabled = data & 0x80;
snes_ppu.screen_brightness = (data & 0x0f) + 1;
break;
case OBSEL: /* Object size and data area designation */
snes_ppu.layer[4].data = ((data & 0x3) * 0x2000) << 1;
snes_ppu.layer[SNES_OAM].data = ((data & 0x3) * 0x2000) << 1;
snes_ppu.oam.name_select = (((data & 0x18) >> 3) * 0x1000) << 1;
/* Determine object size */
switch ((data & 0xe0) >> 5)
@ -912,19 +914,19 @@ WRITE8_HANDLER( snes_w_io )
snes_ppu.mode = data & 0x07;
snes_dynamic_res_change(space->machine);
snes_ppu.bg3_priority_bit = data & 0x08;
snes_ppu.layer[0].tile_size = (data >> 4) & 0x1;
snes_ppu.layer[1].tile_size = (data >> 5) & 0x1;
snes_ppu.layer[2].tile_size = (data >> 6) & 0x1;
snes_ppu.layer[3].tile_size = (data >> 7) & 0x1;
snes_ppu.layer[SNES_BG1].tile_size = (data >> 4) & 0x1;
snes_ppu.layer[SNES_BG2].tile_size = (data >> 5) & 0x1;
snes_ppu.layer[SNES_BG3].tile_size = (data >> 6) & 0x1;
snes_ppu.layer[SNES_BG4].tile_size = (data >> 7) & 0x1;
snes_ppu.update_offsets = 1;
break;
case MOSAIC: /* Size and screen designation for mosaic */
/* FIXME: We support horizontal mosaic only partially */
snes_ppu.mosaic_size = (data & 0xf0) >> 4;
snes_ppu.layer[0].mosaic_enabled = data & 0x01;
snes_ppu.layer[1].mosaic_enabled = data & 0x02;
snes_ppu.layer[2].mosaic_enabled = data & 0x04;
snes_ppu.layer[3].mosaic_enabled = data & 0x08;
snes_ppu.layer[SNES_BG1].mosaic_enabled = data & 0x01;
snes_ppu.layer[SNES_BG2].mosaic_enabled = data & 0x02;
snes_ppu.layer[SNES_BG3].mosaic_enabled = data & 0x04;
snes_ppu.layer[SNES_BG4].mosaic_enabled = data & 0x08;
break;
case BG1SC: /* Address for storing SC data BG1 SC size designation */
case BG2SC: /* Address for storing SC data BG2 SC size designation */
@ -934,18 +936,18 @@ WRITE8_HANDLER( snes_w_io )
snes_ppu.layer[offset - BG1SC].map_size = data & 0x3;
break;
case BG12NBA: /* Address for BG 1 and 2 character data */
snes_ppu.layer[0].data = (data & 0xf) << 13;
snes_ppu.layer[1].data = (data & 0xf0) << 9;
snes_ppu.layer[SNES_BG1].data = (data & 0xf) << 13;
snes_ppu.layer[SNES_BG2].data = (data & 0xf0) << 9;
break;
case BG34NBA: /* Address for BG 3 and 4 character data */
snes_ppu.layer[2].data = (data & 0xf) << 13;
snes_ppu.layer[3].data = (data & 0xf0) << 9;
snes_ppu.layer[SNES_BG3].data = (data & 0xf) << 13;
snes_ppu.layer[SNES_BG4].data = (data & 0xf0) << 9;
break;
// Anomie says "H Current = (Byte<<8) | (Prev&~7) | ((Current>>8)&7); V Current = (Current<<8) | Prev;" and Prev is shared by all scrolls but in Mode 7!
case BG1HOFS: /* BG1 - horizontal scroll (DW) */
/* In Mode 0->6 we use ppu_last_scroll as Prev */
snes_ppu.layer[0].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[0].offset.horizontal >> 8) & 7);
snes_ppu.layer[SNES_BG1].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[SNES_BG1].offset.horizontal >> 8) & 7);
snes_ppu.ppu_last_scroll = data;
/* In Mode 7 we use mode7_last_scroll as Prev */
snes_ppu.mode7.hor_offset = (data << 8) | (snes_ppu.mode7_last_scroll & ~7) | ((snes_ppu.mode7.hor_offset >> 8) & 7);
@ -954,7 +956,7 @@ WRITE8_HANDLER( snes_w_io )
return;
case BG1VOFS: /* BG1 - vertical scroll (DW) */
/* In Mode 0->6 we use ppu_last_scroll as Prev */
snes_ppu.layer[0].offset.vertical = (data << 8) | snes_ppu.ppu_last_scroll;
snes_ppu.layer[SNES_BG1].offset.vertical = (data << 8) | snes_ppu.ppu_last_scroll;
snes_ppu.ppu_last_scroll = data;
/* In Mode 7 we use mode7_last_scroll as Prev */
snes_ppu.mode7.ver_offset = (data << 8) | snes_ppu.mode7_last_scroll;
@ -962,32 +964,32 @@ WRITE8_HANDLER( snes_w_io )
snes_ppu.update_offsets = 1;
return;
case BG2HOFS: /* BG2 - horizontal scroll (DW) */
snes_ppu.layer[1].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[1].offset.horizontal >> 8) & 7);
snes_ppu.layer[SNES_BG2].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[SNES_BG2].offset.horizontal >> 8) & 7);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
case BG2VOFS: /* BG2 - vertical scroll (DW) */
snes_ppu.layer[1].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.layer[SNES_BG2].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
case BG3HOFS: /* BG3 - horizontal scroll (DW) */
snes_ppu.layer[2].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[2].offset.horizontal >> 8) & 7);
snes_ppu.layer[SNES_BG3].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[SNES_BG3].offset.horizontal >> 8) & 7);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
case BG3VOFS: /* BG3 - vertical scroll (DW) */
snes_ppu.layer[2].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.layer[SNES_BG3].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
case BG4HOFS: /* BG4 - horizontal scroll (DW) */
snes_ppu.layer[3].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[3].offset.horizontal >> 8) & 7);
snes_ppu.layer[SNES_BG4].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[SNES_BG4].offset.horizontal >> 8) & 7);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
case BG4VOFS: /* BG4 - vertical scroll (DW) */
snes_ppu.layer[3].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.layer[SNES_BG4].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll);
snes_ppu.ppu_last_scroll = data;
snes_ppu.update_offsets = 1;
return;
@ -1124,38 +1126,38 @@ WRITE8_HANDLER( snes_w_io )
case W12SEL: /* Window mask settings for BG1-2 */
if (data != snes_ram[offset])
{
snes_ppu.layer[0].window1_invert = data & 0x01;
snes_ppu.layer[0].window1_enabled = data & 0x02;
snes_ppu.layer[0].window2_invert = data & 0x04;
snes_ppu.layer[0].window2_enabled = data & 0x08;
snes_ppu.layer[1].window1_invert = data & 0x10;
snes_ppu.layer[1].window1_enabled = data & 0x20;
snes_ppu.layer[1].window2_invert = data & 0x40;
snes_ppu.layer[1].window2_enabled = data & 0x80;
snes_ppu.layer[SNES_BG1].window1_invert = data & 0x01;
snes_ppu.layer[SNES_BG1].window1_enabled = data & 0x02;
snes_ppu.layer[SNES_BG1].window2_invert = data & 0x04;
snes_ppu.layer[SNES_BG1].window2_enabled = data & 0x08;
snes_ppu.layer[SNES_BG2].window1_invert = data & 0x10;
snes_ppu.layer[SNES_BG2].window1_enabled = data & 0x20;
snes_ppu.layer[SNES_BG2].window2_invert = data & 0x40;
snes_ppu.layer[SNES_BG2].window2_enabled = data & 0x80;
snes_ppu.update_windows = 1;
}
break;
case W34SEL: /* Window mask settings for BG3-4 */
if (data != snes_ram[offset])
{
snes_ppu.layer[2].window1_invert = data & 0x01;
snes_ppu.layer[2].window1_enabled = data & 0x02;
snes_ppu.layer[2].window2_invert = data & 0x04;
snes_ppu.layer[2].window2_enabled = data & 0x08;
snes_ppu.layer[3].window1_invert = data & 0x10;
snes_ppu.layer[3].window1_enabled = data & 0x20;
snes_ppu.layer[3].window2_invert = data & 0x40;
snes_ppu.layer[3].window2_enabled = data & 0x80;
snes_ppu.layer[SNES_BG3].window1_invert = data & 0x01;
snes_ppu.layer[SNES_BG3].window1_enabled = data & 0x02;
snes_ppu.layer[SNES_BG3].window2_invert = data & 0x04;
snes_ppu.layer[SNES_BG3].window2_enabled = data & 0x08;
snes_ppu.layer[SNES_BG4].window1_invert = data & 0x10;
snes_ppu.layer[SNES_BG4].window1_enabled = data & 0x20;
snes_ppu.layer[SNES_BG4].window2_invert = data & 0x40;
snes_ppu.layer[SNES_BG4].window2_enabled = data & 0x80;
snes_ppu.update_windows = 1;
}
break;
case WOBJSEL: /* Window mask settings for objects */
if (data != snes_ram[offset])
{
snes_ppu.layer[4].window1_invert = data & 0x01;
snes_ppu.layer[4].window1_enabled = data & 0x02;
snes_ppu.layer[4].window2_invert = data & 0x04;
snes_ppu.layer[4].window2_enabled = data & 0x08;
snes_ppu.layer[SNES_OAM].window1_invert = data & 0x01;
snes_ppu.layer[SNES_OAM].window1_enabled = data & 0x02;
snes_ppu.layer[SNES_OAM].window2_invert = data & 0x04;
snes_ppu.layer[SNES_OAM].window2_enabled = data & 0x08;
snes_ppu.colour.window1_invert = data & 0x10;
snes_ppu.colour.window1_enabled = data & 0x20;
snes_ppu.colour.window2_invert = data & 0x40;
@ -1194,17 +1196,17 @@ WRITE8_HANDLER( snes_w_io )
case WBGLOG: /* Window mask logic for BG's */
if (data != snes_ram[offset])
{
snes_ppu.layer[0].wlog_mask = data & 0x03;
snes_ppu.layer[1].wlog_mask = (data & 0x0c) >> 2;
snes_ppu.layer[2].wlog_mask = (data & 0x30) >> 4;
snes_ppu.layer[3].wlog_mask = (data & 0xc0) >> 6;
snes_ppu.layer[SNES_BG1].wlog_mask = data & 0x03;
snes_ppu.layer[SNES_BG2].wlog_mask = (data & 0x0c) >> 2;
snes_ppu.layer[SNES_BG3].wlog_mask = (data & 0x30) >> 4;
snes_ppu.layer[SNES_BG4].wlog_mask = (data & 0xc0) >> 6;
snes_ppu.update_windows = 1;
}
break;
case WOBJLOG: /* Window mask logic for objects */
if (data != snes_ram[offset])
{
snes_ppu.layer[4].wlog_mask = data & 0x03;
snes_ppu.layer[SNES_OAM].wlog_mask = data & 0x03;
snes_ppu.colour.wlog_mask = (data & 0x0c) >> 2;
snes_ppu.update_windows = 1;
}
@ -1224,18 +1226,18 @@ WRITE8_HANDLER( snes_w_io )
snes_ppu.sub_bg_enabled[4] = data & 0x10;
break;
case TMW: /* Window mask for main screen designation */
snes_ppu.layer[0].main_window_enabled = data & 0x01;
snes_ppu.layer[1].main_window_enabled = data & 0x02;
snes_ppu.layer[2].main_window_enabled = data & 0x04;
snes_ppu.layer[3].main_window_enabled = data & 0x08;
snes_ppu.layer[4].main_window_enabled = data & 0x10;
snes_ppu.layer[SNES_BG1].main_window_enabled = data & 0x01;
snes_ppu.layer[SNES_BG2].main_window_enabled = data & 0x02;
snes_ppu.layer[SNES_BG3].main_window_enabled = data & 0x04;
snes_ppu.layer[SNES_BG4].main_window_enabled = data & 0x08;
snes_ppu.layer[SNES_OAM].main_window_enabled = data & 0x10;
break;
case TSW: /* Window mask for subscreen designation */
snes_ppu.layer[0].sub_window_enabled = data & 0x01;
snes_ppu.layer[1].sub_window_enabled = data & 0x02;
snes_ppu.layer[2].sub_window_enabled = data & 0x04;
snes_ppu.layer[3].sub_window_enabled = data & 0x08;
snes_ppu.layer[4].sub_window_enabled = data & 0x10;
snes_ppu.layer[SNES_BG1].sub_window_enabled = data & 0x01;
snes_ppu.layer[SNES_BG2].sub_window_enabled = data & 0x02;
snes_ppu.layer[SNES_BG3].sub_window_enabled = data & 0x04;
snes_ppu.layer[SNES_BG4].sub_window_enabled = data & 0x08;
snes_ppu.layer[SNES_OAM].sub_window_enabled = data & 0x10;
break;
case CGWSEL: /* Initial settings for Fixed colour addition or screen addition */
/* FIXME: We don't support direct select for modes 3 & 4 or subscreen window stuff */
@ -1249,18 +1251,18 @@ WRITE8_HANDLER( snes_w_io )
#endif
break;
case CGADSUB: /* Addition/Subtraction designation for each screen */
snes_ppu.color_modes = data & 0xc0;
{
UINT8 sub = (data & 0x80) >> 7;
snes_ppu.layer[0].blend = (data & 0x1) << sub;
snes_ppu.layer[1].blend = ((data & 0x2) >> 1) << sub;
snes_ppu.layer[2].blend = ((data & 0x4) >> 2) << sub;
snes_ppu.layer[3].blend = ((data & 0x8) >> 3) << sub;
snes_ppu.layer[4].blend = ((data & 0x10) >> 4) << sub;
snes_ppu.layer[SNES_BG1].blend = (data & 0x1) << sub;
snes_ppu.layer[SNES_BG2].blend = ((data & 0x2) >> 1) << sub;
snes_ppu.layer[SNES_BG3].blend = ((data & 0x4) >> 2) << sub;
snes_ppu.layer[SNES_BG4].blend = ((data & 0x8) >> 3) << sub;
snes_ppu.layer[SNES_OAM].blend = ((data & 0x10) >> 4) << sub;
} break;
case COLDATA: /* Fixed colour data for fixed colour addition/subtraction */
{
/* Store it in the extra space we made in the CGRAM
* It doesn't really go there, but it's as good a place as any. */
/* Store it in the extra space we made in the CGRAM. It doesn't really go there, but it's as good a place as any. */
UINT8 r, g, b;
/* Get existing value. */
@ -1278,9 +1280,11 @@ WRITE8_HANDLER( snes_w_io )
} break;
case SETINI: /* Screen mode/video select */
/* FIXME: We only support line count and interlace here */
snes_ppu.interlace = (data & 1) ? 2 : 1;
snes_ppu.obj_interlace = (data & 2) ? 2 : 1;
snes_ppu.beam.last_visible_line = (data & 0x4) ? 240 : 225;
snes_ppu.interlace = (data & 0x01) ? 2 : 1;
snes_ppu.obj_interlace = (data & 0x02) ? 2 : 1;
snes_ppu.beam.last_visible_line = (data & 0x04) ? 240 : 225;
snes_ppu.pseudo_hires = data & 0x08;
snes_ppu.mode7.extbg = data & 0x40;
snes_dynamic_res_change(space->machine);
#ifdef SNES_DBG_REG_W
if ((data & 0x8) != (snes_ram[SETINI] & 0x8))
@ -1586,7 +1590,10 @@ READ8_HANDLER( snes_r_bank3 )
else if (snes_cart.mode & 5) /* Mode 20 & 22 */
{
if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20)) //FIXME: check this
value = snes_ram[0x200000 + ((offset & ~0x8000) | 0x8000)]; /* Reserved */
{
value = 0xff; /* Reserved */
//value = snes_ram[0x200000 + ((offset & ~0x8000) | 0x8000)]; // is this hack still needed? /* Reserved */
}
else
value = snes_ram[0x400000 + offset];
}

View File

@ -140,8 +140,8 @@ enum
INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 clip, UINT8 black_pen_clip )
{
if( (black_pen_clip == SNES_CLIP_ALL2) ||
(black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[5][offset]) ||
(black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[5][offset]))
(black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) ||
(black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset]))
*colour = 0; //clip to black before color math
if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF
@ -151,8 +151,8 @@ INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 cli
if( !debug_options.transparency_disabled )
#endif /* MAME_DEBUG */
if( (clip == SNES_CLIP_ALL) ||
(clip == SNES_CLIP_IN && !snes_ppu.clipmasks[5][offset]) ||
(clip == SNES_CLIP_OUT && snes_ppu.clipmasks[5][offset]) )
(clip == SNES_CLIP_IN && !snes_ppu.clipmasks[SNES_COLOR][offset]) ||
(clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset]) )
{
UINT16 r, g, b;
@ -165,7 +165,7 @@ INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 cli
b = ((*colour & 0x7c00) >> 10) + ((scanlines[SUBSCREEN].buffer[offset] & 0x7c00) >> 10);
/* don't halve for the back colour */
if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
{
r >>= 1;
g >>= 1;
@ -179,7 +179,7 @@ INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 cli
b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10);
/* don't halve for the back colour */
if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
{
r >>= 1;
g >>= 1;
@ -203,7 +203,7 @@ INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 cli
if( b > 0x1f ) b = 0;
/* don't halve for the back colour */
if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
{
r >>= 1;
g >>= 1;
@ -220,7 +220,7 @@ INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 mode, UINT8 cli
if( b > 0x1f ) b = 0;
/* don't halve for the back colour */
if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
if ((snes_ppu.color_modes & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]))
{
r >>= 1;
g >>= 1;
@ -385,9 +385,9 @@ INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8
if (!debug_options.windows_disabled)
#endif /* MAME_DEBUG */
/* Clip to windows */
window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[4].sub_window_enabled;
window_enabled = (screen == MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled;
if (window_enabled)
colour &= snes_ppu.clipmasks[4][ii];
colour &= snes_ppu.clipmasks[SNES_OAM][ii];
/* Only draw if we have a colour (0 == transparent) */
if (colour)
@ -396,7 +396,7 @@ INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8
{
c = snes_cgram[pal + colour];
if (blend && screen == MAINSCREEN) /* Only blend main screens */
snes_draw_blend(ii/snes_htmult, &c, snes_ppu.layer[4].blend, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
snes_draw_blend(ii/snes_htmult, &c, snes_ppu.layer[SNES_OAM].blend, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
scanlines[screen].buffer[ii] = c;
scanlines[screen].zbuf[ii] = priority;
@ -654,13 +654,13 @@ static void snes_update_line_mode7(UINT8 screen, UINT8 priority_a, UINT8 priorit
/* MOSAIC - to be verified */
if (layer == 1) // BG2 use two different bits for horizontal and vertical mosaic
{
mosaic_x = snes_ppu.mosaic_table[snes_ppu.layer[1].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_y = snes_ppu.mosaic_table[snes_ppu.layer[0].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_x = snes_ppu.mosaic_table[snes_ppu.layer[SNES_BG2].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_y = snes_ppu.mosaic_table[snes_ppu.layer[SNES_BG1].mosaic_enabled ? snes_ppu.mosaic_size : 0];
}
else // BG1 works as usual
{
mosaic_x = snes_ppu.mosaic_table[snes_ppu.layer[0].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_y = snes_ppu.mosaic_table[snes_ppu.layer[0].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_x = snes_ppu.mosaic_table[snes_ppu.layer[SNES_BG1].mosaic_enabled ? snes_ppu.mosaic_size : 0];
mosaic_y = snes_ppu.mosaic_table[snes_ppu.layer[SNES_BG1].mosaic_enabled ? snes_ppu.mosaic_size : 0];
}
/* Let's do some mode7 drawing huh? */
@ -830,9 +830,9 @@ static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curlin
if( (x + (count << 3) < SNES_SCR_WIDTH + 8) )
{
if( widemode )
snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1);
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);
else
snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0);
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);
}
time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
}
@ -844,24 +844,21 @@ static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curlin
if( (x + (xs << 3) < SNES_SCR_WIDTH + 8) )
{
if( widemode )
snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1);
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);
else
snes_draw_tile_object(screen, snes_ppu.layer[4].data + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0);
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);
}
time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
}
}
/* Increase range_over.
* Stop drawing if exceeded 32 objects and
* enforcing that limit is enabled */
/* Increase range_over. Stop drawing if exceeded 32 objects and enforcing that limit is enabled */
range_over++;
if (range_over == 32) //&& (input_port_read(machine, "INTERNAL") & 0x01) )
{
/* Set the flag in STAT77 register */
snes_ram[STAT77] |= 0x40;
/* FIXME: This stops the SNESTest rom from drawing the object
* test properly. Maybe we shouldn't stop drawing? */
snes_ppu.stat77_flags |= 0x40;
/* FIXME: This stops the SNESTest rom from drawing the object test properly. Maybe we shouldn't stop drawing? */
/* return; */
}
}
@ -870,7 +867,7 @@ static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curlin
if (time_over >= 34)
{
/* Set the flag in STAT77 register */
snes_ram[STAT77] |= 0x80;
snes_ppu.stat77_flags |= 0x80;
}
}
@ -964,11 +961,10 @@ static void snes_update_mode_6( UINT8 screen, UINT16 curline )
static void snes_update_mode_7( UINT8 screen, UINT16 curline )
{
UINT8 extbg_mode = snes_ram[SETINI] & 0x40;
UINT8 *bg_enabled;
bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
if (!extbg_mode)
if (!snes_ppu.mode7.extbg)
{
if (bg_enabled[4]) snes_update_objects(screen, 7, curline);
if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, 0, curline);
@ -1071,7 +1067,7 @@ static void snes_update_windowmasks(void)
}
/* update colour window */
snes_ppu.clipmasks[5][ii] = 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = 0xff;
w1 = w2 = -1;
if (snes_ppu.colour.window1_enabled)
{
@ -1098,23 +1094,23 @@ static void snes_update_windowmasks(void)
switch (snes_ppu.colour.wlog_mask)
{
case 0x0: /* OR */
snes_ppu.clipmasks[5][ii] = w1 | w2 ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = w1 | w2 ? 0x00 : 0xff;
break;
case 0x4: /* AND */
snes_ppu.clipmasks[5][ii] = w1 & w2 ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = w1 & w2 ? 0x00 : 0xff;
break;
case 0x8: /* XOR */
snes_ppu.clipmasks[5][ii] = w1 ^ w2 ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = w1 ^ w2 ? 0x00 : 0xff;
break;
case 0xc: /* XNOR */
snes_ppu.clipmasks[5][ii] = !(w1 ^ w2) ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = !(w1 ^ w2) ? 0x00 : 0xff;
break;
}
}
else if (w1 >= 0)
snes_ppu.clipmasks[5][ii] = w1 ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = w1 ? 0x00 : 0xff;
else if (w2 >= 0)
snes_ppu.clipmasks[5][ii] = w2 ? 0x00 : 0xff;
snes_ppu.clipmasks[SNES_COLOR][ii] = w2 ? 0x00 : 0xff;
}
}
@ -1135,14 +1131,14 @@ static void snes_update_offsets(void)
}
#if 0
popmessage("%04x %04x|%04x %04x|%04x %04x|%04x %04x",
snes_ppu.layer[0].offset.tile_horz,
snes_ppu.layer[0].offset.tile_vert,
snes_ppu.layer[1].offset.tile_horz,
snes_ppu.layer[1].offset.tile_vert,
snes_ppu.layer[2].offset.tile_horz,
snes_ppu.layer[2].offset.tile_vert,
snes_ppu.layer[3].offset.tile_horz,
snes_ppu.layer[3].offset.tile_vert
snes_ppu.layer[SNES_BG1].offset.tile_horz,
snes_ppu.layer[SNES_BG1].offset.tile_vert,
snes_ppu.layer[SNES_BG2].offset.tile_horz,
snes_ppu.layer[SNES_BG2].offset.tile_vert,
snes_ppu.layer[SNES_BG3].offset.tile_horz,
snes_ppu.layer[SNES_BG3].offset.tile_vert,
snes_ppu.layer[SNES_BG4].offset.tile_horz,
snes_ppu.layer[SNES_BG4].offset.tile_vert
);
#endif
snes_ppu.update_offsets = 0;
@ -1162,7 +1158,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
profiler_mark_start(PROFILER_VIDEO);
if (snes_ram[INIDISP] & 0x80) /* screen is forced blank */
if (snes_ppu.screen_disabled) /* screen is forced blank */
for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
*BITMAP_ADDR32(bitmap, curline, x) = RGB_BLACK;
else
@ -1199,7 +1195,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
{
for(ii = 0; ii < SNES_SCR_WIDTH * snes_htmult; ii++)
{
snes_draw_blend(ii/snes_htmult, &scanlines[MAINSCREEN].buffer[ii], (snes_ram[CGADSUB] & 0x80) ? SNES_BLEND_SUB : SNES_BLEND_ADD, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
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);
}
}
@ -1221,7 +1217,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
scanline = &scanlines[MAINSCREEN];
/* Phew! Draw the line to screen */
fade = (snes_ram[INIDISP] & 0xf) + 1;
fade = snes_ppu.screen_brightness;
for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
{
@ -1417,11 +1413,11 @@ static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16
WINLOGIC[(snes_ram[WBGLOG] & 0x3)],
(snes_ram[W12SEL] & 0x2)?((snes_ram[W12SEL] & 0x1)?"o":"i"):" ",
(snes_ram[W12SEL] & 0x8)?((snes_ram[W12SEL] & 0x4)?"o":"i"):" ",
snes_ppu.layer[0].tile_size + 1,
snes_ppu.layer[SNES_BG1].tile_size + 1,
(snes_ram[MOSAIC] & 0x1)?"m":" ",
snes_ram[BG1SC] & 0x3,
(snes_ram[BG1SC] & 0xfc) << 9,
snes_ppu.layer[0].data );
snes_ppu.layer[SNES_BG1].data );
//ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
logerror("%s2 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
debug_options.bg_disabled[1]?" ":"*",
@ -1433,11 +1429,11 @@ static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16
WINLOGIC[(snes_ram[WBGLOG] & 0xc) >> 2],
(snes_ram[W12SEL] & 0x20)?((snes_ram[W12SEL] & 0x10)?"o":"i"):" ",
(snes_ram[W12SEL] & 0x80)?((snes_ram[W12SEL] & 0x40)?"o":"i"):" ",
snes_ppu.layer[1].tile_size + 1,
snes_ppu.layer[SNES_BG2].tile_size + 1,
(snes_ram[MOSAIC] & 0x2)?"m":" ",
snes_ram[BG2SC] & 0x3,
(snes_ram[BG2SC] & 0xfc) << 9,
snes_ppu.layer[1].data );
snes_ppu.layer[SNES_BG2].data );
//ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
logerror("%s3 %s%s%s%s%s%c%s%s%d%s%s%d %4X %4X",
debug_options.bg_disabled[2]?" ":"*",
@ -1449,12 +1445,12 @@ static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16
WINLOGIC[(snes_ram[WBGLOG] & 0x30)>>4],
(snes_ram[W34SEL] & 0x2)?((snes_ram[W34SEL] & 0x1)?"o":"i"):" ",
(snes_ram[W34SEL] & 0x8)?((snes_ram[W34SEL] & 0x4)?"o":"i"):" ",
snes_ppu.layer[2].tile_size + 1,
snes_ppu.layer[SNES_BG3].tile_size + 1,
(snes_ram[MOSAIC] & 0x4)?"m":" ",
(snes_ram[BGMODE] & 0x8)?"P":" ",
snes_ram[BG3SC] & 0x3,
(snes_ram[BG3SC] & 0xfc) << 9,
snes_ppu.layer[2].data );
snes_ppu.layer[SNES_BG3].data );
//ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
logerror("%s4 %s%s%s%s%s%c%s%s%d%s %d %4X %4X",
debug_options.bg_disabled[3]?" ":"*",
@ -1466,11 +1462,11 @@ static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16
WINLOGIC[(snes_ram[WBGLOG] & 0xc0)>>6],
(snes_ram[W34SEL] & 0x20)?((snes_ram[W34SEL] & 0x10)?"o":"i"):" ",
(snes_ram[W34SEL] & 0x80)?((snes_ram[W34SEL] & 0x40)?"o":"i"):" ",
snes_ppu.layer[3].tile_size + 1,
snes_ppu.layer[SNES_BG4].tile_size + 1,
(snes_ram[MOSAIC] & 0x8)?"m":" ",
snes_ram[BG4SC] & 0x3,
(snes_ram[BG4SC] & 0xfc) << 9,
snes_ppu.layer[3].data );
snes_ppu.layer[SNES_BG4].data );
//ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
logerror("%sO %s%s%s%s%s%c%s%s%d%d %4X",
debug_options.bg_disabled[4]?" ":"*",
@ -1483,7 +1479,7 @@ static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16
(snes_ram[WOBJSEL] & 0x2)?((snes_ram[WOBJSEL] & 0x1)?"o":"i"):" ",
(snes_ram[WOBJSEL] & 0x8)?((snes_ram[WOBJSEL] & 0x4)?"o":"i"):" ",
snes_ppu.oam.size[0], snes_ppu.oam.size[1],
snes_ppu.layer[4].data );
snes_ppu.layer[SNES_OAM].data );
//ui_draw_text( t, SNES_DBG_HORZ_POS, y++ * 9 );
logerror("%sB %s %c%s%s",
debug_options.bg_disabled[5]?" ":"*",