Merge pull request #4957 from cam900/dgpix_args

dgpix.cpp : Updates
This commit is contained in:
R. Belmont 2019-05-01 21:36:36 -04:00 committed by GitHub
commit 940b14de51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,6 +163,7 @@ class dgpix_state : public driver_device
public:
dgpix_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_flash(*this, "flash"),
m_maincpu(*this, "maincpu"),
m_vblank(*this, "VBLANK")
{ }
@ -176,57 +177,60 @@ public:
void init_kdynastg();
void init_fmaniac3();
private:
required_device<cpu_device> m_maincpu;
required_ioport m_vblank;
std::unique_ptr<uint32_t[]> m_vram;
int m_vbuffer;
int m_flash_roms;
int m_old_vbuf;
uint32_t m_flash_cmd;
int32_t m_first_offset;
DECLARE_READ32_MEMBER(flash_r);
DECLARE_WRITE32_MEMBER(flash_w);
DECLARE_WRITE32_MEMBER(vram_w);
DECLARE_READ32_MEMBER(vram_r);
DECLARE_WRITE32_MEMBER(vbuffer_w);
DECLARE_WRITE32_MEMBER(coin_w);
DECLARE_READ32_MEMBER(vblank_r);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
uint32_t screen_update_dgpix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void cpu_map(address_map &map);
private:
required_memory_region m_flash;
required_device<cpu_device> m_maincpu;
required_ioport m_vblank;
std::unique_ptr<u16[]> m_vram;
int m_vbuffer;
int m_flash_roms;
int m_old_vbuf;
u32 m_flash_cmd;
s32 m_first_offset;
u32 flash_r(offs_t offset);
void flash_w(offs_t offset, u32 data, u32 mem_mask = ~0);
void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
u16 vram_r(offs_t offset);
void vbuffer_w(u32 data);
void coin_w(u32 data);
u32 vblank_r();
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void mem_map(address_map &map);
void io_map(address_map &map);
};
READ32_MEMBER(dgpix_state::flash_r)
u32 dgpix_state::flash_r(offs_t offset)
{
uint32_t *ROM = (uint32_t *)memregion("flash")->base();
u32 *ROM = (u32 *)m_flash->base();
if(offset >= (0x2000000 - m_flash_roms * 0x400000) / 4)
if (offset >= (0x2000000 - m_flash_roms * 0x400000) / 4)
{
if(m_flash_cmd == 0x90900000)
if (m_flash_cmd == 0x90900000)
{
//read maker ID and chip ID
return 0x00890014;
}
else if(m_flash_cmd == 0x00700000)
else if (m_flash_cmd == 0x00700000)
{
//read status
return 0x80<<16;
}
else if(m_flash_cmd == 0x70700000)
else if (m_flash_cmd == 0x70700000)
{
//read status and ?
return 0x82<<16;
}
else if(m_flash_cmd == 0xe8e80000)
else if (m_flash_cmd == 0xe8e80000)
{
//read status ?
return 0x80<<16;
@ -236,15 +240,15 @@ READ32_MEMBER(dgpix_state::flash_r)
return ROM[offset];
}
WRITE32_MEMBER(dgpix_state::flash_w)
void dgpix_state::flash_w(offs_t offset, u32 data, u32 mem_mask)
{
if(m_flash_cmd == 0x20200000)
if (m_flash_cmd == 0x20200000)
{
// erase game settings
if(data == 0xd0d00000)
if (data == 0xd0d00000)
{
// point to game settings
uint8_t *rom = (uint8_t *)memregion("flash")->base() + offset*4;
u8 *rom = (u8 *)m_flash->base() + offset*4;
// erase one block
memset(rom, 0xff, 0x10000);
@ -252,9 +256,9 @@ WRITE32_MEMBER(dgpix_state::flash_w)
m_flash_cmd = 0;
}
}
else if(m_flash_cmd == 0x0f0f0000)
else if (m_flash_cmd == 0x0f0f0000)
{
if(data == 0xd0d00000 && offset == m_first_offset)
if (data == 0xd0d00000 && offset == m_first_offset)
{
// finished
m_flash_cmd = 0;
@ -262,11 +266,11 @@ WRITE32_MEMBER(dgpix_state::flash_w)
}
else
{
uint16_t *rom = (uint16_t *)memregion("flash")->base();
u16 *rom = (u16 *)m_flash->base();
// write game settings
if(ACCESSING_BITS_0_15)
if (ACCESSING_BITS_0_15)
rom[BYTE_XOR_BE(offset*2 + 1)] = data & 0xffff;
else
rom[BYTE_XOR_BE(offset*2 + 0)] = (data & 0xffff0000) >> 16;
@ -276,38 +280,27 @@ WRITE32_MEMBER(dgpix_state::flash_w)
{
m_flash_cmd = data;
if(m_flash_cmd == 0x0f0f0000 && m_first_offset == -1)
if (m_flash_cmd == 0x0f0f0000 && m_first_offset == -1)
{
m_first_offset = offset;
}
}
}
WRITE32_MEMBER(dgpix_state::vram_w)
void dgpix_state::vram_w(offs_t offset, u16 data, u16 mem_mask)
{
uint32_t *dest = &m_vram[offset+(0x40000/4)*m_vbuffer];
if (mem_mask == 0xffffffff)
{
if (~data & 0x80000000)
*dest = (*dest & 0x0000ffff) | (data & 0xffff0000);
if (~data & 0x00008000)
*dest = (*dest & 0xffff0000) | (data & 0x0000ffff);
}
else if (((mem_mask == 0xffff0000) && (~data & 0x80000000)) ||
((mem_mask == 0x0000ffff) && (~data & 0x00008000)))
COMBINE_DATA(dest);
if ((mem_mask == 0xffff) && (~data & 0x8000))
COMBINE_DATA(&m_vram[offset + (0x40000 / 2) * m_vbuffer]);
}
READ32_MEMBER(dgpix_state::vram_r)
u16 dgpix_state::vram_r(offs_t offset)
{
return m_vram[offset+(0x40000/4)*m_vbuffer];
return m_vram[offset + (0x40000 / 2) * m_vbuffer];
}
WRITE32_MEMBER(dgpix_state::vbuffer_w)
void dgpix_state::vbuffer_w(u32 data)
{
if(m_old_vbuf == 3 && (data & 3) == 2)
if (m_old_vbuf == 3 && (data & 3) == 2)
{
m_vbuffer ^= 1;
}
@ -315,20 +308,20 @@ WRITE32_MEMBER(dgpix_state::vbuffer_w)
m_old_vbuf = data & 3;
}
WRITE32_MEMBER(dgpix_state::coin_w)
void dgpix_state::coin_w(u32 data)
{
machine().bookkeeping().coin_counter_w(0, data & 1);
machine().bookkeeping().coin_counter_w(1, data & 2);
}
READ32_MEMBER(dgpix_state::vblank_r)
u32 dgpix_state::vblank_r()
{
/* burn a bunch of cycles because this is polled frequently during busy loops */
m_maincpu->eat_cycles(100);
return m_vblank->read();
}
void dgpix_state::cpu_map(address_map &map)
void dgpix_state::mem_map(address_map &map)
{
map(0x00000000, 0x007fffff).ram();
map(0x40000000, 0x4003ffff).rw(FUNC(dgpix_state::vram_r), FUNC(dgpix_state::vram_w));
@ -386,28 +379,22 @@ INPUT_PORTS_END
void dgpix_state::video_start()
{
m_vram = std::make_unique<uint32_t[]>(0x40000*2/4);
m_vram = std::make_unique<u16[]>(0x40000);
save_pointer(NAME(m_vram), 0x40000*2/4);
save_pointer(NAME(m_vram), 0x40000);
}
uint32_t dgpix_state::screen_update_dgpix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
u32 dgpix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int y;
for (y = 0; y < 240; y++)
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
int x;
uint32_t *src = &m_vram[(m_vbuffer ? 0 : 0x10000) | (y << 8)];
uint16_t *dest = &bitmap.pix16(y);
int x = cliprect.left();
u16 *src = &m_vram[(m_vbuffer ? 0 : 0x20000) | (y << 9) | x];
u16 *dest = &bitmap.pix16(y, x);
for (x = 0; x < 320; x += 2)
for (; x <= cliprect.right(); x++)
{
dest[0] = (*src >> 16) & 0x7fff;
dest[1] = (*src >> 0) & 0x7fff;
src++;
dest += 2;
*dest++ = *src++ & 0x7fff;
}
}
@ -434,7 +421,7 @@ void dgpix_state::machine_reset()
void dgpix_state::dgpix(machine_config &config)
{
E132XT(config, m_maincpu, 20000000*4); /* 4x internal multiplier */
m_maincpu->set_addrmap(AS_PROGRAM, &dgpix_state::cpu_map);
m_maincpu->set_addrmap(AS_PROGRAM, &dgpix_state::mem_map);
m_maincpu->set_addrmap(AS_IO, &dgpix_state::io_map);
/*
@ -450,7 +437,7 @@ void dgpix_state::dgpix(machine_config &config)
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
screen.set_size(512, 256);
screen.set_visarea(0, 319, 0, 239);
screen.set_screen_update(FUNC(dgpix_state::screen_update_dgpix));
screen.set_screen_update(FUNC(dgpix_state::screen_update));
screen.set_palette("palette");
PALETTE(config, "palette", palette_device::BGR_555);
@ -614,7 +601,7 @@ ROM_END
void dgpix_state::init_elfin()
{
uint8_t *rom = (uint8_t *)memregion("flash")->base() + 0x1c00000;
u8 *rom = (u8 *)m_flash->base() + 0x1c00000;
rom[BYTE4_XOR_BE(0x3a9e94)] = 3;
rom[BYTE4_XOR_BE(0x3a9e95)] = 0;
@ -628,7 +615,7 @@ void dgpix_state::init_elfin()
void dgpix_state::init_jumpjump()
{
uint8_t *rom = (uint8_t *)memregion("flash")->base() + 0x1c00000;
u8 *rom = (u8 *)m_flash->base() + 0x1c00000;
rom[BYTE4_XOR_BE(0x3a829a)] = 3;
rom[BYTE4_XOR_BE(0x3a829b)] = 0;
@ -642,7 +629,7 @@ void dgpix_state::init_jumpjump()
void dgpix_state::init_xfiles()
{
uint8_t *rom = (uint8_t *)memregion("flash")->base() + 0x1c00000;
u8 *rom = (u8 *)m_flash->base() + 0x1c00000;
rom[BYTE4_XOR_BE(0x3a9a2a)] = 3;
rom[BYTE4_XOR_BE(0x3a9a2b)] = 0;
@ -656,7 +643,7 @@ void dgpix_state::init_xfiles()
void dgpix_state::init_xfilesk()
{
uint8_t *rom = (uint8_t *)memregion("flash")->base() + 0x1c00000;
u8 *rom = (u8 *)m_flash->base() + 0x1c00000;
rom[BYTE4_XOR_BE(0x3aa92e)] = 3;
rom[BYTE4_XOR_BE(0x3aa92f)] = 0;
@ -673,7 +660,7 @@ void dgpix_state::init_xfilesk()
void dgpix_state::init_kdynastg()
{
uint8_t *rom = (uint8_t *)memregion("flash")->base() + 0x1c00000;
u8 *rom = (u8 *)m_flash->base() + 0x1c00000;
rom[BYTE4_XOR_BE(0x3aaa10)] = 3; // 129f0 - nopped call
rom[BYTE4_XOR_BE(0x3aaa11)] = 0;