mirror of
https://github.com/holub/mame
synced 2025-06-10 23:02:38 +03:00
blockout.cpp : Updates
Simplify handlers, Use palette format for palette, Fix / Cleanup some drawing behavior, Fix namings, Fix spacings, Reduce unnecessary lines, Unnecessary pointers, Use shorter / correct type values
This commit is contained in:
parent
610897fd38
commit
e72043f0d4
@ -107,13 +107,13 @@ void blockout_state::main_map(address_map &map)
|
|||||||
map(0x100012, 0x100013).w(FUNC(blockout_state::blockout_irq5_ack_w));
|
map(0x100012, 0x100013).w(FUNC(blockout_state::blockout_irq5_ack_w));
|
||||||
map(0x100015, 0x100015).w(m_soundlatch, FUNC(generic_latch_8_device::write));
|
map(0x100015, 0x100015).w(m_soundlatch, FUNC(generic_latch_8_device::write));
|
||||||
map(0x100016, 0x100017).nopw(); /* don't know, maybe reset sound CPU */
|
map(0x100016, 0x100017).nopw(); /* don't know, maybe reset sound CPU */
|
||||||
map(0x180000, 0x1bffff).ram().w(FUNC(blockout_state::blockout_videoram_w)).share("videoram");
|
map(0x180000, 0x1bffff).rw(FUNC(blockout_state::videoram_r), FUNC(blockout_state::videoram_w)).share("videoram");
|
||||||
map(0x1d4000, 0x1dffff).ram(); /* work RAM */
|
map(0x1d4000, 0x1dffff).ram(); /* work RAM */
|
||||||
map(0x1f4000, 0x1fffff).ram(); /* work RAM */
|
map(0x1f4000, 0x1fffff).ram(); /* work RAM */
|
||||||
map(0x200000, 0x207fff).ram().share("frontvideoram");
|
map(0x200000, 0x207fff).ram().share("frontvideoram");
|
||||||
map(0x208000, 0x21ffff).ram(); /* ??? */
|
map(0x208000, 0x21ffff).ram(); /* ??? */
|
||||||
map(0x280002, 0x280003).w(FUNC(blockout_state::blockout_frontcolor_w));
|
map(0x280002, 0x280003).w(FUNC(blockout_state::frontcolor_w));
|
||||||
map(0x280200, 0x2805ff).ram().w(FUNC(blockout_state::blockout_paletteram_w)).share("paletteram");
|
map(0x280200, 0x2805ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockout_state::agress_map(address_map &map)
|
void blockout_state::agress_map(address_map &map)
|
||||||
@ -128,13 +128,13 @@ void blockout_state::agress_map(address_map &map)
|
|||||||
map(0x100012, 0x100013).w(FUNC(blockout_state::blockout_irq5_ack_w));
|
map(0x100012, 0x100013).w(FUNC(blockout_state::blockout_irq5_ack_w));
|
||||||
map(0x100015, 0x100015).w(m_soundlatch, FUNC(generic_latch_8_device::write));
|
map(0x100015, 0x100015).w(m_soundlatch, FUNC(generic_latch_8_device::write));
|
||||||
map(0x100016, 0x100017).nopw(); /* don't know, maybe reset sound CPU */
|
map(0x100016, 0x100017).nopw(); /* don't know, maybe reset sound CPU */
|
||||||
map(0x180000, 0x1bffff).ram().w(FUNC(blockout_state::blockout_videoram_w)).share("videoram");
|
map(0x180000, 0x1bffff).rw(FUNC(blockout_state::videoram_r), FUNC(blockout_state::videoram_w)).share("videoram");
|
||||||
map(0x1d4000, 0x1dffff).ram(); /* work RAM */
|
map(0x1d4000, 0x1dffff).ram(); /* work RAM */
|
||||||
map(0x1f4000, 0x1fffff).ram(); /* work RAM */
|
map(0x1f4000, 0x1fffff).ram(); /* work RAM */
|
||||||
map(0x200000, 0x207fff).ram().share("frontvideoram");
|
map(0x200000, 0x207fff).ram().share("frontvideoram");
|
||||||
map(0x208000, 0x21ffff).ram(); /* ??? */
|
map(0x208000, 0x21ffff).ram(); /* ??? */
|
||||||
map(0x280002, 0x280003).w(FUNC(blockout_state::blockout_frontcolor_w));
|
map(0x280002, 0x280003).w(FUNC(blockout_state::frontcolor_w));
|
||||||
map(0x280200, 0x2805ff).ram().w(FUNC(blockout_state::blockout_paletteram_w)).share("paletteram");
|
map(0x280200, 0x2805ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockout_state::audio_map(address_map &map)
|
void blockout_state::audio_map(address_map &map)
|
||||||
@ -297,10 +297,10 @@ TIMER_DEVICE_CALLBACK_MEMBER(blockout_state::blockout_scanline)
|
|||||||
{
|
{
|
||||||
int scanline = param;
|
int scanline = param;
|
||||||
|
|
||||||
if(scanline == 250) // vblank-out irq
|
if (scanline == 250) // vblank-out irq
|
||||||
m_maincpu->set_input_line(6, ASSERT_LINE);
|
m_maincpu->set_input_line(6, ASSERT_LINE);
|
||||||
|
|
||||||
if(scanline == 0) // vblank-in irq or directly tied to coin inputs (TODO: check)
|
if (scanline == 0) // vblank-in irq or directly tied to coin inputs (TODO: check)
|
||||||
m_maincpu->set_input_line(5, ASSERT_LINE);
|
m_maincpu->set_input_line(5, ASSERT_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,15 +314,14 @@ void blockout_state::blockout(machine_config &config)
|
|||||||
Z80(config, m_audiocpu, AUDIO_CLOCK); /* 3.579545 MHz */
|
Z80(config, m_audiocpu, AUDIO_CLOCK); /* 3.579545 MHz */
|
||||||
m_audiocpu->set_addrmap(AS_PROGRAM, &blockout_state::audio_map);
|
m_audiocpu->set_addrmap(AS_PROGRAM, &blockout_state::audio_map);
|
||||||
|
|
||||||
|
|
||||||
/* video hardware */
|
/* video hardware */
|
||||||
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
|
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
|
||||||
/* assume same as ddragon3 with adjusted visible display area */
|
/* assume same as ddragon3 with adjusted visible display area */
|
||||||
m_screen->set_raw(XTAL(28'000'000) / 4, 448, 0, 320, 272, 10, 250);
|
m_screen->set_raw(XTAL(28'000'000) / 4, 448, 0, 320, 272, 10, 250);
|
||||||
m_screen->set_screen_update(FUNC(blockout_state::screen_update_blockout));
|
m_screen->set_screen_update(FUNC(blockout_state::screen_update));
|
||||||
m_screen->set_palette(m_palette);
|
m_screen->set_palette(m_palette);
|
||||||
|
|
||||||
PALETTE(config, m_palette).set_entries(513);
|
PALETTE(config, m_palette).set_format(2, &blockout_state::blockout_xBGR_444, 513);
|
||||||
|
|
||||||
/* sound hardware */
|
/* sound hardware */
|
||||||
SPEAKER(config, "lspeaker").front_left();
|
SPEAKER(config, "lspeaker").front_left();
|
||||||
@ -451,7 +450,7 @@ void blockout_state::init_agress()
|
|||||||
* For now let's use D and just patch the TRACE exception that causes the bogus mirror check
|
* For now let's use D and just patch the TRACE exception that causes the bogus mirror check
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint16_t *rom = (uint16_t *)memregion("maincpu")->base();
|
u16 *rom = (u16 *)memregion("maincpu")->base();
|
||||||
|
|
||||||
rom[0x82/2] = 0x2700;
|
rom[0x82/2] = 0x2700;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,8 @@ class blockout_state : public driver_device
|
|||||||
public:
|
public:
|
||||||
blockout_state(const machine_config &mconfig, device_type type, const char *tag)
|
blockout_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||||
: driver_device(mconfig, type, tag),
|
: driver_device(mconfig, type, tag),
|
||||||
m_videoram(*this, "videoram"),
|
m_videoram(*this, "videoram", 16),
|
||||||
m_frontvideoram(*this, "frontvideoram"),
|
m_frontvideoram(*this, "frontvideoram"),
|
||||||
m_paletteram(*this, "paletteram"),
|
|
||||||
m_maincpu(*this, "maincpu"),
|
m_maincpu(*this, "maincpu"),
|
||||||
m_audiocpu(*this, "audiocpu"),
|
m_audiocpu(*this, "audiocpu"),
|
||||||
m_screen(*this, "screen"),
|
m_screen(*this, "screen"),
|
||||||
@ -27,13 +26,12 @@ public:
|
|||||||
m_soundlatch(*this, "soundlatch") { }
|
m_soundlatch(*this, "soundlatch") { }
|
||||||
|
|
||||||
/* memory pointers */
|
/* memory pointers */
|
||||||
required_shared_ptr<uint16_t> m_videoram;
|
required_shared_ptr<u8> m_videoram;
|
||||||
required_shared_ptr<uint16_t> m_frontvideoram;
|
required_shared_ptr<u16> m_frontvideoram;
|
||||||
required_shared_ptr<uint16_t> m_paletteram;
|
|
||||||
|
|
||||||
/* video-related */
|
/* video-related */
|
||||||
bitmap_ind16 m_tmpbitmap;
|
bitmap_ind16 m_tmpbitmap;
|
||||||
uint16_t m_color;
|
u16 m_color;
|
||||||
|
|
||||||
/* devices */
|
/* devices */
|
||||||
required_device<cpu_device> m_maincpu;
|
required_device<cpu_device> m_maincpu;
|
||||||
@ -45,17 +43,16 @@ public:
|
|||||||
DECLARE_WRITE_LINE_MEMBER(irq_handler);
|
DECLARE_WRITE_LINE_MEMBER(irq_handler);
|
||||||
DECLARE_WRITE16_MEMBER(blockout_irq6_ack_w);
|
DECLARE_WRITE16_MEMBER(blockout_irq6_ack_w);
|
||||||
DECLARE_WRITE16_MEMBER(blockout_irq5_ack_w);
|
DECLARE_WRITE16_MEMBER(blockout_irq5_ack_w);
|
||||||
DECLARE_WRITE16_MEMBER(blockout_paletteram_w);
|
void frontcolor_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||||
DECLARE_WRITE16_MEMBER(blockout_frontcolor_w);
|
u8 videoram_r(offs_t offset);
|
||||||
DECLARE_WRITE16_MEMBER(blockout_videoram_w);
|
void videoram_w(offs_t offset, u8 data);
|
||||||
void init_agress();
|
void init_agress();
|
||||||
virtual void machine_start() override;
|
virtual void machine_start() override;
|
||||||
virtual void machine_reset() override;
|
virtual void machine_reset() override;
|
||||||
virtual void video_start() override;
|
virtual void video_start() override;
|
||||||
uint32_t screen_update_blockout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||||
TIMER_DEVICE_CALLBACK_MEMBER(blockout_scanline);
|
TIMER_DEVICE_CALLBACK_MEMBER(blockout_scanline);
|
||||||
void setcolor( int color, int rgb );
|
static rgb_t blockout_xBGR_444(u32 raw);
|
||||||
void update_pixels( int x, int y );
|
|
||||||
void blockout(machine_config &config);
|
void blockout(machine_config &config);
|
||||||
void agress(machine_config &config);
|
void agress(machine_config &config);
|
||||||
void agress_map(address_map &map);
|
void agress_map(address_map &map);
|
||||||
|
@ -10,50 +10,39 @@
|
|||||||
#include "includes/blockout.h"
|
#include "includes/blockout.h"
|
||||||
|
|
||||||
|
|
||||||
void blockout_state::setcolor( int color, int rgb )
|
rgb_t blockout_state::blockout_xBGR_444(u32 raw)
|
||||||
{
|
{
|
||||||
int bit0, bit1, bit2, bit3;
|
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
|
|
||||||
/* red component */
|
/* red component */
|
||||||
bit0 = (rgb >> 0) & 0x01;
|
u8 bit0 = (raw >> 0) & 0x01;
|
||||||
bit1 = (rgb >> 1) & 0x01;
|
u8 bit1 = (raw >> 1) & 0x01;
|
||||||
bit2 = (rgb >> 2) & 0x01;
|
u8 bit2 = (raw >> 2) & 0x01;
|
||||||
bit3 = (rgb >> 3) & 0x01;
|
u8 bit3 = (raw >> 3) & 0x01;
|
||||||
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
const u8 r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
||||||
|
|
||||||
/* green component */
|
/* green component */
|
||||||
bit0 = (rgb >> 4) & 0x01;
|
bit0 = (raw >> 4) & 0x01;
|
||||||
bit1 = (rgb >> 5) & 0x01;
|
bit1 = (raw >> 5) & 0x01;
|
||||||
bit2 = (rgb >> 6) & 0x01;
|
bit2 = (raw >> 6) & 0x01;
|
||||||
bit3 = (rgb >> 7) & 0x01;
|
bit3 = (raw >> 7) & 0x01;
|
||||||
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
const u8 g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
||||||
|
|
||||||
/* blue component */
|
/* blue component */
|
||||||
bit0 = (rgb >> 8) & 0x01;
|
bit0 = (raw >> 8) & 0x01;
|
||||||
bit1 = (rgb >> 9) & 0x01;
|
bit1 = (raw >> 9) & 0x01;
|
||||||
bit2 = (rgb >> 10) & 0x01;
|
bit2 = (raw >> 10) & 0x01;
|
||||||
bit3 = (rgb >> 11) & 0x01;
|
bit3 = (raw >> 11) & 0x01;
|
||||||
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
const u8 b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
|
||||||
|
|
||||||
m_palette->set_pen_color(color, rgb_t(r,g,b));
|
return rgb_t(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE16_MEMBER(blockout_state::blockout_paletteram_w)
|
void blockout_state::frontcolor_w(offs_t offset, u16 data, u16 mem_mask)
|
||||||
{
|
|
||||||
COMBINE_DATA(&m_paletteram[offset]);
|
|
||||||
setcolor(offset, m_paletteram[offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
WRITE16_MEMBER(blockout_state::blockout_frontcolor_w)
|
|
||||||
{
|
{
|
||||||
COMBINE_DATA(&m_color);
|
COMBINE_DATA(&m_color);
|
||||||
setcolor(512, m_color);
|
m_palette->set_pen_color(512, blockout_xBGR_444(m_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
|
||||||
Start the video hardware emulation.
|
Start the video hardware emulation.
|
||||||
@ -62,65 +51,52 @@ WRITE16_MEMBER(blockout_state::blockout_frontcolor_w)
|
|||||||
void blockout_state::video_start()
|
void blockout_state::video_start()
|
||||||
{
|
{
|
||||||
/* Allocate temporary bitmaps */
|
/* Allocate temporary bitmaps */
|
||||||
m_screen->register_screen_bitmap(m_tmpbitmap);
|
m_tmpbitmap.allocate(512, 256);
|
||||||
|
const rectangle clip(0, 511, 0, 255);
|
||||||
|
m_tmpbitmap.fill(0x100, clip);
|
||||||
save_item(NAME(m_tmpbitmap));
|
save_item(NAME(m_tmpbitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockout_state::update_pixels( int x, int y )
|
u8 blockout_state::videoram_r(offs_t offset)
|
||||||
{
|
{
|
||||||
uint16_t front, back;
|
return m_videoram[offset];
|
||||||
int color;
|
}
|
||||||
const rectangle &visarea = m_screen->visible_area();
|
|
||||||
|
|
||||||
if (!visarea.contains(x, y))
|
void blockout_state::videoram_w(offs_t offset, u8 data)
|
||||||
return;
|
{
|
||||||
|
if (m_videoram[offset] != data)
|
||||||
|
{
|
||||||
|
m_videoram[offset] = data;
|
||||||
|
const u16 x = offset & 0x1ff;
|
||||||
|
const u16 y = (offset >> 9) & 0xff;
|
||||||
|
u16 color;
|
||||||
|
|
||||||
front = m_videoram[y * 256 + x / 2];
|
const u8 front = m_videoram[(y << 9) | x];
|
||||||
back = m_videoram[0x10000 + y * 256 + x / 2];
|
const u8 back = m_videoram[0x20000 | (y << 9) | x];
|
||||||
|
|
||||||
if (front >> 8)
|
if (front)
|
||||||
color = front >> 8;
|
color = front;
|
||||||
else
|
else
|
||||||
color = (back >> 8) + 256;
|
color = back | 0x100;
|
||||||
|
|
||||||
m_tmpbitmap.pix16(y, x) = color;
|
m_tmpbitmap.pix16(y, x) = color;
|
||||||
|
}
|
||||||
if (front & 0xff)
|
|
||||||
color = front & 0xff;
|
|
||||||
else
|
|
||||||
color = (back & 0xff) + 256;
|
|
||||||
|
|
||||||
m_tmpbitmap.pix16(y, x + 1) = color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u32 blockout_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||||
WRITE16_MEMBER(blockout_state::blockout_videoram_w)
|
|
||||||
{
|
{
|
||||||
COMBINE_DATA(&m_videoram[offset]);
|
|
||||||
update_pixels((offset % 256) * 2, (offset / 256) % 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t blockout_state::screen_update_blockout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
pen_t color = 512;
|
pen_t color = 512;
|
||||||
|
|
||||||
copybitmap(bitmap, m_tmpbitmap, 0, 0, 0, 0, cliprect);
|
copybitmap(bitmap, m_tmpbitmap, 0, 0, 0, 0, cliprect);
|
||||||
|
|
||||||
for (y = 0; y < 256; y++)
|
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < 320; x += 8)
|
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||||
{
|
{
|
||||||
int d = m_frontvideoram[y * 64 + (x / 8)];
|
const u16 d = m_frontvideoram[((y & 0xff) << 6) + ((x & 0x1ff) >> 3)];
|
||||||
int xi;
|
if (d & (1 << (7 - (x & 7))))
|
||||||
for(xi=0;xi<8;xi++)
|
bitmap.pix16(y, x) = color;
|
||||||
{
|
|
||||||
if(d & 1 << (7-xi))
|
|
||||||
bitmap.pix16(y, x + xi) = color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user