mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
jangou_blitter.cpp: rewritten blitter setters [Angelo Salese]
This commit is contained in:
parent
98bc547349
commit
b7d299ef39
@ -40,6 +40,27 @@ jangou_blitter_device::jangou_blitter_device(const machine_config &mconfig, cons
|
||||
}
|
||||
|
||||
|
||||
DEVICE_ADDRESS_MAP_START( blit_v1_regs, 8, jangou_blitter_device )
|
||||
AM_RANGE(0x00, 0x00) AM_WRITE(src_lo_address_w)
|
||||
AM_RANGE(0x01, 0x01) AM_WRITE(src_md_address_w)
|
||||
AM_RANGE(0x02, 0x02) AM_WRITE(x_w)
|
||||
AM_RANGE(0x03, 0x03) AM_WRITE(y_w)
|
||||
AM_RANGE(0x04, 0x04) AM_WRITE(width_w)
|
||||
AM_RANGE(0x05, 0x05) AM_WRITE(height_and_trigger_w)
|
||||
AM_RANGE(0x06, 0x06) AM_WRITE(src_hi_address_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
// Sexy Gal and variants (v2) swaps around upper src address
|
||||
DEVICE_ADDRESS_MAP_START( blit_v2_regs, 8, jangou_blitter_device )
|
||||
AM_RANGE(0x00, 0x00) AM_WRITE(src_lo_address_w)
|
||||
AM_RANGE(0x01, 0x01) AM_WRITE(src_md_address_w)
|
||||
AM_RANGE(0x02, 0x02) AM_WRITE(src_hi_address_w)
|
||||
AM_RANGE(0x03, 0x03) AM_WRITE(x_w)
|
||||
AM_RANGE(0x04, 0x04) AM_WRITE(y_w)
|
||||
AM_RANGE(0x05, 0x05) AM_WRITE(width_w)
|
||||
AM_RANGE(0x06, 0x06) AM_WRITE(height_and_trigger_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -53,7 +74,11 @@ void jangou_blitter_device::device_start()
|
||||
m_gfxrommask = devregion->bytes()-1;
|
||||
|
||||
save_item(NAME(m_pen_data));
|
||||
save_item(NAME(m_blit_data));
|
||||
save_item(NAME(m_x));
|
||||
save_item(NAME(m_y));
|
||||
save_item(NAME(m_width));
|
||||
save_item(NAME(m_height));
|
||||
save_item(NAME(m_src_addr));
|
||||
save_item(NAME(m_blit_buffer));
|
||||
}
|
||||
|
||||
@ -64,7 +89,6 @@ void jangou_blitter_device::device_start()
|
||||
|
||||
void jangou_blitter_device::device_reset()
|
||||
{
|
||||
memset(m_blit_data, 0, ARRAY_LENGTH(m_blit_data));
|
||||
memset(m_pen_data, 0, ARRAY_LENGTH(m_pen_data));
|
||||
m_bltflip = false;
|
||||
}
|
||||
@ -96,83 +120,59 @@ void jangou_blitter_device::plot_gfx_pixel( uint8_t pix, int x, int y )
|
||||
m_blit_buffer[(y * 256) + (x >> 1)] = (m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( jangou_blitter_device::process_w )
|
||||
void jangou_blitter_device::trigger_write(void)
|
||||
{
|
||||
int src, x, y, h, w, flipx;
|
||||
m_blit_data[offset] = data;
|
||||
int count = 0;
|
||||
int xcount, ycount;
|
||||
|
||||
if (offset == 5)
|
||||
w = (m_width & 0xff) + 1;
|
||||
h = (m_height & 0xff) + 1;
|
||||
src = m_src_addr & m_gfxrommask;
|
||||
if(m_src_addr & ~m_gfxrommask)
|
||||
logerror("%s: Warning blit src address = %08x above ROM mask %08x\n",this->tag(),m_src_addr,m_gfxrommask);
|
||||
x = (m_x & 0xff);
|
||||
y = (m_y & 0xff);
|
||||
|
||||
// lowest bit of src controls flipping / draw direction?
|
||||
flipx = (m_src_addr & 1);
|
||||
|
||||
if (!flipx)
|
||||
src += (w * h) - 1;
|
||||
else
|
||||
src -= (w * h) - 1;
|
||||
|
||||
for (ycount = 0; ycount < h; ycount++)
|
||||
{
|
||||
int count = 0;
|
||||
int xcount, ycount;
|
||||
|
||||
w = (m_blit_data[4] & 0xff) + 1;
|
||||
h = (m_blit_data[5] & 0xff) + 1;
|
||||
src = ((m_blit_data[1] << 8)|(m_blit_data[0] << 0));
|
||||
src |= (m_blit_data[6] & 3) << 16;
|
||||
x = (m_blit_data[2] & 0xff);
|
||||
y = (m_blit_data[3] & 0xff);
|
||||
|
||||
#if 0
|
||||
if(m_bltflip == true)
|
||||
for(xcount = 0; xcount < w; xcount++)
|
||||
{
|
||||
printf("%02x %02x %02x %02x %02x %02x %02x\n", m_blit_data[0], m_blit_data[1], m_blit_data[2],m_blit_data[3], m_blit_data[4], m_blit_data[5],m_blit_data[6]);
|
||||
printf("=>");
|
||||
for(int i=0;i<0x10;i++)
|
||||
printf("%02x ",m_pen_data[i]);
|
||||
printf("\n");
|
||||
int drawx = (x + xcount) & 0xff;
|
||||
int drawy = (y + ycount) & 0xff;
|
||||
uint8_t dat = gfx_nibble(src + count);
|
||||
uint8_t cur_pen = m_pen_data[dat & 0x0f];
|
||||
//dat = cur_pen_lo | (cur_pen_hi << 4);
|
||||
|
||||
if ((cur_pen & 0xff) != 0)
|
||||
plot_gfx_pixel(cur_pen, drawx, drawy);
|
||||
|
||||
if (!flipx)
|
||||
count--;
|
||||
else
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
// lowest bit of src controls flipping / draw direction?
|
||||
flipx = (m_blit_data[0] & 1);
|
||||
|
||||
if (!flipx)
|
||||
src += (w * h) - 1;
|
||||
else
|
||||
src -= (w * h) - 1;
|
||||
|
||||
|
||||
for (ycount = 0; ycount < h; ycount++)
|
||||
{
|
||||
for(xcount = 0; xcount < w; xcount++)
|
||||
{
|
||||
int drawx = (x + xcount) & 0xff;
|
||||
int drawy = (y + ycount) & 0xff;
|
||||
uint8_t dat = gfx_nibble(src + count);
|
||||
uint8_t cur_pen = m_pen_data[dat & 0x0f];
|
||||
|
||||
//dat = cur_pen_lo | (cur_pen_hi << 4);
|
||||
|
||||
if ((cur_pen & 0xff) != 0)
|
||||
plot_gfx_pixel(cur_pen, drawx, drawy);
|
||||
|
||||
if (!flipx)
|
||||
count--;
|
||||
else
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//uint32_t new_src = src + count;
|
||||
|
||||
// update source and height after blitter operation
|
||||
// TODO: Jangou doesn't agree with this, later HW?
|
||||
#if 0
|
||||
m_blit_data[0] = new_src & 0xfe;
|
||||
m_blit_data[1] = new_src >> 8;
|
||||
m_blit_data[5] = 0;
|
||||
m_blit_data[6] = new_src >> 16;
|
||||
#endif
|
||||
m_bltflip = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Sexy Gal swaps around upper src address
|
||||
WRITE8_MEMBER( jangou_blitter_device::alt_process_w )
|
||||
{
|
||||
const uint8_t translate_addr[7] = { 0, 1, 6, 2, 3, 4, 5 };
|
||||
//uint32_t new_src = src + count;
|
||||
|
||||
process_w(space,translate_addr[offset],data);
|
||||
// update source and height after blitter operation
|
||||
// TODO: Jangou doesn't agree with this, later HW?
|
||||
#if 0
|
||||
m_blit_data[0] = new_src & 0xfe;
|
||||
m_blit_data[1] = new_src >> 8;
|
||||
m_blit_data[5] = 0;
|
||||
m_blit_data[6] = new_src >> 16;
|
||||
#endif
|
||||
m_bltflip = false;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( jangou_blitter_device::vregs_w )
|
||||
@ -192,3 +192,33 @@ READ_LINE_MEMBER( jangou_blitter_device::status_r )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// data accessors
|
||||
|
||||
WRITE8_MEMBER( jangou_blitter_device::x_w ) { m_x = data; }
|
||||
WRITE8_MEMBER( jangou_blitter_device::y_w ) { m_y = data; }
|
||||
WRITE8_MEMBER( jangou_blitter_device::src_lo_address_w )
|
||||
{
|
||||
m_src_addr &= ~0xff;
|
||||
m_src_addr |= data & 0xff;
|
||||
}
|
||||
WRITE8_MEMBER( jangou_blitter_device::src_md_address_w )
|
||||
{
|
||||
m_src_addr &= ~0xff00;
|
||||
m_src_addr |= data << 8;
|
||||
}
|
||||
WRITE8_MEMBER( jangou_blitter_device::src_hi_address_w )
|
||||
{
|
||||
m_src_addr &= ~0xff0000;
|
||||
m_src_addr |= data << 16;
|
||||
}
|
||||
WRITE8_MEMBER( jangou_blitter_device::width_w )
|
||||
{
|
||||
m_width = data;
|
||||
}
|
||||
WRITE8_MEMBER( jangou_blitter_device::height_and_trigger_w )
|
||||
{
|
||||
m_height = data;
|
||||
trigger_write();
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,22 @@ public:
|
||||
jangou_blitter_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// I/O operations
|
||||
DECLARE_WRITE8_MEMBER( process_w );
|
||||
DECLARE_WRITE8_MEMBER( alt_process_w );
|
||||
DECLARE_ADDRESS_MAP(blit_v1_regs, 8);
|
||||
DECLARE_ADDRESS_MAP(blit_v2_regs, 8);
|
||||
|
||||
DECLARE_WRITE8_MEMBER( vregs_w );
|
||||
DECLARE_WRITE8_MEMBER( bltflip_w );
|
||||
DECLARE_READ_LINE_MEMBER( status_r );
|
||||
|
||||
// blitter write accessors
|
||||
DECLARE_WRITE8_MEMBER( x_w );
|
||||
DECLARE_WRITE8_MEMBER( y_w );
|
||||
DECLARE_WRITE8_MEMBER( height_and_trigger_w );
|
||||
DECLARE_WRITE8_MEMBER( width_w );
|
||||
DECLARE_WRITE8_MEMBER( src_lo_address_w );
|
||||
DECLARE_WRITE8_MEMBER( src_md_address_w );
|
||||
DECLARE_WRITE8_MEMBER( src_hi_address_w );
|
||||
|
||||
const uint8_t &blit_buffer(unsigned y, unsigned x) const { return m_blit_buffer[(256 * y) + x]; }
|
||||
|
||||
protected:
|
||||
@ -46,8 +56,11 @@ private:
|
||||
|
||||
void plot_gfx_pixel( uint8_t pix, int x, int y );
|
||||
uint8_t gfx_nibble( uint32_t niboffset );
|
||||
void trigger_write(void);
|
||||
uint8_t m_pen_data[0x10];
|
||||
uint8_t m_blit_data[7];
|
||||
uint8_t m_x,m_y,m_width,m_height;
|
||||
uint32_t m_src_addr;
|
||||
//uint8_t m_blit_data[7];
|
||||
uint8_t *m_gfxrom;
|
||||
uint32_t m_gfxrommask;
|
||||
bool m_bltflip;
|
||||
|
@ -333,7 +333,7 @@ static ADDRESS_MAP_START( cpu0_io, AS_IO, 8, jangou_state )
|
||||
AM_RANGE(0x02,0x03) AM_DEVWRITE("aysnd", ay8910_device, data_address_w)
|
||||
AM_RANGE(0x10,0x10) AM_READ_PORT("DSW") AM_WRITE(output_w) //dsw + blitter busy flag
|
||||
AM_RANGE(0x11,0x11) AM_WRITE(mux_w)
|
||||
AM_RANGE(0x12,0x17) AM_DEVWRITE("blitter",jangou_blitter_device, process_w)
|
||||
AM_RANGE(0x12,0x17) AM_DEVICE("blitter",jangou_blitter_device, blit_v1_regs)
|
||||
AM_RANGE(0x20,0x2f) AM_DEVWRITE("blitter",jangou_blitter_device, vregs_w)
|
||||
AM_RANGE(0x30,0x30) AM_WRITENOP //? polls 0x03 continuously
|
||||
AM_RANGE(0x31,0x31) AM_WRITE(sound_latch_w)
|
||||
@ -404,7 +404,7 @@ static ADDRESS_MAP_START( cntrygrl_cpu0_io, AS_IO, 8, jangou_state )
|
||||
AM_RANGE(0x10,0x10) AM_READ_PORT("DSW") //dsw + blitter busy flag
|
||||
AM_RANGE(0x10,0x10) AM_WRITE(output_w)
|
||||
AM_RANGE(0x11,0x11) AM_WRITE(mux_w)
|
||||
AM_RANGE(0x12,0x17) AM_DEVWRITE("blitter",jangou_blitter_device, process_w)
|
||||
AM_RANGE(0x12,0x17) AM_DEVICE("blitter",jangou_blitter_device, blit_v1_regs)
|
||||
AM_RANGE(0x20,0x2f) AM_DEVWRITE("blitter",jangou_blitter_device, vregs_w)
|
||||
AM_RANGE(0x30,0x30) AM_WRITENOP //? polls 0x03 continuously
|
||||
// AM_RANGE(0x31,0x31) AM_WRITE(sound_latch_w)
|
||||
@ -429,7 +429,7 @@ static ADDRESS_MAP_START( roylcrdn_cpu0_io, AS_IO, 8, jangou_state )
|
||||
AM_RANGE(0x10,0x10) AM_WRITENOP /* Writes continuosly 0's in attract mode, and 1's in game */
|
||||
AM_RANGE(0x11,0x11) AM_WRITE(mux_w)
|
||||
AM_RANGE(0x13,0x13) AM_READNOP /* Often reads bit7 with unknown purposes */
|
||||
AM_RANGE(0x12,0x17) AM_DEVWRITE("blitter",jangou_blitter_device, process_w)
|
||||
AM_RANGE(0x12,0x17) AM_DEVICE("blitter",jangou_blitter_device, blit_v1_regs)
|
||||
AM_RANGE(0x20,0x2f) AM_DEVWRITE("blitter",jangou_blitter_device, vregs_w)
|
||||
AM_RANGE(0x30,0x30) AM_WRITENOP /* Seems to write 0x10 on each sound event */
|
||||
ADDRESS_MAP_END
|
||||
|
@ -368,8 +368,7 @@ ADDRESS_MAP_END
|
||||
|
||||
static ADDRESS_MAP_START( sexygal_nsc_map, AS_PROGRAM, 8, nightgal_state )
|
||||
AM_IMPORT_FROM( common_nsc_map )
|
||||
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVWRITE("blitter", jangou_blitter_device, alt_process_w)
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVICE("blitter",jangou_blitter_device, blit_v2_regs)
|
||||
AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x2c00) AM_READWRITE(royalqn_comm_r, royalqn_comm_w) AM_SHARE("comms_ram")
|
||||
AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x2000) AM_ROM AM_REGION("subrom", 0)
|
||||
ADDRESS_MAP_END
|
||||
@ -377,7 +376,7 @@ ADDRESS_MAP_END
|
||||
static ADDRESS_MAP_START( sgaltrop_nsc_map, AS_PROGRAM, 8, nightgal_state )
|
||||
AM_IMPORT_FROM( common_nsc_map )
|
||||
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVWRITE("blitter", jangou_blitter_device, alt_process_w)
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVICE("blitter",jangou_blitter_device, blit_v2_regs)
|
||||
AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x2c00) AM_READWRITE(royalqn_comm_r, royalqn_comm_w) AM_SHARE("comms_ram")
|
||||
AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("subrom", 0)
|
||||
ADDRESS_MAP_END
|
||||
@ -411,7 +410,7 @@ ADDRESS_MAP_END
|
||||
static ADDRESS_MAP_START( royalqn_nsc_map, AS_PROGRAM, 8, nightgal_state )
|
||||
AM_IMPORT_FROM( common_nsc_map )
|
||||
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVWRITE("blitter", jangou_blitter_device, process_w)
|
||||
AM_RANGE(0x0080, 0x0086) AM_DEVICE("blitter",jangou_blitter_device, blit_v1_regs)
|
||||
AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x2c00) AM_READWRITE(royalqn_comm_r, royalqn_comm_w)
|
||||
AM_RANGE(0x4000, 0x4000) AM_NOP
|
||||
AM_RANGE(0x8000, 0x8000) AM_NOP //open bus or protection check
|
||||
|
Loading…
Reference in New Issue
Block a user