Basic KRAM hook
This commit is contained in:
parent
9b6503ac95
commit
e8f1af1c00
@ -16,6 +16,44 @@
|
||||
// device type definition
|
||||
const device_type huc6272 = &device_creator<huc6272_device>;
|
||||
|
||||
static ADDRESS_MAP_START( huc6272_vram, AS_0, 16, huc6272_device )
|
||||
AM_RANGE(0x000000, 0x0fffff) AM_RAM
|
||||
AM_RANGE(0x100000, 0x1fffff) AM_RAM
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// memory_space_config - return a description of
|
||||
// any address spaces owned by this device
|
||||
//-------------------------------------------------
|
||||
|
||||
const address_space_config *huc6272_device::memory_space_config(address_spacenum spacenum) const
|
||||
{
|
||||
return (spacenum == AS_0) ? &m_space_config : NULL;
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// INLINE HELPERS
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// read_dword - read a dword at the given address
|
||||
//-------------------------------------------------
|
||||
|
||||
inline UINT32 huc6272_device::read_word(offs_t address)
|
||||
{
|
||||
return space()->read_word(address << 1);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// write_dword - write a dword at the given address
|
||||
//-------------------------------------------------
|
||||
|
||||
inline void huc6272_device::write_word(offs_t address, UINT32 data)
|
||||
{
|
||||
space()->write_word(address << 1, data);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
@ -26,7 +64,9 @@ const device_type huc6272 = &device_creator<huc6272_device>;
|
||||
//-------------------------------------------------
|
||||
|
||||
huc6272_device::huc6272_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, huc6272, "huc6272", tag, owner, clock)
|
||||
: device_t(mconfig, huc6272, "huc6272", tag, owner, clock),
|
||||
device_memory_interface(mconfig, *this),
|
||||
m_space_config("videoram", ENDIANNESS_LITTLE, 16, 32, 0, NULL, *ADDRESS_MAP_NAME(huc6272_vram))
|
||||
{
|
||||
|
||||
}
|
||||
@ -65,11 +105,67 @@ void huc6272_device::device_reset()
|
||||
// READ/WRITE HANDLERS
|
||||
//**************************************************************************
|
||||
|
||||
READ16_MEMBER( huc6272_device::read )
|
||||
READ32_MEMBER( huc6272_device::read )
|
||||
{
|
||||
return 0;
|
||||
UINT32 res = 0;
|
||||
|
||||
if((offset & 1) == 0)
|
||||
res = m_register & 0x7f;
|
||||
else
|
||||
{
|
||||
switch(m_register)
|
||||
{
|
||||
/*
|
||||
x--- ---- ---- ---- ----
|
||||
*/
|
||||
case 0x0c: // KRAM load address
|
||||
res = (m_kram_addr_r & 0x3ffff) | ((m_kram_inc_r & 0x1ff) << 18) | ((m_kram_page_r & 1) << 31);
|
||||
break;
|
||||
|
||||
case 0x0d: // KRAM write address
|
||||
res = (m_kram_addr_w & 0x3ffff) | ((m_kram_inc_w & 0x1ff) << 18) | ((m_kram_page_w & 1) << 31);
|
||||
break;
|
||||
|
||||
case 0x0e:
|
||||
res = read_word((m_kram_addr_r)|(m_kram_page_r<<18));
|
||||
m_kram_addr_r += (m_kram_inc_r & 0x100) ? ((m_kram_inc_r & 0xff) - 0x100) : (m_kram_inc_r & 0xff);
|
||||
break;
|
||||
//default: printf("%04x\n",m_register);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER( huc6272_device::write )
|
||||
WRITE32_MEMBER( huc6272_device::write )
|
||||
{
|
||||
if((offset & 1) == 0)
|
||||
m_register = data & 0x7f;
|
||||
else
|
||||
{
|
||||
switch(m_register)
|
||||
{
|
||||
/*
|
||||
---- ---- ---- ---- ----
|
||||
*/
|
||||
case 0x0c: // KRAM load address
|
||||
m_kram_addr_r = (data & 0x0003ffff);
|
||||
m_kram_inc_r = (data & 0x07fc0000) >> 18;
|
||||
m_kram_page_r = (data & 0x80000000) >> 31;
|
||||
break;
|
||||
|
||||
case 0x0d: // KRAM write address
|
||||
m_kram_addr_w = (data & 0x0003ffff);
|
||||
m_kram_inc_w = (data & 0x07fc0000) >> 18;
|
||||
m_kram_page_w = (data & 0x80000000) >> 31;
|
||||
break;
|
||||
|
||||
case 0x0e: // KRAM write VRAM
|
||||
write_word((m_kram_addr_w)|(m_kram_page_w<<18),data & 0xffff); /* TODO: there are some 32-bits accesses during BIOS? */
|
||||
m_kram_addr_w += (m_kram_inc_w & 0x100) ? ((m_kram_inc_w & 0xff) - 0x100) : (m_kram_inc_w & 0xff);
|
||||
break;
|
||||
|
||||
//default: printf("%04x %04x\n",m_register,data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ Template for skeleton device
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_HUC6272_ADD(_tag,_freq) \
|
||||
MCFG_DEVICE_ADD(_tag, huc6272, _freq) \
|
||||
MCFG_DEVICE_ADD(_tag, huc6272, _freq)
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -25,21 +25,34 @@ Template for skeleton device
|
||||
|
||||
// ======================> huc6272_device
|
||||
|
||||
class huc6272_device : public device_t
|
||||
class huc6272_device : public device_t,
|
||||
public device_memory_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
huc6272_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// I/O operations
|
||||
DECLARE_WRITE16_MEMBER( write );
|
||||
DECLARE_READ16_MEMBER( read );
|
||||
DECLARE_WRITE32_MEMBER( write );
|
||||
DECLARE_READ32_MEMBER( read );
|
||||
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_validity_check(validity_checker &valid) const;
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
|
||||
|
||||
private:
|
||||
inline UINT32 read_word(offs_t address);
|
||||
inline void write_word(offs_t address, UINT32 data);
|
||||
UINT8 m_register;
|
||||
UINT32 m_kram_addr_r, m_kram_addr_w;
|
||||
UINT16 m_kram_inc_r,m_kram_inc_w;
|
||||
UINT8 m_kram_page_r,m_kram_page_w;
|
||||
|
||||
const address_space_config m_space_config;
|
||||
};
|
||||
|
||||
|
||||
|
@ -166,7 +166,7 @@ static ADDRESS_MAP_START( pcfx_io, AS_IO, 32, pcfx_state )
|
||||
AM_RANGE( 0x00000300, 0x000003FF ) AM_DEVREADWRITE16( "huc6261", huc6261_device, read, write, 0xffff ) /* HuC6261 */
|
||||
AM_RANGE( 0x00000400, 0x000004FF ) AM_DEVREADWRITE8( "huc6270_a", huc6270_device, read, write, 0xffff ) /* HuC6270-A */
|
||||
AM_RANGE( 0x00000500, 0x000005FF ) AM_DEVREADWRITE8( "huc6270_b", huc6270_device, read, write, 0xffff ) /* HuC6270-B */
|
||||
AM_RANGE( 0x00000600, 0x000006FF ) AM_DEVREADWRITE16( "huc6272", huc6272_device, read, write, 0xffff ) /* HuC6272 */
|
||||
AM_RANGE( 0x00000600, 0x000006FF ) AM_DEVREADWRITE( "huc6272", huc6272_device, read, write ) /* HuC6272 */
|
||||
AM_RANGE( 0x00000C80, 0x00000C83 ) AM_NOP
|
||||
AM_RANGE( 0x00000E00, 0x00000EFF ) AM_READWRITE16( irq_read, irq_write, 0xffff ) /* Interrupt controller */
|
||||
AM_RANGE( 0x00000F00, 0x00000FFF ) AM_NOP
|
||||
|
Loading…
Reference in New Issue
Block a user