neogeo: use real palette_device (nw)
This commit is contained in:
parent
b81f168c7a
commit
0e881d0a55
@ -984,7 +984,7 @@ WRITE8_MEMBER(neogeo_state::system_control_w)
|
||||
{
|
||||
default:
|
||||
case 0x00:
|
||||
neogeo_set_screen_dark(bit);
|
||||
neogeo_set_screen_shadow(bit);
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
@ -1792,7 +1792,7 @@ MACHINE_CONFIG_START( neogeo_base, neogeo_state )
|
||||
MCFG_SCREEN_UPDATE_DRIVER(neogeo_state, screen_update_neogeo)
|
||||
|
||||
/* 4096 colors * two banks * normal and shadow */
|
||||
MCFG_PALETTE_ADD("palette", 4096*2*2)
|
||||
MCFG_PALETTE_ADD_INIT_BLACK("palette", 4096*2*2)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", NEOGEO_SPRITE_OPTIMZIED, 0)
|
||||
|
||||
|
@ -151,12 +151,10 @@ protected:
|
||||
void neogeo_set_display_counter_lsb(UINT16 data);
|
||||
void set_video_control( UINT16 data );
|
||||
|
||||
void compute_rgb_weights( );
|
||||
void create_rgb_lookups();
|
||||
void regenerate_pens();
|
||||
pen_t get_pen( UINT16 data );
|
||||
void neogeo_set_palette_bank( UINT8 data );
|
||||
void neogeo_set_screen_dark( UINT8 data );
|
||||
void set_pens();
|
||||
void neogeo_set_screen_shadow( int data );
|
||||
void neogeo_set_palette_bank( int data );
|
||||
|
||||
void audio_cpu_check_nmi();
|
||||
void select_controller( UINT8 data );
|
||||
@ -346,15 +344,11 @@ protected:
|
||||
UINT16 get_video_control( );
|
||||
|
||||
// color/palette related
|
||||
UINT8 m_palette_lookup[32][4];
|
||||
double m_rgb_weights_normal[5];
|
||||
double m_rgb_weights_normal_bit15[5];
|
||||
double m_rgb_weights_dark[5];
|
||||
double m_rgb_weights_dark_bit15[5];
|
||||
UINT16 *m_palettes[2]; /* 0x100*16 2 byte palette entries */
|
||||
pen_t *m_pens;
|
||||
UINT8 m_palette_bank;
|
||||
UINT8 m_screen_dark;
|
||||
dynamic_array<UINT16> m_paletteram;
|
||||
UINT8 m_palette_lookup[32][4];
|
||||
const pen_t *m_bg_pen;
|
||||
int m_screen_shadow;
|
||||
int m_palette_bank;
|
||||
|
||||
// cartridge-specific hardware
|
||||
// TODO: move into separate devices
|
||||
|
@ -19,35 +19,6 @@
|
||||
*
|
||||
*************************************/
|
||||
|
||||
void neogeo_state::compute_rgb_weights( )
|
||||
{
|
||||
static const int resistances[] = { 220, 470, 1000, 2200, 3900 };
|
||||
|
||||
/* compute four sets of weights - with or without the pulldowns -
|
||||
ensuring that we use the same scaler for all */
|
||||
|
||||
double scaler = compute_resistor_weights(0, 0xff, -1,
|
||||
5, resistances, m_rgb_weights_normal, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0);
|
||||
|
||||
compute_resistor_weights(0, 0xff, scaler,
|
||||
5, resistances, m_rgb_weights_normal_bit15, 8200, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0);
|
||||
|
||||
compute_resistor_weights(0, 0xff, scaler,
|
||||
5, resistances, m_rgb_weights_dark, 150, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0);
|
||||
|
||||
compute_resistor_weights(0, 0xff, scaler,
|
||||
5, resistances, m_rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void neogeo_state::create_rgb_lookups()
|
||||
{
|
||||
static const int resistances[] = {3900, 2200, 1000, 470, 220};
|
||||
@ -92,96 +63,53 @@ void neogeo_state::create_rgb_lookups()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pen_t neogeo_state::get_pen( UINT16 data )
|
||||
void neogeo_state::set_pens()
|
||||
{
|
||||
double *weights;
|
||||
UINT8 r, g, b;
|
||||
|
||||
if (m_screen_dark)
|
||||
{
|
||||
if (data & 0x8000)
|
||||
weights = m_rgb_weights_dark_bit15;
|
||||
else
|
||||
weights = m_rgb_weights_dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data & 0x8000)
|
||||
weights = m_rgb_weights_normal_bit15;
|
||||
else
|
||||
weights = m_rgb_weights_normal;
|
||||
}
|
||||
|
||||
r = combine_5_weights(weights,
|
||||
(data >> 11) & 0x01,
|
||||
(data >> 10) & 0x01,
|
||||
(data >> 9) & 0x01,
|
||||
(data >> 8) & 0x01,
|
||||
(data >> 14) & 0x01);
|
||||
|
||||
g = combine_5_weights(weights,
|
||||
(data >> 7) & 0x01,
|
||||
(data >> 6) & 0x01,
|
||||
(data >> 5) & 0x01,
|
||||
(data >> 4) & 0x01,
|
||||
(data >> 13) & 0x01);
|
||||
|
||||
b = combine_5_weights(weights,
|
||||
(data >> 3) & 0x01,
|
||||
(data >> 2) & 0x01,
|
||||
(data >> 1) & 0x01,
|
||||
(data >> 0) & 0x01,
|
||||
(data >> 12) & 0x01);
|
||||
|
||||
return rgb_t(r, g, b);
|
||||
const pen_t *pen_base = m_palette->pens() + m_palette_bank + (m_screen_shadow ? 0x2000 : 0);
|
||||
m_sprgen->set_pens(pen_base);
|
||||
m_bg_pen = pen_base + 0xfff;
|
||||
}
|
||||
|
||||
|
||||
void neogeo_state::regenerate_pens()
|
||||
void neogeo_state::neogeo_set_screen_shadow( int data )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_PENS; i++)
|
||||
m_pens[i] = get_pen(m_palettes[m_palette_bank][i]);
|
||||
m_screen_shadow = data;
|
||||
set_pens();
|
||||
}
|
||||
|
||||
|
||||
void neogeo_state::neogeo_set_palette_bank( UINT8 data )
|
||||
void neogeo_state::neogeo_set_palette_bank( int data )
|
||||
{
|
||||
if (data != m_palette_bank)
|
||||
{
|
||||
m_palette_bank = data;
|
||||
|
||||
regenerate_pens();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void neogeo_state::neogeo_set_screen_dark( UINT8 data )
|
||||
{
|
||||
if (data != m_screen_dark)
|
||||
{
|
||||
m_screen_dark = data;
|
||||
|
||||
regenerate_pens();
|
||||
}
|
||||
m_palette_bank = data ? 0x1000 : 0;
|
||||
set_pens();
|
||||
}
|
||||
|
||||
|
||||
READ16_MEMBER(neogeo_state::neogeo_paletteram_r)
|
||||
{
|
||||
return m_palettes[m_palette_bank][offset];
|
||||
return m_paletteram[m_palette_bank + offset];
|
||||
}
|
||||
|
||||
|
||||
WRITE16_MEMBER(neogeo_state::neogeo_paletteram_w)
|
||||
{
|
||||
UINT16 *addr = &m_palettes[m_palette_bank][offset];
|
||||
offset += m_palette_bank;
|
||||
data = COMBINE_DATA(&m_paletteram[offset]);
|
||||
|
||||
COMBINE_DATA(addr);
|
||||
int dark = data >> 15;
|
||||
int r = ((data >> 14) & 0x1) | ((data >> 7) & 0x1e);
|
||||
int g = ((data >> 13) & 0x1) | ((data >> 3) & 0x1e);
|
||||
int b = ((data >> 12) & 0x1) | ((data << 1) & 0x1e);
|
||||
|
||||
m_pens[offset] = get_pen(*addr);
|
||||
m_palette->set_pen_color(offset,
|
||||
m_palette_lookup[r][dark],
|
||||
m_palette_lookup[g][dark],
|
||||
m_palette_lookup[b][dark]); // normal
|
||||
|
||||
m_palette->set_pen_color(offset + 0x2000,
|
||||
m_palette_lookup[r][dark+2],
|
||||
m_palette_lookup[g][dark+2],
|
||||
m_palette_lookup[b][dark+2]); // shadow
|
||||
}
|
||||
|
||||
|
||||
@ -194,25 +122,19 @@ WRITE16_MEMBER(neogeo_state::neogeo_paletteram_w)
|
||||
|
||||
void neogeo_state::video_start()
|
||||
{
|
||||
/* allocate memory not directly mapped */
|
||||
m_palettes[0] = auto_alloc_array(machine(), UINT16, NUM_PENS);
|
||||
m_palettes[1] = auto_alloc_array(machine(), UINT16, NUM_PENS);
|
||||
m_pens = auto_alloc_array(machine(), pen_t, NUM_PENS);
|
||||
|
||||
compute_rgb_weights();
|
||||
create_rgb_lookups();
|
||||
|
||||
memset(m_palettes[0], 0x00, NUM_PENS * sizeof(UINT16));
|
||||
memset(m_palettes[1], 0x00, NUM_PENS * sizeof(UINT16));
|
||||
memset(m_pens, 0x00, NUM_PENS * sizeof(pen_t));
|
||||
m_paletteram.resize_and_clear(0x1000 * 2);
|
||||
|
||||
save_pointer(NAME(m_palettes[0]), NUM_PENS);
|
||||
save_pointer(NAME(m_palettes[1]), NUM_PENS);
|
||||
save_item(NAME(m_screen_dark));
|
||||
m_screen_shadow = 0;
|
||||
m_palette_bank = 0;
|
||||
|
||||
save_item(NAME(m_paletteram));
|
||||
save_item(NAME(m_screen_shadow));
|
||||
save_item(NAME(m_palette_bank));
|
||||
machine().save().register_postload(save_prepost_delegate(FUNC(neogeo_state::regenerate_pens), this));
|
||||
machine().save().register_postload(save_prepost_delegate(FUNC(neogeo_state::set_pens), this));
|
||||
|
||||
m_sprgen->set_pens(m_pens);
|
||||
set_pens();
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +161,7 @@ void neogeo_state::video_reset()
|
||||
UINT32 neogeo_state::screen_update_neogeo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
// fill with background color first
|
||||
bitmap.fill(m_pens[0x0fff], cliprect);
|
||||
bitmap.fill(*m_bg_pen, cliprect);
|
||||
|
||||
m_sprgen->draw_sprites(bitmap, cliprect.min_y);
|
||||
|
||||
|
@ -234,7 +234,7 @@ void neosprite_base_device::draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline
|
||||
int i;
|
||||
int gfx_offset = ((code << 5) | (scanline & 0x07)) & addr_mask;
|
||||
|
||||
pen_t *char_pens;
|
||||
const pen_t *char_pens;
|
||||
|
||||
char_pens = &m_pens[code_and_palette >> 12 << m_bppshift];
|
||||
|
||||
@ -252,7 +252,7 @@ void neosprite_base_device::draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline
|
||||
}
|
||||
|
||||
|
||||
inline void neosprite_base_device::draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, pen_t* char_pens)
|
||||
inline void neosprite_base_device::draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, const pen_t* char_pens)
|
||||
{
|
||||
UINT8 data = gfx_base[offset];
|
||||
|
||||
@ -377,7 +377,7 @@ void neosprite_base_device::draw_sprites( bitmap_rgb32 &bitmap, int scanline )
|
||||
UINT16 attr;
|
||||
UINT32 code;
|
||||
const int *zoom_x_table;
|
||||
pen_t *line_pens;
|
||||
const pen_t *line_pens;
|
||||
int x_inc;
|
||||
|
||||
int sprite_line = (scanline - y) & 0x1ff;
|
||||
@ -627,7 +627,7 @@ void neosprite_base_device::set_screen(screen_device* screen)
|
||||
m_screen = screen;
|
||||
}
|
||||
|
||||
void neosprite_base_device::set_pens(pen_t* pens)
|
||||
void neosprite_base_device::set_pens(const pen_t* pens)
|
||||
{
|
||||
m_pens = pens;
|
||||
}
|
||||
@ -670,7 +670,7 @@ void neosprite_regular_device::set_sprite_region(memory_region* region_sprites)
|
||||
m_sprite_gfx_address_mask = mask;
|
||||
}
|
||||
|
||||
inline void neosprite_regular_device::draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens)
|
||||
inline void neosprite_regular_device::draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens)
|
||||
{
|
||||
const UINT8* src = m_region_sprites->base() + (((romaddr &~0xff)>>1) | (((romaddr&0x8)^0x8)<<3) | ((romaddr & 0xf0) >> 2));
|
||||
const int x = romaddr & 0x7;
|
||||
@ -739,7 +739,7 @@ void neosprite_optimized_device::optimize_sprite_data()
|
||||
}
|
||||
}
|
||||
|
||||
inline void neosprite_optimized_device::draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens)
|
||||
inline void neosprite_optimized_device::draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens)
|
||||
{
|
||||
const UINT8 gfx = m_sprite_gfx[romaddr];
|
||||
|
||||
@ -765,7 +765,7 @@ neosprite_midas_device::neosprite_midas_device(const machine_config &mconfig, co
|
||||
}
|
||||
|
||||
|
||||
inline void neosprite_midas_device::draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens)
|
||||
inline void neosprite_midas_device::draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens)
|
||||
{
|
||||
const UINT8* src = m_region_sprites->base() + (((romaddr &~0xff)) | (((romaddr&0x8)^0x8)<<4) | ((romaddr & 0xf0) >> 1));
|
||||
const int x = romaddr & 0x7;
|
||||
@ -800,7 +800,7 @@ void neosprite_midas_device::buffer_vram()
|
||||
memcpy(m_videoram_buffer, m_videoram, (0x8000 + 0x800) * sizeof(UINT16));
|
||||
}
|
||||
|
||||
inline void neosprite_midas_device::draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, pen_t* char_pens)
|
||||
inline void neosprite_midas_device::draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, const pen_t* char_pens)
|
||||
{
|
||||
UINT8 data;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
// neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
virtual void optimize_sprite_data();
|
||||
virtual void draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, pen_t* char_pens);
|
||||
virtual void draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, const pen_t* char_pens);
|
||||
void draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline );
|
||||
void set_videoram_offset( UINT16 data );
|
||||
UINT16 get_videoram_data( );
|
||||
@ -37,7 +37,7 @@ public:
|
||||
void start_auto_animation_timer( );
|
||||
void neogeo_set_fixed_layer_source( UINT8 data );
|
||||
inline bool sprite_on_scanline(int scanline, int y, int rows);
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens) = 0;
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens) = 0;
|
||||
void draw_sprites( bitmap_rgb32 &bitmap, int scanline );
|
||||
void parse_sprites( int scanline );
|
||||
void create_sprite_line_timer( );
|
||||
@ -45,7 +45,7 @@ public:
|
||||
virtual void set_sprite_region(memory_region* region_sprites);
|
||||
void set_fixed_regions(memory_region* fix_cart, memory_region* fix_bios);
|
||||
void set_screen(screen_device* screen);
|
||||
void set_pens(pen_t* pens);
|
||||
void set_pens(const pen_t* pens);
|
||||
|
||||
UINT16 *m_videoram;
|
||||
UINT16 *m_videoram_drawsource;
|
||||
@ -83,7 +83,7 @@ protected:
|
||||
memory_region* m_region_fixed;
|
||||
memory_region* m_region_fixedbios;
|
||||
screen_device* m_screen;
|
||||
pen_t *m_pens;
|
||||
const pen_t *m_pens;
|
||||
|
||||
private:
|
||||
|
||||
@ -96,7 +96,7 @@ class neosprite_regular_device : public neosprite_base_device
|
||||
{
|
||||
public:
|
||||
neosprite_regular_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens);
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens);
|
||||
virtual void set_sprite_region(memory_region* region_sprites);
|
||||
|
||||
};
|
||||
@ -109,7 +109,7 @@ class neosprite_optimized_device : public neosprite_base_device
|
||||
public:
|
||||
neosprite_optimized_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual void optimize_sprite_data();
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens);
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens);
|
||||
dynamic_array<UINT8> m_sprite_gfx;
|
||||
|
||||
};
|
||||
@ -125,11 +125,11 @@ class neosprite_midas_device : public neosprite_base_device
|
||||
public:
|
||||
neosprite_midas_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, pen_t *line_pens);
|
||||
virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens);
|
||||
|
||||
UINT16* m_videoram_buffer;
|
||||
void buffer_vram();
|
||||
virtual void draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, pen_t* char_pens);
|
||||
virtual void draw_fixed_layer_2pixels(UINT32*&pixel_addr, int offset, UINT8* gfx_base, const pen_t* char_pens);
|
||||
virtual void set_sprite_region(memory_region* region_sprites);
|
||||
|
||||
protected:
|
||||
|
@ -1455,7 +1455,7 @@ void ng_aes_state::NeoCDIRQUpdate(UINT8 byteValue)
|
||||
UINT32 ng_aes_state::screen_update_neocd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
// fill with background color first
|
||||
bitmap.fill(m_pens[0x0fff], cliprect);
|
||||
bitmap.fill(*m_bg_pen, cliprect);
|
||||
|
||||
if (m_has_sprite_bus) m_sprgen->draw_sprites(bitmap, cliprect.min_y);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user