mirror of
https://github.com/holub/mame
synced 2025-07-03 17:08:39 +03:00
b16.cpp: device_finder (nw)
This commit is contained in:
parent
44243dcac8
commit
ee20deea84
@ -27,15 +27,29 @@ public:
|
|||||||
b16_state(const machine_config &mconfig, device_type type, const char *tag)
|
b16_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||||
: driver_device(mconfig, type, tag),
|
: driver_device(mconfig, type, tag),
|
||||||
m_vram(*this, "vram"),
|
m_vram(*this, "vram"),
|
||||||
|
m_mc6845(*this, "crtc"),
|
||||||
m_dma8237(*this, "8237dma"),
|
m_dma8237(*this, "8237dma"),
|
||||||
m_maincpu(*this, "maincpu"),
|
m_maincpu(*this, "maincpu"),
|
||||||
m_gfxdecode(*this, "gfxdecode"),
|
m_gfxdecode(*this, "gfxdecode"),
|
||||||
m_palette(*this, "palette") { }
|
m_palette(*this, "palette"),
|
||||||
|
m_char_rom(*this, "pcg") { }
|
||||||
|
|
||||||
uint8_t *m_char_rom;
|
void b16(machine_config &config);
|
||||||
required_shared_ptr<uint16_t> m_vram;
|
|
||||||
|
protected:
|
||||||
|
virtual void video_start() override;
|
||||||
|
|
||||||
|
private:
|
||||||
uint8_t m_crtc_vreg[0x100], m_crtc_index;
|
uint8_t m_crtc_vreg[0x100], m_crtc_index;
|
||||||
|
|
||||||
|
required_shared_ptr<uint16_t> m_vram;
|
||||||
|
required_device<mc6845_device> m_mc6845;
|
||||||
|
required_device<am9517a_device> m_dma8237;
|
||||||
|
required_device<cpu_device> m_maincpu;
|
||||||
|
required_device<gfxdecode_device> m_gfxdecode;
|
||||||
|
required_device<palette_device> m_palette;
|
||||||
|
required_region_ptr<uint8_t> m_char_rom;
|
||||||
|
|
||||||
DECLARE_READ16_MEMBER(vblank_r);
|
DECLARE_READ16_MEMBER(vblank_r);
|
||||||
DECLARE_WRITE8_MEMBER(b16_pcg_w);
|
DECLARE_WRITE8_MEMBER(b16_pcg_w);
|
||||||
DECLARE_WRITE8_MEMBER(b16_6845_address_w);
|
DECLARE_WRITE8_MEMBER(b16_6845_address_w);
|
||||||
@ -45,17 +59,8 @@ public:
|
|||||||
DECLARE_READ8_MEMBER(memory_read_byte);
|
DECLARE_READ8_MEMBER(memory_read_byte);
|
||||||
DECLARE_WRITE8_MEMBER(memory_write_byte);
|
DECLARE_WRITE8_MEMBER(memory_write_byte);
|
||||||
|
|
||||||
virtual void video_start() override;
|
|
||||||
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||||
|
|
||||||
mc6845_device *m_mc6845;
|
|
||||||
required_device<am9517a_device> m_dma8237;
|
|
||||||
virtual void machine_start() override;
|
|
||||||
virtual void machine_reset() override;
|
|
||||||
required_device<cpu_device> m_maincpu;
|
|
||||||
required_device<gfxdecode_device> m_gfxdecode;
|
|
||||||
required_device<palette_device> m_palette;
|
|
||||||
void b16(machine_config &config);
|
|
||||||
void b16_io(address_map &map);
|
void b16_io(address_map &map);
|
||||||
void b16_map(address_map &map);
|
void b16_map(address_map &map);
|
||||||
};
|
};
|
||||||
@ -80,30 +85,26 @@ public:
|
|||||||
|
|
||||||
void b16_state::video_start()
|
void b16_state::video_start()
|
||||||
{
|
{
|
||||||
// find memory regions
|
save_item(NAME(m_crtc_vreg));
|
||||||
m_char_rom = memregion("pcg")->base();
|
save_item(NAME(m_crtc_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t b16_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
uint32_t b16_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||||
{
|
{
|
||||||
int x,y;
|
for(int y=0;y<mc6845_v_display;y++)
|
||||||
int xi,yi;
|
|
||||||
uint8_t *gfx_rom = memregion("pcg")->base();
|
|
||||||
|
|
||||||
for(y=0;y<mc6845_v_display;y++)
|
|
||||||
{
|
{
|
||||||
for(x=0;x<mc6845_h_display;x++)
|
for(int x=0;x<mc6845_h_display;x++)
|
||||||
{
|
{
|
||||||
int tile = m_vram[x+y*mc6845_h_display] & 0xff;
|
int tile = m_vram[x+y*mc6845_h_display] & 0xff;
|
||||||
int color = (m_vram[x+y*mc6845_h_display] & 0x700) >> 8;
|
int color = (m_vram[x+y*mc6845_h_display] & 0x700) >> 8;
|
||||||
int pen;
|
int pen;
|
||||||
|
|
||||||
for(yi=0;yi<mc6845_tile_height;yi++)
|
for(int yi=0;yi<mc6845_tile_height;yi++)
|
||||||
{
|
{
|
||||||
for(xi=0;xi<8;xi++)
|
for(int xi=0;xi<8;xi++)
|
||||||
{
|
{
|
||||||
pen = (gfx_rom[tile*16+yi] >> (7-xi) & 1) ? color : 0;
|
pen = (m_char_rom[tile*16+yi] >> (7-xi) & 1) ? color : 0;
|
||||||
|
|
||||||
if(y*mc6845_tile_height < 400 && x*8+xi < 640) /* TODO: safety check */
|
if(y*mc6845_tile_height < 400 && x*8+xi < 640) /* TODO: safety check */
|
||||||
bitmap.pix16(y*mc6845_tile_height+yi, x*8+xi) = m_palette->pen(pen);
|
bitmap.pix16(y*mc6845_tile_height+yi, x*8+xi) = m_palette->pen(pen);
|
||||||
@ -251,16 +252,6 @@ static GFXDECODE_START( gfx_b16 )
|
|||||||
GFXDECODE_ENTRY( "pcg", 0x0000, b16_charlayout, 0, 1 )
|
GFXDECODE_ENTRY( "pcg", 0x0000, b16_charlayout, 0, 1 )
|
||||||
GFXDECODE_END
|
GFXDECODE_END
|
||||||
|
|
||||||
void b16_state::machine_start()
|
|
||||||
{
|
|
||||||
m_mc6845 = machine().device<mc6845_device>("crtc");
|
|
||||||
}
|
|
||||||
|
|
||||||
void b16_state::machine_reset()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
READ8_MEMBER(b16_state::memory_read_byte)
|
READ8_MEMBER(b16_state::memory_read_byte)
|
||||||
{
|
{
|
||||||
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
address_space& prog_space = m_maincpu->space(AS_PROGRAM);
|
||||||
@ -276,7 +267,7 @@ WRITE8_MEMBER(b16_state::memory_write_byte)
|
|||||||
|
|
||||||
MACHINE_CONFIG_START(b16_state::b16)
|
MACHINE_CONFIG_START(b16_state::b16)
|
||||||
/* basic machine hardware */
|
/* basic machine hardware */
|
||||||
MCFG_DEVICE_ADD("maincpu",I8086, XTAL(14'318'181)/2) //unknown xtal
|
MCFG_DEVICE_ADD(m_maincpu, I8086, XTAL(14'318'181)/2) //unknown xtal
|
||||||
MCFG_DEVICE_PROGRAM_MAP(b16_map)
|
MCFG_DEVICE_PROGRAM_MAP(b16_map)
|
||||||
MCFG_DEVICE_IO_MAP(b16_io)
|
MCFG_DEVICE_IO_MAP(b16_io)
|
||||||
|
|
||||||
@ -290,16 +281,16 @@ MACHINE_CONFIG_START(b16_state::b16)
|
|||||||
MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1)
|
MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1)
|
||||||
MCFG_SCREEN_PALETTE("palette")
|
MCFG_SCREEN_PALETTE("palette")
|
||||||
|
|
||||||
MCFG_MC6845_ADD("crtc", H46505, "screen", XTAL(14'318'181)/5) /* unknown clock, hand tuned to get ~60 fps */
|
MCFG_MC6845_ADD(m_mc6845, H46505, "screen", XTAL(14'318'181)/5) /* unknown clock, hand tuned to get ~60 fps */
|
||||||
MCFG_MC6845_SHOW_BORDER_AREA(false)
|
MCFG_MC6845_SHOW_BORDER_AREA(false)
|
||||||
MCFG_MC6845_CHAR_WIDTH(8)
|
MCFG_MC6845_CHAR_WIDTH(8)
|
||||||
|
|
||||||
MCFG_DEVICE_ADD("8237dma", AM9517A, XTAL(14'318'181)/2)
|
MCFG_DEVICE_ADD(m_dma8237, AM9517A, XTAL(14'318'181)/2)
|
||||||
MCFG_I8237_IN_MEMR_CB(READ8(*this, b16_state, memory_read_byte))
|
MCFG_I8237_IN_MEMR_CB(READ8(*this, b16_state, memory_read_byte))
|
||||||
MCFG_I8237_OUT_MEMW_CB(WRITE8(*this, b16_state, memory_write_byte))
|
MCFG_I8237_OUT_MEMW_CB(WRITE8(*this, b16_state, memory_write_byte))
|
||||||
|
|
||||||
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_b16)
|
MCFG_DEVICE_ADD(m_gfxdecode, GFXDECODE, m_palette, gfx_b16)
|
||||||
MCFG_PALETTE_ADD("palette", 8)
|
MCFG_PALETTE_ADD(m_palette, 8)
|
||||||
// MCFG_PALETTE_INIT_STANDARD(black_and_white) // TODO
|
// MCFG_PALETTE_INIT_STANDARD(black_and_white) // TODO
|
||||||
|
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
Loading…
Reference in New Issue
Block a user