- tryout.cpp: used object finders and other minor cleanups

- gp32.h: initialized some arrays which were causing problems in drvnoclear builds
This commit is contained in:
Ivan Vangelista 2021-08-11 07:21:21 +02:00
parent f4fa9412e3
commit 47e91b2686
5 changed files with 106 additions and 112 deletions

View File

@ -50,7 +50,7 @@
//**************************************************************************
DEFINE_DEVICE_TYPE(A2BUS_Q68, a2bus_q68_device, "q68", "Stellation Two Q-68")
DEFINE_DEVICE_TYPE(A2BUS_Q68PLUS, a2bus_q68plus_device, "q68", "Stellation Two Q-68 Plus")
DEFINE_DEVICE_TYPE(A2BUS_Q68PLUS, a2bus_q68plus_device, "q68plus", "Stellation Two Q-68 Plus")
void a2bus_q68_device::m68008_mem(address_map &map)
{

View File

@ -23,6 +23,7 @@ $208 strikes count
#include "includes/tryout.h"
#include "cpu/m6502/m6502.h"
#include "machine/gen_latch.h"
#include "sound/ymopn.h"
#include "screen.h"
#include "speaker.h"
@ -30,17 +31,10 @@ $208 strikes count
void tryout_state::nmi_ack_w(uint8_t data)
{
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE );
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}
void tryout_state::sound_w(uint8_t data)
{
m_soundlatch->write(data);
m_audiocpu->set_input_line(0, HOLD_LINE);
}
/*this is actually irq/nmi mask, polls only four values at start up (81->01->81->01) and then
stays on this state.*/
// this is actually irq/nmi mask, polls only four values at start up (81->01->81->01) and then stays on this state.
void tryout_state::sound_irq_ack_w(uint8_t data)
{
// m_audiocpu->set_input_line(0, CLEAR_LINE);
@ -48,22 +42,22 @@ void tryout_state::sound_irq_ack_w(uint8_t data)
void tryout_state::machine_start()
{
membank("bank1")->configure_entries(0, 2, memregion("maincpu")->base() + 0x10000, 0x2000);
m_rombank->configure_entries(0, 2, memregion("maincpu")->base() + 0x10000, 0x2000);
}
void tryout_state::bankswitch_w(uint8_t data)
{
membank("bank1")->set_entry(data & 0x01);
m_rombank->set_entry(data & 0x01);
}
void tryout_state::main_cpu(address_map &map)
{
map(0x0000, 0x07ff).ram();
map(0x1000, 0x17ff).ram().w(FUNC(tryout_state::videoram_w)).share("videoram");
map(0x2000, 0x3fff).bankr("bank1");
map(0x1000, 0x17ff).ram().w(FUNC(tryout_state::videoram_w)).share(m_videoram);
map(0x2000, 0x3fff).bankr(m_rombank);
map(0x4000, 0xbfff).rom();
map(0xc800, 0xc87f).ram().share("spriteram");
map(0xcc00, 0xcc7f).ram().share("spriteram2");
map(0xc800, 0xc87f).ram().share(m_spriteram[0]);
map(0xcc00, 0xcc7f).ram().share(m_spriteram[1]);
map(0xd000, 0xd7ff).rw(FUNC(tryout_state::vram_r), FUNC(tryout_state::vram_w));
map(0xe000, 0xe000).portr("DSW");
map(0xe001, 0xe001).portr("P1");
@ -72,17 +66,17 @@ void tryout_state::main_cpu(address_map &map)
map(0xe301, 0xe301).w(FUNC(tryout_state::flipscreen_w));
map(0xe302, 0xe302).w(FUNC(tryout_state::bankswitch_w));
map(0xe401, 0xe401).w(FUNC(tryout_state::vram_bankswitch_w));
map(0xe402, 0xe404).writeonly().share("gfx_control");
map(0xe414, 0xe414).w(FUNC(tryout_state::sound_w));
map(0xe402, 0xe404).writeonly().share(m_gfx_control);
map(0xe414, 0xe414).w("soundlatch", FUNC(generic_latch_8_device::write));
map(0xe417, 0xe417).w(FUNC(tryout_state::nmi_ack_w));
map(0xfff0, 0xffff).rom().region("maincpu", 0xbff0); /* reset vectors */
map(0xfff0, 0xffff).rom().region("maincpu", 0xbff0); // reset vectors
}
void tryout_state::sound_cpu(address_map &map)
{
map(0x0000, 0x07ff).ram();
map(0x4000, 0x4001).rw("ymsnd", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xa000, 0xa000).r(m_soundlatch, FUNC(generic_latch_8_device::read));
map(0xa000, 0xa000).r("soundlatch", FUNC(generic_latch_8_device::read));
map(0xd000, 0xd000).w(FUNC(tryout_state::sound_irq_ack_w));
map(0xc000, 0xffff).rom();
}
@ -151,13 +145,13 @@ INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8, /* 8*8 characters */
8,8, // 8*8 characters
RGN_FRAC(1,2),
2, /* 2 bits per pixel */
{ 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */
2, // 2 bits per pixel
{ 0, 4 }, // the two bitplanes for 4 pixels are packed into one byte
{ 3, 2, 1, 0, RGN_FRAC(1,2)+3, RGN_FRAC(1,2)+2, RGN_FRAC(1,2)+1, RGN_FRAC(1,2)+0 },
{ 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
8*8 /* every char takes 8 consecutive bytes */
8*8 // every char takes 8 consecutive bytes
};
static const gfx_layout vramlayout =
@ -188,35 +182,36 @@ static const gfx_layout spritelayout =
static GFXDECODE_START( gfx_tryout )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 8 )
GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 4 )
GFXDECODE_ENTRY( nullptr, 0, vramlayout, 0, 4 )
GFXDECODE_RAM( "vram_gfx", 0, vramlayout, 0, 4 )
GFXDECODE_END
void tryout_state::tryout(machine_config &config)
{
/* basic machine hardware */
M6502(config, m_maincpu, 2000000); /* ? */
// basic machine hardware
M6502(config, m_maincpu, 2000000); // ?
m_maincpu->set_addrmap(AS_PROGRAM, &tryout_state::main_cpu);
M6502(config, m_audiocpu, 1500000); /* ? */
M6502(config, m_audiocpu, 1500000); // ?
m_audiocpu->set_addrmap(AS_PROGRAM, &tryout_state::sound_cpu);
m_audiocpu->set_periodic_int(FUNC(tryout_state::nmi_line_pulse), attotime::from_hz(1000)); /* controls BGM tempo, 1000 is an hand-tuned value to match a side-by-side video */
m_audiocpu->set_periodic_int(FUNC(tryout_state::nmi_line_pulse), attotime::from_hz(1000)); // controls BGM tempo, 1000 is an hand-tuned value to match a side-by-side video
/* video hardware */
// video hardware
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate
screen.set_size(256, 256);
screen.set_visarea(0*8, 32*8-1, 1*8, 31*8-1);
screen.set_screen_update(FUNC(tryout_state::screen_update));
screen.set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_tryout);
PALETTE(config, m_palette, FUNC(tryout_state::tryout_palette), 0x20);
PALETTE(config, m_palette, FUNC(tryout_state::palette), 0x20);
/* sound hardware */
// sound hardware
SPEAKER(config, "mono").front_center();
GENERIC_LATCH_8(config, m_soundlatch);
generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch"));
soundlatch.data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_IRQ0);
YM2203(config, "ymsnd", 1500000).add_route(ALL_OUTPUTS, "mono", 0.50);
}

View File

@ -105,7 +105,12 @@ public:
m_io_in0(*this, "IN0"),
m_io_in1(*this, "IN1"),
m_screen(*this, "screen"),
m_palette(*this, "palette") { }
m_palette(*this, "palette")
{
std::fill(std::begin(m_s3c240x_lcd_regs), std::end(m_s3c240x_lcd_regs), 0);
std::fill(std::begin(m_s3c240x_uart_0_regs), std::end(m_s3c240x_uart_0_regs), 0);
std::fill(std::begin(m_s3c240x_uart_1_regs), std::end(m_s3c240x_uart_1_regs), 0);
}
void gp32(machine_config &config);

View File

@ -5,7 +5,6 @@
#pragma once
#include "machine/gen_latch.h"
#include "emupal.h"
#include "tilemap.h"
@ -18,37 +17,41 @@ public:
m_audiocpu(*this, "audiocpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch"),
m_videoram(*this, "videoram"),
m_spriteram(*this, "spriteram"),
m_spriteram2(*this, "spriteram2"),
m_gfx_control(*this, "gfx_control")
m_spriteram(*this, "spriteram%u", 1U),
m_gfx_control(*this, "gfx_control"),
m_vram(*this, "vram", 8 * 0x800, ENDIANNESS_LITTLE),
m_vram_gfx(*this, "vram_gfx", 0x6000, ENDIANNESS_LITTLE),
m_rombank(*this, "rombank")
{ }
void tryout(machine_config &config);
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
protected:
virtual void machine_start() override;
virtual void video_start() override;
private:
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<generic_latch_8_device> m_soundlatch;
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_spriteram2;
required_shared_ptr_array<uint8_t, 2> m_spriteram;
required_shared_ptr<uint8_t> m_gfx_control;
memory_share_creator<uint8_t> m_vram;
memory_share_creator<uint8_t> m_vram_gfx;
required_memory_bank m_rombank;
tilemap_t *m_fg_tilemap;
tilemap_t *m_bg_tilemap;
uint8_t m_vram_bank;
std::unique_ptr<uint8_t[]> m_vram;
std::unique_ptr<uint8_t[]> m_vram_gfx;
void nmi_ack_w(uint8_t data);
void sound_w(uint8_t data);
void sound_irq_ack_w(uint8_t data);
void bankswitch_w(uint8_t data);
uint8_t vram_r(offs_t offset);
@ -62,9 +65,7 @@ private:
TILEMAP_MAPPER_MEMBER(get_fg_memory_offset);
TILEMAP_MAPPER_MEMBER(get_bg_memory_offset);
virtual void machine_start() override;
virtual void video_start() override;
void tryout_palette(palette_device &palette) const;
void palette(palette_device &palette) const;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);

View File

@ -11,7 +11,7 @@
#include "includes/tryout.h"
void tryout_state::tryout_palette(palette_device &palette) const
void tryout_state::palette(palette_device &palette) const
{
uint8_t const *const color_prom = memregion("proms")->base();
@ -68,25 +68,26 @@ void tryout_state::videoram_w(offs_t offset, uint8_t data)
void tryout_state::vram_w(offs_t offset, uint8_t data)
{
/* There are eight banks of vram - in bank 0 the first 0x400 bytes
is reserved for the tilemap. In banks 2, 4 and 6 the game never
are reserved for the tilemap. In banks 2, 4 and 6 the game never
writes to the first 0x400 bytes - I suspect it's either
unused, or it actually mirrors the tilemap ram from the first bank.
The rest of the vram is tile data which has the bitplanes arranged
in a very strange format. For Mame's sake we reformat this on
in a very strange format. For MAME's sake we reformat this on
the fly for easier gfx decode.
Bit 0 of the bank register seems special - it's kept low when uploading
gfx data and then set high from that point onwards.
*/
const uint8_t bank=(m_vram_bank>>1)&0x7;
const uint8_t bank = (m_vram_bank >> 1) & 0x7;
if ((bank==0 || bank==2 || bank==4 || bank==6) && (offset&0x7ff)<0x400) {
int newoff=offset&0x3ff;
if ((bank == 0 || bank == 2 || bank == 4 || bank == 6) && (offset & 0x7ff) < 0x400)
{
int newoff = offset & 0x3ff;
m_vram[newoff]=data;
m_vram[newoff] = data;
m_bg_tilemap->mark_tile_dirty(newoff);
return;
}
@ -100,37 +101,38 @@ void tryout_state::vram_w(offs_t offset, uint8_t data)
etc.
*/
offset=(offset&0x7ff) | (bank<<11);
m_vram[offset]=data;
offset = (offset & 0x7ff) | (bank << 11);
m_vram[offset] = data;
switch (offset&0x1c00) {
switch (offset & 0x1c00)
{
case 0x0400:
m_vram_gfx[(offset&0x3ff) + 0x0000 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x2000 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x0000 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x2000 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
case 0x0800:
m_vram_gfx[(offset&0x3ff) + 0x4000 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x4400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x4000 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x4400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
case 0x0c00:
m_vram_gfx[(offset&0x3ff) + 0x0400 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x2400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x0400 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x2400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
case 0x1400:
m_vram_gfx[(offset&0x3ff) + 0x0800 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x2800 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x0800 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x2800 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
case 0x1800:
m_vram_gfx[(offset&0x3ff) + 0x4800 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x4c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x4800 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x4c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
case 0x1c00:
m_vram_gfx[(offset&0x3ff) + 0x0c00 + ((offset&0x2000)>>1)]=(~data&0xf);
m_vram_gfx[(offset&0x3ff) + 0x2c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4;
m_vram_gfx[(offset & 0x3ff) + 0x0c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf);
m_vram_gfx[(offset & 0x3ff) + 0x2c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4;
break;
}
m_gfxdecode->gfx(2)->mark_dirty((offset-0x400/64)&0x7f);
m_gfxdecode->gfx(2)->mark_dirty((offset - 0x400 / 64) & 0x7f);
}
void tryout_state::vram_bankswitch_w(uint8_t data)
@ -154,9 +156,9 @@ TILEMAP_MAPPER_MEMBER(tryout_state::get_bg_memory_offset)
// if (col&0x20)
// a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + (( ( 0x10 - (col & 0x10) ) ) << 4) + ((( (col & 0x20))) << 4);
// else
a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + (( ( (col & 0x10) ) ) << 4) + ((( (col & 0x20))) << 4);
a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + ((col & 0x10) << 4) + ((col & 0x20) << 4);
// osd_printf_debug("%d %d -> %d\n",col,row, a);
// osd_printf_debug("%d %d -> %d\n", col, row, a);
return a;
}
@ -165,34 +167,25 @@ void tryout_state::video_start()
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_fg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_fg_memory_offset)), 8, 8, 32,32);
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_bg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_bg_memory_offset)), 16,16, 64,16);
m_vram=std::make_unique<uint8_t[]>(8 * 0x800);
m_vram_gfx=std::make_unique<uint8_t[]>(0x6000);
m_gfxdecode->gfx(2)->set_source(m_vram_gfx.get());
m_fg_tilemap->set_transparent_pen(0);
save_item(NAME(m_vram_bank));
save_pointer(NAME(m_vram), 8 * 0x800);
save_pointer(NAME(m_vram_gfx), 0x6000);
}
void tryout_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
{
int offs,fx,fy,x,y,color,sprite,inc;
for (offs = 0;offs < 0x7f;offs += 4)
for (int offs = 0; offs < 0x7f; offs += 4)
{
if (!(m_spriteram[offs]&1))
if (!(m_spriteram[0][offs] & 1))
continue;
sprite = m_spriteram[offs+1] + ((m_spriteram2[offs]&7)<<8);
x = m_spriteram[offs+3]-3;
y = m_spriteram[offs+2];
color = 0;//(m_spriteram[offs] & 8)>>3;
fx = (m_spriteram[offs] & 8)>>3;
fy = 0;
inc = 16;
int sprite = m_spriteram[0][offs + 1] + ((m_spriteram[1][offs] & 7) << 8);
int x = m_spriteram[0][offs + 3] - 3;
int y = m_spriteram[0][offs + 2];
int color = 0;//(m_spriteram[0][offs] & 8) >> 3;
int fx = (m_spriteram[0][offs] & 8) >> 3;
int fy = 0;
int inc = 16;
if (flip_screen())
{
@ -205,22 +198,22 @@ void tryout_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
inc = -inc;
}
/* Double Height */
if(m_spriteram[offs] & 0x10)
// Double Height
if(m_spriteram[0][offs] & 0x10)
{
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
m_gfxdecode->gfx(1)->transpen(bitmap, cliprect,
sprite,
color,fx,fy,x,y + inc,0);
color, fx, fy, x, y + inc, 0);
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
sprite+1,
color,fx,fy,x,y,0);
m_gfxdecode->gfx(1)->transpen(bitmap, cliprect,
sprite + 1,
color, fx, fy, x, y, 0);
}
else
{
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
m_gfxdecode->gfx(1)->transpen(bitmap, cliprect,
sprite,
color,fx,fy,x,y,0);
color, fx, fy, x, y, 0);
}
}
}
@ -230,30 +223,30 @@ uint32_t tryout_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
int scrollx = 0;
if (!flip_screen())
m_fg_tilemap->set_scrollx(0, 16); /* Assumed hard-wired */
m_fg_tilemap->set_scrollx(0, 16); // Assumed hard-wired
else
m_fg_tilemap->set_scrollx(0, -8); /* Assumed hard-wired */
m_fg_tilemap->set_scrollx(0, -8); // Assumed hard-wired
scrollx = m_gfx_control[1] + ((m_gfx_control[0]&1)<<8) + ((m_gfx_control[0]&4)<<7) - ((m_gfx_control[0] & 2) ? 0 : 0x100);
scrollx = m_gfx_control[1] + ((m_gfx_control[0] & 1) << 8) + ((m_gfx_control[0] & 4) << 7) - ((m_gfx_control[0] & 2) ? 0 : 0x100);
/* wrap-around */
if(m_gfx_control[1] == 0) { scrollx+=0x100; }
// wrap-around
if (m_gfx_control[1] == 0) { scrollx += 0x100; }
m_bg_tilemap->set_scrollx(0, scrollx+2); /* why +2? hard-wired? */
m_bg_tilemap->set_scrollx(0, scrollx + 2); // why +2? hard-wired?
m_bg_tilemap->set_scrolly(0, -m_gfx_control[2]);
if(!(m_gfx_control[0] & 0x8)) // screen disable
{
/* TODO: Color might be different, needs a video from an original pcb. */
// TODO: Color might be different, needs a video from an original PCB.
bitmap.fill(m_palette->pen(0x10), cliprect);
}
else
{
m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0);
draw_sprites(bitmap,cliprect);
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
draw_sprites(bitmap, cliprect);
}
// popmessage("%02x %02x %02x %02x",m_gfx_control[0],m_gfx_control[1],m_gfx_control[2],scrollx);
// popmessage("%02x %02x %02x %02x", m_gfx_control[0], m_gfx_control[1], m_gfx_control[2], scrollx);
return 0;
}