xyonix: Hook up 6845 CRTC, add screen raw parameters

A scanline based renderer using MC6845_UPDATE_ROW has been added
but is commented out because the tilemap renderer is much simpler.
This commit is contained in:
Dirk Best 2020-02-20 13:31:32 +01:00
parent 7cfb828456
commit 796181f73e
4 changed files with 155 additions and 128 deletions

View File

@ -5010,8 +5010,6 @@ files {
MAME_DIR .. "src/mame/drivers/wms.cpp",
MAME_DIR .. "src/mame/drivers/xtom3d.cpp",
MAME_DIR .. "src/mame/drivers/xyonix.cpp",
MAME_DIR .. "src/mame/includes/xyonix.h",
MAME_DIR .. "src/mame/video/xyonix.cpp",
MAME_DIR .. "src/mame/drivers/yuvomz80.cpp",
}
end

View File

@ -23,14 +23,71 @@ TODO:
******************************************************************************/
#include "emu.h"
#include "includes/xyonix.h"
#include "cpu/z80/z80.h"
#include "video/mc6845.h"
#include "sound/sn76496.h"
#include "screen.h"
#include "speaker.h"
#include "emupal.h"
#include "tilemap.h"
class xyonix_state : public driver_device
{
public:
xyonix_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_crtc(*this, "crtc"),
m_palette(*this, "palette"),
m_gfxdecode(*this, "gfxdecode"),
m_gfx(*this, "gfx1"),
m_vidram(*this, "vidram")
{ }
void xyonix(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
required_device<cpu_device> m_maincpu;
required_device<mc6845_device> m_crtc;
required_device<palette_device> m_palette;
required_device<gfxdecode_device> m_gfxdecode;
required_memory_region m_gfx;
required_shared_ptr<uint8_t> m_vidram;
tilemap_t *m_tilemap;
int m_e0_data;
int m_credits;
int m_coins;
int m_prev_coin;
bool m_nmi_mask;
DECLARE_WRITE_LINE_MEMBER(nmiclk_w);
DECLARE_WRITE8_MEMBER(irqack_w);
DECLARE_WRITE8_MEMBER(nmiack_w);
DECLARE_READ8_MEMBER(io_r);
DECLARE_WRITE8_MEMBER(io_w);
DECLARE_WRITE8_MEMBER(vidram_w);
TILE_GET_INFO_MEMBER(get_tile_info);
void xyonix_palette(palette_device &palette) const;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void handle_coins(int coin);
void main_map(address_map &map);
void port_map(address_map &map);
// MC6845_UPDATE_ROW(crtc_update_row);
};
void xyonix_state::machine_start()
{
save_item(NAME(m_e0_data));
@ -63,6 +120,91 @@ WRITE8_MEMBER(xyonix_state::nmiack_w)
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}
void xyonix_state::xyonix_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
for (int i = 0; i < palette.entries(); i++)
{
int bit0, bit1, bit2;
// red component
bit0 = BIT(color_prom[i], 0);
bit1 = BIT(color_prom[i], 1);
bit2 = BIT(color_prom[i], 2);
int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// green component
bit0 = BIT(color_prom[i], 5);
bit1 = BIT(color_prom[i], 6);
bit2 = BIT(color_prom[i], 7);
int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// blue component
bit0 = BIT(color_prom[i], 3);
bit1 = BIT(color_prom[i], 4);
int const b = 0x4f * bit0 + 0xa8 * bit1;
palette.set_pen_color(i,rgb_t(r,g,b));
}
}
TILE_GET_INFO_MEMBER(xyonix_state::get_tile_info)
{
int tileno;
int attr = m_vidram[tile_index+0x1000+1];
tileno = (m_vidram[tile_index+1] << 0) | ((attr & 0x0f) << 8);
SET_TILE_INFO_MEMBER(0,tileno,attr >> 4,0);
}
WRITE8_MEMBER(xyonix_state::vidram_w)
{
m_vidram[offset] = data;
m_tilemap->mark_tile_dirty((offset-1)&0x0fff);
}
void xyonix_state::video_start()
{
m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(xyonix_state::get_tile_info)), TILEMAP_SCAN_ROWS, 4, 8, 80, 32);
}
uint32_t xyonix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}
#if 0
// commented out because the tilemap renderer is much simpler
MC6845_UPDATE_ROW( xyonix_state::crtc_update_row )
{
const pen_t *pen = m_palette->pens();
for (int i = 0; i < x_count; i++)
{
uint8_t code = m_vidram[(0x0000 | (ma + i)) + 1];
uint8_t attr = m_vidram[(0x1000 | (ma + i)) + 1];
// tile offset into the gfx rom
uint16_t tile = ((((attr & 0x0f) << 8) | code) << 3) | ra;
// tile data (4 pixels with 4 bit color code)
uint16_t data = m_gfx->base()[0x8000 | tile] << 8 | m_gfx->base()[tile];
// draw 4 pixels
bitmap.pix32(y, i * 4 + 0) = pen[(attr & 0xf0) | bitswap<4>(data, 4, 0, 12, 8)];
bitmap.pix32(y, i * 4 + 1) = pen[(attr & 0xf0) | bitswap<4>(data, 5, 1, 13, 9)];
bitmap.pix32(y, i * 4 + 2) = pen[(attr & 0xf0) | bitswap<4>(data, 6, 2, 14, 10)];
bitmap.pix32(y, i * 4 + 3) = pen[(attr & 0xf0) | bitswap<4>(data, 7, 3, 15, 11)];
}
}
#endif
/* Inputs ********************************************************************/
@ -177,7 +319,8 @@ void xyonix_state::port_map(address_map &map)
map(0x21, 0x21).nopr().w("sn2", FUNC(sn76496_device::write));
map(0x40, 0x40).w(FUNC(xyonix_state::nmiack_w));
map(0x50, 0x50).w(FUNC(xyonix_state::irqack_w));
map(0x60, 0x61).nopw(); /* mc6845 */
map(0x60, 0x60).w(m_crtc, FUNC(mc6845_device::address_w));
map(0x61, 0x61).rw(m_crtc, FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
map(0xe0, 0xe0).rw(FUNC(xyonix_state::io_r), FUNC(xyonix_state::io_w));
}
@ -256,17 +399,22 @@ void xyonix_state::xyonix(machine_config &config)
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(80*4, 32*8);
screen.set_visarea(0, 80*4-1, 0, 28*8-1);
screen.set_raw(16_MHz_XTAL / 2, 508, 0, 320, 256, 0, 224); // 8 MHz?
screen.set_screen_update(FUNC(xyonix_state::screen_update));
// screen.set_screen_update(m_crtc, FUNC(mc6845_device::screen_update));
screen.set_palette("palette");
screen.screen_vblank().set(FUNC(xyonix_state::nmiclk_w));
GFXDECODE(config, m_gfxdecode, "palette", gfx_xyonix);
PALETTE(config, "palette", FUNC(xyonix_state::xyonix_palette), 256);
MC6845(config, m_crtc, 16_MHz_XTAL / 8); // 2 MHz?
m_crtc->set_screen("screen");
m_crtc->set_show_border_area(false);
m_crtc->set_char_width(4);
// m_crtc->set_update_row_callback(FUNC(xyonix_state::crtc_update_row));
m_crtc->out_vsync_callback().set(FUNC(xyonix_state::nmiclk_w));
/* sound hardware */
SPEAKER(config, "mono").front_center();

View File

@ -1,58 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood
#ifndef MAME_INCLUDES_XYONIX_H
#define MAME_INCLUDES_XYONIX_H
#pragma once
#include "emupal.h"
#include "tilemap.h"
class xyonix_state : public driver_device
{
public:
xyonix_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_vidram(*this, "vidram")
{ }
void xyonix(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_shared_ptr<uint8_t> m_vidram;
tilemap_t *m_tilemap;
int m_e0_data;
int m_credits;
int m_coins;
int m_prev_coin;
bool m_nmi_mask;
DECLARE_WRITE_LINE_MEMBER(nmiclk_w);
DECLARE_WRITE8_MEMBER(irqack_w);
DECLARE_WRITE8_MEMBER(nmiack_w);
DECLARE_READ8_MEMBER(io_r);
DECLARE_WRITE8_MEMBER(io_w);
DECLARE_WRITE8_MEMBER(vidram_w);
TILE_GET_INFO_MEMBER(get_tile_info);
void xyonix_palette(palette_device &palette) const;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void handle_coins(int coin);
void main_map(address_map &map);
void port_map(address_map &map);
};
#endif // MAME_INCLUDES_XYONIX_H

View File

@ -1,61 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood
#include "emu.h"
#include "includes/xyonix.h"
void xyonix_state::xyonix_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
for (int i = 0; i < palette.entries(); i++)
{
int bit0, bit1, bit2;
// red component
bit0 = BIT(color_prom[i], 0);
bit1 = BIT(color_prom[i], 1);
bit2 = BIT(color_prom[i], 2);
int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// green component
bit0 = BIT(color_prom[i], 5);
bit1 = BIT(color_prom[i], 6);
bit2 = BIT(color_prom[i], 7);
int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
// blue component
bit0 = BIT(color_prom[i], 3);
bit1 = BIT(color_prom[i], 4);
int const b = 0x4f * bit0 + 0xa8 * bit1;
palette.set_pen_color(i,rgb_t(r,g,b));
}
}
TILE_GET_INFO_MEMBER(xyonix_state::get_tile_info)
{
int tileno;
int attr = m_vidram[tile_index+0x1000+1];
tileno = (m_vidram[tile_index+1] << 0) | ((attr & 0x0f) << 8);
SET_TILE_INFO_MEMBER(0,tileno,attr >> 4,0);
}
WRITE8_MEMBER(xyonix_state::vidram_w)
{
m_vidram[offset] = data;
m_tilemap->mark_tile_dirty((offset-1)&0x0fff);
}
void xyonix_state::video_start()
{
m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(xyonix_state::get_tile_info)), TILEMAP_SCAN_ROWS, 4, 8, 80, 32);
}
uint32_t xyonix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}