mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
usgames.cpp: converted to 6845 update row, fixes screen alignment [Angelo Salese]
This commit is contained in:
parent
3364c13bff
commit
28d69d6d7d
@ -77,7 +77,7 @@ void usgames_state::usgames_map(address_map &map)
|
||||
map(0x2070, 0x2070).portr("UNK2");
|
||||
map(0x2400, 0x2401).w("aysnd", FUNC(ay8912_device::address_data_w));
|
||||
map(0x2800, 0x2fff).ram().w(FUNC(usgames_state::charram_w)).share("charram");
|
||||
map(0x3000, 0x3fff).ram().w(FUNC(usgames_state::videoram_w)).share("videoram");
|
||||
map(0x3000, 0x3fff).ram().share("videoram");
|
||||
map(0x4000, 0x7fff).bankr("bank1");
|
||||
map(0x8000, 0xffff).rom();
|
||||
}
|
||||
@ -97,7 +97,7 @@ void usgames_state::usg185_map(address_map &map)
|
||||
map(0x2460, 0x2460).w(FUNC(usgames_state::rombank_w));
|
||||
map(0x2470, 0x2470).portr("UNK2");
|
||||
map(0x2800, 0x2fff).ram().w(FUNC(usgames_state::charram_w)).share("charram");
|
||||
map(0x3000, 0x3fff).ram().w(FUNC(usgames_state::videoram_w)).share("videoram");
|
||||
map(0x3000, 0x3fff).ram().share("videoram");
|
||||
map(0x4000, 0x7fff).bankr("bank1");
|
||||
map(0x8000, 0xffff).rom();
|
||||
}
|
||||
@ -214,7 +214,7 @@ static const gfx_layout charlayout =
|
||||
};
|
||||
|
||||
static GFXDECODE_START( gfx_usgames )
|
||||
GFXDECODE_ENTRY( nullptr, 0x2800, charlayout, 0, 256 )
|
||||
GFXDECODE_ENTRY( nullptr, 0x2800, charlayout, 0, 1 )
|
||||
GFXDECODE_END
|
||||
|
||||
|
||||
@ -233,15 +233,16 @@ void usgames_state::usg32(machine_config &config)
|
||||
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
|
||||
screen.set_size(64*8, 32*8);
|
||||
screen.set_visarea(7*8, 57*8-1, 0*8, 31*8-1);
|
||||
screen.set_screen_update(FUNC(usgames_state::screen_update));
|
||||
screen.set_screen_update("crtc", FUNC(mc6845_device::screen_update));
|
||||
|
||||
GFXDECODE(config, m_gfxdecode, "palette", gfx_usgames);
|
||||
PALETTE(config, "palette", FUNC(usgames_state::usgames_palette), 2*256);
|
||||
PALETTE(config, "palette", FUNC(usgames_state::usgames_palette), 16);
|
||||
|
||||
mc6845_device &crtc(MC6845(config, "crtc", 18_MHz_XTAL / 16));
|
||||
crtc.set_screen("screen");
|
||||
crtc.set_show_border_area(false);
|
||||
crtc.set_char_width(8);
|
||||
crtc.set_update_row_callback(FUNC(usgames_state::update_row), this);
|
||||
|
||||
/* sound hardware */
|
||||
SPEAKER(config, "mono").front_center();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "emupal.h"
|
||||
#include "video/mc6845.h"
|
||||
|
||||
class usgames_state : public driver_device
|
||||
{
|
||||
@ -16,7 +17,8 @@ public:
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_videoram(*this, "videoram"),
|
||||
m_charram(*this, "charram"),
|
||||
m_leds(*this, "led%u", 0U)
|
||||
m_leds(*this, "led%u", 0U),
|
||||
m_palette(*this, "palette")
|
||||
{ }
|
||||
|
||||
void usg32(machine_config &config);
|
||||
@ -34,22 +36,18 @@ private:
|
||||
required_shared_ptr<uint8_t> m_charram;
|
||||
|
||||
output_finder<5> m_leds;
|
||||
|
||||
tilemap_t *m_tilemap;
|
||||
required_device<palette_device> m_palette;
|
||||
|
||||
DECLARE_WRITE8_MEMBER(rombank_w);
|
||||
DECLARE_WRITE8_MEMBER(lamps1_w);
|
||||
DECLARE_WRITE8_MEMBER(lamps2_w);
|
||||
DECLARE_WRITE8_MEMBER(videoram_w);
|
||||
DECLARE_WRITE8_MEMBER(charram_w);
|
||||
|
||||
TILE_GET_INFO_MEMBER(get_tile_info);
|
||||
|
||||
void usgames_palette(palette_device &palette) const;
|
||||
|
||||
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
void usg185_map(address_map &map);
|
||||
void usgames_map(address_map &map);
|
||||
MC6845_UPDATE_ROW(update_row);
|
||||
};
|
||||
|
||||
#endif // MAME_INCLUDES_USGAMES_H
|
||||
|
@ -6,14 +6,12 @@
|
||||
|
||||
void usgames_state::usgames_palette(palette_device &palette) const
|
||||
{
|
||||
for (int j = 0; j < 0x200; j++)
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
int const data = (j >> ((j & 0x01) ? 5 : 1)) & 0x0f;
|
||||
|
||||
int r = BIT(data, 0);
|
||||
int g = BIT(data, 1);
|
||||
int b = BIT(data, 2);
|
||||
int const i = BIT(data, 3);
|
||||
int r = BIT(j, 0);
|
||||
int g = BIT(j, 1);
|
||||
int b = BIT(j, 2);
|
||||
int const i = BIT(j, 3);
|
||||
|
||||
r = 0xff * r;
|
||||
g = 0x7f * g * (i + 1);
|
||||
@ -23,38 +21,33 @@ void usgames_state::usgames_palette(palette_device &palette) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TILE_GET_INFO_MEMBER(usgames_state::get_tile_info)
|
||||
{
|
||||
int const tileno = m_videoram[tile_index*2];
|
||||
int const colour = m_videoram[tile_index*2+1];
|
||||
|
||||
SET_TILE_INFO_MEMBER(0, tileno, colour, 0);
|
||||
}
|
||||
|
||||
void usgames_state::video_start()
|
||||
{
|
||||
m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(usgames_state::get_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,64,32);
|
||||
m_gfxdecode->gfx(0)->set_source(m_charram);
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(usgames_state::videoram_w)
|
||||
{
|
||||
m_videoram[offset] = data;
|
||||
m_tilemap->mark_tile_dirty(offset/2);
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(usgames_state::charram_w)
|
||||
{
|
||||
m_charram[offset] = data;
|
||||
m_gfxdecode->gfx(0)->mark_dirty(offset/8);
|
||||
}
|
||||
|
||||
|
||||
uint32_t usgames_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
MC6845_UPDATE_ROW(usgames_state::update_row)
|
||||
{
|
||||
m_tilemap->draw(screen, bitmap, cliprect, 0,0);
|
||||
return 0;
|
||||
uint32_t *pix = &bitmap.pix32(y);
|
||||
ra &= 0x07;
|
||||
|
||||
for (int x = 0; x < x_count; x++)
|
||||
{
|
||||
int tile_index = (x + ma) & (m_videoram.mask()/2);
|
||||
int tile = m_videoram[tile_index*2];
|
||||
int attr = m_videoram[tile_index*2+1];
|
||||
uint8_t bg_color = attr & 0xf;
|
||||
uint8_t fg_color = (attr & 0xf0) >> 4;
|
||||
|
||||
const uint8_t plane = m_charram[(tile << 3) | ra];
|
||||
for (int n = 7; n >= 0; n--)
|
||||
*pix++ = m_palette->pen(BIT(plane, n) ? fg_color : bg_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user