small cleanup

This commit is contained in:
Michaël Banaan Ananas 2014-07-30 18:50:24 +00:00
parent 6875012f32
commit 8df0ec79a4
3 changed files with 46 additions and 150 deletions

View File

@ -33,7 +33,6 @@ epic12_device::epic12_device(const machine_config &mconfig, const char *tag, dev
epic12_device_gfx_scroll_1_y_shadowcopy = 0;
epic12_device_ram16_copy = 0;
epic12_device_blit_delay = 0;
}
TIMER_CALLBACK_MEMBER( epic12_device::epic12_device_blitter_delay_callback )
@ -41,48 +40,18 @@ TIMER_CALLBACK_MEMBER( epic12_device::epic12_device_blitter_delay_callback )
blitter_busy = 0;
}
// static
void epic12_device::set_rambase(device_t &device, UINT16* rambase)
{
epic12_device &dev = downcast<epic12_device &>(device);
dev.epic12_device_ram16 = rambase;
}
void epic12_device::set_delay_scale(device_t &device, int delay_scale)
{
epic12_device &dev = downcast<epic12_device &>(device);
dev.m_delay_scale = delay_scale;
}
void epic12_device::set_is_unsafe(device_t &device, int is_unsafe)
{
epic12_device &dev = downcast<epic12_device &>(device);
dev.m_is_unsafe = is_unsafe;
}
void epic12_device::set_cpu_device(device_t &device, cpu_device* maincpu)
{
epic12_device &dev = downcast<epic12_device &>(device);
dev.m_maincpu = maincpu;
}
void epic12_device::device_start()
{
epic12_device_gfx_size = 0x2000 * 0x1000;
epic12_device_bitmaps = auto_bitmap_rgb32_alloc(machine(), 0x2000, 0x1000);
epic12_device_clip = epic12_device_bitmaps->cliprect();
epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
epic12_device_ram16_copy = auto_alloc_array(machine(), UINT16, m_main_ramsize/2);
epic12_device_blitter_delay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(epic12_device::epic12_device_blitter_delay_callback),this));
epic12_device_blitter_delay_timer->adjust(attotime::never);
}
void epic12_device::device_reset()
@ -326,7 +295,7 @@ epic12_device_blitfunction epic12_device_f1_ti0_tr0_blit_funcs[] =
inline void epic12_device::epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr, int cliptype)
inline void epic12_device::epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr)
{
COPY_NEXT_WORD(space, addr);
COPY_NEXT_WORD(space, addr);
@ -567,12 +536,7 @@ inline void epic12_device::epic12_device_gfx_draw(offs_t *addr)
void epic12_device::epic12_device_gfx_create_shadow_copy(address_space &space)
{
offs_t addr = epic12_device_gfx_addr & 0x1fffffff;
UINT16 cliptype = 0;
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
while (1)
{
@ -585,25 +549,10 @@ void epic12_device::epic12_device_gfx_create_shadow_copy(address_space &space)
return;
case 0xc000:
data = COPY_NEXT_WORD(space, &addr);
cliptype = data ? 1 : 0;
if (cliptype)
{
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
}
if (COPY_NEXT_WORD(space, &addr)) // cliptype
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
else
{
epic12_device_clip.min_x = 0;
epic12_device_clip.min_y = 0;
epic12_device_clip.max_x = 0x2000-1;
epic12_device_clip.max_y = 0x1000-1;
}
epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
break;
case 0x2000:
@ -613,7 +562,7 @@ void epic12_device::epic12_device_gfx_create_shadow_copy(address_space &space)
case 0x1000:
addr -= 2;
epic12_device_gfx_draw_shadow_copy(space, &addr, cliptype);
epic12_device_gfx_draw_shadow_copy(space, &addr);
break;
default:
@ -626,17 +575,11 @@ void epic12_device::epic12_device_gfx_create_shadow_copy(address_space &space)
void epic12_device::epic12_device_gfx_exec(void)
{
UINT16 cliptype = 0;
offs_t addr = epic12_device_gfx_addr_shadowcopy & 0x1fffffff;
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
// logerror("GFX EXEC: %08X\n", addr);
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
while (1)
{
UINT16 data = READ_NEXT_WORD(&addr);
@ -648,23 +591,10 @@ void epic12_device::epic12_device_gfx_exec(void)
return;
case 0xc000:
data = READ_NEXT_WORD(&addr);
cliptype = data ? 1 : 0;
if (cliptype)
{
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
}
if (READ_NEXT_WORD(&addr)) // cliptype
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
else
{
epic12_device_clip.min_x = 0;
epic12_device_clip.min_y = 0;
epic12_device_clip.max_x = 0x2000-1;
epic12_device_clip.max_y = 0x1000-1;
}
epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
break;
case 0x2000:
@ -687,17 +617,11 @@ void epic12_device::epic12_device_gfx_exec(void)
void epic12_device::epic12_device_gfx_exec_unsafe(void)
{
UINT16 cliptype = 0;
offs_t addr = epic12_device_gfx_addr & 0x1fffffff;
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
// logerror("GFX EXEC: %08X\n", addr);
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
while (1)
{
UINT16 data = READ_NEXT_WORD(&addr);
@ -709,23 +633,10 @@ void epic12_device::epic12_device_gfx_exec_unsafe(void)
return;
case 0xc000:
data = READ_NEXT_WORD(&addr);
cliptype = data ? 1 : 0;
if (cliptype)
{
epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x;
epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y;
epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
}
if (READ_NEXT_WORD(&addr)) // cliptype
epic12_device_clip.set(epic12_device_gfx_scroll_1_x_shadowcopy, epic12_device_clip.min_x + 320-1, epic12_device_gfx_scroll_1_y_shadowcopy, epic12_device_clip.min_y + 240-1);
else
{
epic12_device_clip.min_x = 0;
epic12_device_clip.min_y = 0;
epic12_device_clip.max_x = 0x2000-1;
epic12_device_clip.max_y = 0x1000-1;
}
epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
break;
case 0x2000:
@ -1025,9 +936,6 @@ void epic12_device::install_handlers(int addr1, int addr2)
}
space.install_readwrite_handler(addr1, addr2, read , write, U64(0xffffffffffffffff));
}
READ64_MEMBER( epic12_device::epic12_device_fpga_r )

View File

@ -1,3 +1,4 @@
/* emulation of Altera Cyclone EPIC12 FPGA programmed as a blitter */
#define MCFG_EPIC12_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, EPIC12, 0)
@ -50,7 +51,7 @@ class epic12_device : public device_t,
public:
epic12_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
static void set_rambase(device_t &device, UINT16* rambase);
void set_rambase(UINT16* rambase) { epic12_device_ram16 = rambase; }
inline UINT16 READ_NEXT_WORD(offs_t *addr);
@ -67,7 +68,7 @@ public:
DECLARE_READ64_MEMBER( epic12_device_fpga_r );
DECLARE_WRITE64_MEMBER( epic12_device_fpga_w );
void draw_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect );
void draw_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect);
UINT16* epic12_device_ram16;
UINT32 epic12_device_gfx_addr;
@ -94,7 +95,7 @@ public:
inline void epic12_device_gfx_upload_shadow_copy(address_space &space, offs_t *addr);
inline void epic12_device_gfx_create_shadow_copy(address_space &space);
inline UINT16 COPY_NEXT_WORD(address_space &space, offs_t *addr);
inline void epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr, int cliptype);
inline void epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr);
inline void epic12_device_gfx_upload(offs_t *addr);
inline void epic12_device_gfx_draw(offs_t *addr);
void epic12_device_gfx_exec(void);
@ -114,9 +115,9 @@ public:
int m_delay_scale;
cpu_device* m_maincpu;
static void set_delay_scale(device_t &device, int delay_scale);
static void set_is_unsafe(device_t &device, int is_unsafe);
static void set_cpu_device(device_t &device, cpu_device* maincpu);
void set_delay_scale(int delay_scale) { m_delay_scale = delay_scale; }
void set_is_unsafe(int is_unsafe) { m_is_unsafe = is_unsafe; }
void set_cpu_device(cpu_device* maincpu) { m_maincpu = maincpu; }
void install_handlers(int addr1, int addr2);
@ -831,8 +832,6 @@ protected:
virtual void device_start();
virtual void device_reset();
osd_work_queue * queue; /* work queue */
osd_work_item * blitter_request;
@ -841,14 +840,8 @@ protected:
int blitter_busy;
TIMER_CALLBACK_MEMBER( epic12_device_blitter_delay_callback );
private:
};
extern const device_type EPIC12;

View File

@ -162,7 +162,7 @@ Speedups
- Need SH3 recompiler?
Blitter Timing
- Correct slowdown emulation and flags (depends on blit mode, and speed of RAM) - could do with the recompiler or alt idle skips on the busy flag wait looops
- Correct slowdown emulation and flags (depends on blit mode, and speed of RAM) - could do with the recompiler or alt idle skips on the busy flag wait loops
- End of Blit IRQ? (one game has a valid irq routine that looks like it was used for profiling, but nothing depends on it)
*/
@ -187,7 +187,7 @@ public:
m_blitter(*this, "blitter"),
m_serflash(*this, "game"),
m_eeprom(*this, "eeprom"),
cv1k_ram(*this, "mainram"),
m_ram(*this, "mainram"),
m_blitrate(*this, "BLITRATE"),
m_eepromout(*this, "EEPROMOUT") { }
@ -196,7 +196,7 @@ public:
required_device<serflash_device> m_serflash;
required_device<rtc9701_device> m_eeprom;
required_shared_ptr<UINT64> cv1k_ram;
required_shared_ptr<UINT64> m_ram;
DECLARE_READ8_MEMBER(cv1k_flash_io_r);
DECLARE_WRITE8_MEMBER(cv1k_flash_io_w);
@ -204,10 +204,9 @@ public:
DECLARE_WRITE8_MEMBER(serial_rtc_eeprom_w);
DECLARE_READ64_MEMBER(cv1k_flash_port_e_r);
INTERRUPT_GEN_MEMBER(cv1k_interrupt);
UINT32 screen_update_cv1k(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_MACHINE_RESET( cv1k );
virtual void machine_reset();
/* game specific */
DECLARE_READ64_MEMBER(mushisam_speedup_r);
@ -231,7 +230,7 @@ public:
UINT32 cv1k_state::screen_update_cv1k(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
epic12_device::set_delay_scale(m_blitter, m_blitrate->read());
m_blitter->set_delay_scale(m_blitrate->read());
m_blitter->draw_screen(bitmap,cliprect);
return 0;
@ -242,7 +241,7 @@ UINT32 cv1k_state::screen_update_cv1k(screen_device &screen, bitmap_rgb32 &bitma
READ64_MEMBER( cv1k_state::cv1k_flash_port_e_r )
{
return ((m_serflash->flash_ready_r(space, offset) ? 0x20 : 0x00)) | 0xdf;
return ((m_serflash->flash_ready_r(space, offset) ? 0x20 : 0x00)) | 0xdf;
}
@ -298,7 +297,7 @@ READ8_MEMBER( cv1k_state::serial_rtc_eeprom_r )
{
switch (offset)
{
case 1:
case 0x01:
return 0xfe | m_eeprom->read_bit();
default:
@ -315,10 +314,11 @@ WRITE8_MEMBER( cv1k_state::serial_rtc_eeprom_w )
break;
case 0x03:
m_serflash->flash_enab_w(space,offset,data);
return;
break;
default:
logerror("unknown serial_rtc_eeprom_w access offset %02x data %02x\n",offset, data);
break;
logerror("unknown serial_rtc_eeprom_w access offset %02x data %02x\n", offset, data);
break;
}
}
@ -409,21 +409,17 @@ static INPUT_PORTS_START( cv1k )
INPUT_PORTS_END
INTERRUPT_GEN_MEMBER(cv1k_state::cv1k_interrupt)
void cv1k_state::machine_reset()
{
m_maincpu->set_input_line(2, HOLD_LINE);
}
MACHINE_RESET_MEMBER( cv1k_state, cv1k )
{
epic12_device::set_rambase (m_blitter, reinterpret_cast<UINT16 *>(cv1k_ram.target()));
epic12_device::set_cpu_device (m_blitter, m_maincpu );
epic12_device::set_is_unsafe(m_blitter, machine().root_device().ioport(":BLITCFG")->read());
m_blitter->set_rambase (reinterpret_cast<UINT16 *>(m_ram.target()));
m_blitter->set_cpu_device (m_maincpu);
m_blitter->set_is_unsafe(machine().root_device().ioport(":BLITCFG")->read());
m_blitter->install_handlers( 0x18000000, 0x18000057 );
m_blitter->reset();
}
static MACHINE_CONFIG_START( cv1k, cv1k_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", SH3BE, CPU_CLOCK)
MCFG_SH4_MD0(0) // none of this is verified
@ -438,7 +434,7 @@ static MACHINE_CONFIG_START( cv1k, cv1k_state )
MCFG_SH4_CLOCK(CPU_CLOCK)
MCFG_CPU_PROGRAM_MAP(cv1k_map)
MCFG_CPU_IO_MAP(cv1k_port)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", cv1k_state, cv1k_interrupt)
MCFG_CPU_VBLANK_INT_DRIVER("screen", cv1k_state, irq2_line_hold)
MCFG_RTC9701_ADD("eeprom")
MCFG_SERFLASH_ADD("game")
@ -451,11 +447,8 @@ static MACHINE_CONFIG_START( cv1k, cv1k_state )
MCFG_SCREEN_VISIBLE_AREA(0, 0x140-1, 0, 0xf0-1)
MCFG_SCREEN_UPDATE_DRIVER(cv1k_state, screen_update_cv1k)
MCFG_PALETTE_ADD("palette", 0x10000)
MCFG_MACHINE_RESET_OVERRIDE(cv1k_state, cv1k)
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_YMZ770_ADD("ymz770", XTAL_16_384MHz)
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
@ -466,6 +459,8 @@ static MACHINE_CONFIG_START( cv1k, cv1k_state )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( cv1k_d, cv1k )
/* basic machine hardware */
MCFG_DEVICE_REMOVE("maincpu")
MCFG_CPU_ADD("maincpu", SH3BE, CPU_CLOCK)
@ -481,7 +476,7 @@ static MACHINE_CONFIG_DERIVED( cv1k_d, cv1k )
MCFG_SH4_CLOCK(CPU_CLOCK)
MCFG_CPU_PROGRAM_MAP(cv1k_d_map)
MCFG_CPU_IO_MAP(cv1k_port)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", cv1k_state, cv1k_interrupt)
MCFG_CPU_VBLANK_INT_DRIVER("screen", cv1k_state, irq2_line_hold)
MCFG_DEVICE_MODIFY("blitter")
MCFG_EPIC12_SET_MAINRAMSIZE(0x1000000)
@ -804,7 +799,7 @@ READ64_MEMBER( cv1k_state::mushisam_speedup_r )
if ( pc == 0xc04a0aa ) m_maincpu->spin_until_time( attotime::from_usec(10)); // mushisam
else if (pc == 0xc04a0da) m_maincpu->spin_until_time( attotime::from_usec(10)); // mushitam
// else printf("read %08x\n", m_maincpu->pc());
return cv1k_ram[0x0022f0/8];
return m_ram[0x0022f0/8];
}
DRIVER_INIT_MEMBER(cv1k_state,mushisam)
@ -816,7 +811,7 @@ READ64_MEMBER( cv1k_state::mushisama_speedup_r )
{
if (m_maincpu->pc()== 0xc04a2aa ) m_maincpu->spin_until_time( attotime::from_usec(10)); // mushisam
// else printf("read %08x\n", m_maincpu->pc());
return cv1k_ram[0x00024d8/8];
return m_ram[0x00024d8/8];
}
DRIVER_INIT_MEMBER(cv1k_state,mushisama)
@ -833,7 +828,7 @@ READ64_MEMBER( cv1k_state::espgal2_speedup_r )
if ( pc == 0xc0519a2 ) m_maincpu->spin_until_time( attotime::from_usec(10)); // deathsml
if ( pc == 0xc1d1346 ) m_maincpu->spin_until_time( attotime::from_usec(10)); // dpddfk / dsmbl
// else printf("read %08x\n", m_maincpu->pc());
return cv1k_ram[0x002310/8];
return m_ram[0x002310/8];
}
DRIVER_INIT_MEMBER(cv1k_state,espgal2)