Previous 199869 Revisions Next

r31473 Wednesday 30th July, 2014 at 18:50:24 UTC by hap
small cleanup
[src/emu/video]epic12.c epic12.h
[src/mame/drivers]cv1k.c

trunk/src/mame/drivers/cv1k.c
r31472r31473
162162 - Need SH3 recompiler?
163163
164164Blitter Timing
165 - 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
165 - 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
166166 - End of Blit IRQ? (one game has a valid irq routine that looks like it was used for profiling, but nothing depends on it)
167167
168168*/
r31472r31473
187187      m_blitter(*this, "blitter"),
188188      m_serflash(*this, "game"),
189189      m_eeprom(*this, "eeprom"),
190      cv1k_ram(*this, "mainram"),
190      m_ram(*this, "mainram"),
191191      m_blitrate(*this, "BLITRATE"),
192192      m_eepromout(*this, "EEPROMOUT") { }
193193
r31472r31473
196196   required_device<serflash_device> m_serflash;
197197   required_device<rtc9701_device> m_eeprom;
198198
199   required_shared_ptr<UINT64> cv1k_ram;
199   required_shared_ptr<UINT64> m_ram;
200200
201201   DECLARE_READ8_MEMBER(cv1k_flash_io_r);
202202   DECLARE_WRITE8_MEMBER(cv1k_flash_io_w);
r31472r31473
204204   DECLARE_WRITE8_MEMBER(serial_rtc_eeprom_w);
205205   DECLARE_READ64_MEMBER(cv1k_flash_port_e_r);
206206
207   INTERRUPT_GEN_MEMBER(cv1k_interrupt);
208207   UINT32 screen_update_cv1k(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
209208
210   DECLARE_MACHINE_RESET( cv1k );
209   virtual void machine_reset();
211210
212211   /* game specific */
213212   DECLARE_READ64_MEMBER(mushisam_speedup_r);
r31472r31473
231230
232231UINT32 cv1k_state::screen_update_cv1k(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
233232{
234   epic12_device::set_delay_scale(m_blitter, m_blitrate->read());
233   m_blitter->set_delay_scale(m_blitrate->read());
235234
236235   m_blitter->draw_screen(bitmap,cliprect);
237236   return 0;
r31472r31473
242241
243242READ64_MEMBER( cv1k_state::cv1k_flash_port_e_r )
244243{
245   return ((m_serflash->flash_ready_r(space, offset) ? 0x20 : 0x00)) | 0xdf;
244   return ((m_serflash->flash_ready_r(space, offset) ? 0x20 : 0x00)) | 0xdf;
246245}
247246
248247
r31472r31473
298297{
299298   switch (offset)
300299   {
301      case 1:
300      case 0x01:
302301         return 0xfe | m_eeprom->read_bit();
303302
304303      default:
r31472r31473
315314         break;
316315      case 0x03:
317316         m_serflash->flash_enab_w(space,offset,data);
318         return;
317         break;
318
319319      default:
320         logerror("unknown serial_rtc_eeprom_w access offset %02x data %02x\n",offset, data);
321      break;
320         logerror("unknown serial_rtc_eeprom_w access offset %02x data %02x\n", offset, data);
321         break;
322322   }
323323}
324324
r31472r31473
409409INPUT_PORTS_END
410410
411411
412INTERRUPT_GEN_MEMBER(cv1k_state::cv1k_interrupt)
412void cv1k_state::machine_reset()
413413{
414   m_maincpu->set_input_line(2, HOLD_LINE);
415}
416
417MACHINE_RESET_MEMBER( cv1k_state, cv1k )
418{
419   epic12_device::set_rambase (m_blitter, reinterpret_cast<UINT16 *>(cv1k_ram.target()));
420   epic12_device::set_cpu_device (m_blitter, m_maincpu );
421   epic12_device::set_is_unsafe(m_blitter, machine().root_device().ioport(":BLITCFG")->read());
414   m_blitter->set_rambase (reinterpret_cast<UINT16 *>(m_ram.target()));
415   m_blitter->set_cpu_device (m_maincpu);
416   m_blitter->set_is_unsafe(machine().root_device().ioport(":BLITCFG")->read());
422417   m_blitter->install_handlers( 0x18000000, 0x18000057 );
423418   m_blitter->reset();
424419}
425420
426421static MACHINE_CONFIG_START( cv1k, cv1k_state )
422
427423   /* basic machine hardware */
428424   MCFG_CPU_ADD("maincpu", SH3BE, CPU_CLOCK)
429425   MCFG_SH4_MD0(0)  // none of this is verified
r31472r31473
438434   MCFG_SH4_CLOCK(CPU_CLOCK)
439435   MCFG_CPU_PROGRAM_MAP(cv1k_map)
440436   MCFG_CPU_IO_MAP(cv1k_port)
441   MCFG_DEVICE_VBLANK_INT_DRIVER("screen", cv1k_state, cv1k_interrupt)
437   MCFG_CPU_VBLANK_INT_DRIVER("screen", cv1k_state, irq2_line_hold)
442438
443439   MCFG_RTC9701_ADD("eeprom")
444440   MCFG_SERFLASH_ADD("game")
r31472r31473
451447   MCFG_SCREEN_VISIBLE_AREA(0, 0x140-1, 0, 0xf0-1)
452448   MCFG_SCREEN_UPDATE_DRIVER(cv1k_state, screen_update_cv1k)
453449
454
455450   MCFG_PALETTE_ADD("palette", 0x10000)
456451
457   MCFG_MACHINE_RESET_OVERRIDE(cv1k_state, cv1k)
458
459452   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
460453   MCFG_YMZ770_ADD("ymz770", XTAL_16_384MHz)
461454   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r31472r31473
466459MACHINE_CONFIG_END
467460
468461static MACHINE_CONFIG_DERIVED( cv1k_d, cv1k )
462
463   /* basic machine hardware */
469464   MCFG_DEVICE_REMOVE("maincpu")
470465
471466   MCFG_CPU_ADD("maincpu", SH3BE, CPU_CLOCK)
r31472r31473
481476   MCFG_SH4_CLOCK(CPU_CLOCK)
482477   MCFG_CPU_PROGRAM_MAP(cv1k_d_map)
483478   MCFG_CPU_IO_MAP(cv1k_port)
484   MCFG_DEVICE_VBLANK_INT_DRIVER("screen", cv1k_state, cv1k_interrupt)
479   MCFG_CPU_VBLANK_INT_DRIVER("screen", cv1k_state, irq2_line_hold)
485480
486481   MCFG_DEVICE_MODIFY("blitter")
487482   MCFG_EPIC12_SET_MAINRAMSIZE(0x1000000)
r31472r31473
804799   if ( pc == 0xc04a0aa ) m_maincpu->spin_until_time( attotime::from_usec(10)); // mushisam
805800   else if (pc == 0xc04a0da)  m_maincpu->spin_until_time( attotime::from_usec(10)); // mushitam
806801//  else printf("read %08x\n", m_maincpu->pc());
807   return cv1k_ram[0x0022f0/8];
802   return m_ram[0x0022f0/8];
808803}
809804
810805DRIVER_INIT_MEMBER(cv1k_state,mushisam)
r31472r31473
816811{
817812   if (m_maincpu->pc()== 0xc04a2aa ) m_maincpu->spin_until_time( attotime::from_usec(10)); // mushisam
818813//  else printf("read %08x\n", m_maincpu->pc());
819   return cv1k_ram[0x00024d8/8];
814   return m_ram[0x00024d8/8];
820815}
821816
822817DRIVER_INIT_MEMBER(cv1k_state,mushisama)
r31472r31473
833828   if ( pc == 0xc0519a2 ) m_maincpu->spin_until_time( attotime::from_usec(10)); // deathsml
834829   if ( pc == 0xc1d1346 ) m_maincpu->spin_until_time( attotime::from_usec(10)); // dpddfk / dsmbl
835830//  else printf("read %08x\n", m_maincpu->pc());
836   return cv1k_ram[0x002310/8];
831   return m_ram[0x002310/8];
837832}
838833
839834DRIVER_INIT_MEMBER(cv1k_state,espgal2)
trunk/src/emu/video/epic12.c
r31472r31473
3333   epic12_device_gfx_scroll_1_y_shadowcopy = 0;
3434   epic12_device_ram16_copy = 0;
3535   epic12_device_blit_delay = 0;
36
3736}
3837
3938TIMER_CALLBACK_MEMBER( epic12_device::epic12_device_blitter_delay_callback )
r31472r31473
4140   blitter_busy = 0;
4241}
4342
44// static
45   void epic12_device::set_rambase(device_t &device, UINT16* rambase)
46{
47   epic12_device &dev = downcast<epic12_device &>(device);
48   dev.epic12_device_ram16 = rambase;
49}
5043
51
52void epic12_device::set_delay_scale(device_t &device, int delay_scale)
53{
54   epic12_device &dev = downcast<epic12_device &>(device);
55   dev.m_delay_scale = delay_scale;
56}
57
58void epic12_device::set_is_unsafe(device_t &device, int is_unsafe)
59{
60   epic12_device &dev = downcast<epic12_device &>(device);
61   dev.m_is_unsafe = is_unsafe;
62
63}
64
65void epic12_device::set_cpu_device(device_t &device, cpu_device* maincpu)
66{
67   epic12_device &dev = downcast<epic12_device &>(device);
68   dev.m_maincpu = maincpu;
69}
70
71
7244void epic12_device::device_start()
7345{
7446   epic12_device_gfx_size = 0x2000 * 0x1000;
7547   epic12_device_bitmaps = auto_bitmap_rgb32_alloc(machine(), 0x2000, 0x1000);
7648   epic12_device_clip = epic12_device_bitmaps->cliprect();
77
49   epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
50   
7851   epic12_device_ram16_copy = auto_alloc_array(machine(), UINT16, m_main_ramsize/2);
7952
80
81
8253   epic12_device_blitter_delay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(epic12_device::epic12_device_blitter_delay_callback),this));
8354   epic12_device_blitter_delay_timer->adjust(attotime::never);
84
85
8655}
8756
8857void epic12_device::device_reset()
r31472r31473
326295
327296
328297
329inline void epic12_device::epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr, int cliptype)
298inline void epic12_device::epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr)
330299{
331300   COPY_NEXT_WORD(space, addr);
332301   COPY_NEXT_WORD(space, addr);
r31472r31473
567536void epic12_device::epic12_device_gfx_create_shadow_copy(address_space &space)
568537{
569538   offs_t addr = epic12_device_gfx_addr & 0x1fffffff;
570   UINT16 cliptype = 0;
539   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);
571540
572   epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
573   epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
574   epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
575   epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
576
577541   while (1)
578542   {
579543      UINT16 data = COPY_NEXT_WORD(space, &addr);
r31472r31473
585549            return;
586550
587551         case 0xc000:
588            data = COPY_NEXT_WORD(space, &addr);
589
590            cliptype = data ? 1 : 0;
591
592            if (cliptype)
593            {
594               epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
595               epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
596               epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
597               epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
598            }
552            if (COPY_NEXT_WORD(space, &addr)) // cliptype
553               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);
599554            else
600            {
601               epic12_device_clip.min_x = 0;
602               epic12_device_clip.min_y = 0;
603               epic12_device_clip.max_x = 0x2000-1;
604               epic12_device_clip.max_y = 0x1000-1;
605            }
606
555               epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
607556            break;
608557
609558         case 0x2000:
r31472r31473
613562
614563         case 0x1000:
615564            addr -= 2;
616            epic12_device_gfx_draw_shadow_copy(space, &addr, cliptype);
565            epic12_device_gfx_draw_shadow_copy(space, &addr);
617566            break;
618567
619568         default:
r31472r31473
626575
627576void epic12_device::epic12_device_gfx_exec(void)
628577{
629   UINT16 cliptype = 0;
630
631578   offs_t addr = epic12_device_gfx_addr_shadowcopy & 0x1fffffff;
579   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);
632580
633581//  logerror("GFX EXEC: %08X\n", addr);
634582
635   epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
636   epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
637   epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
638   epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
639
640583   while (1)
641584   {
642585      UINT16 data = READ_NEXT_WORD(&addr);
r31472r31473
648591            return;
649592
650593         case 0xc000:
651            data = READ_NEXT_WORD(&addr);
652            cliptype = data ? 1 : 0;
653
654            if (cliptype)
655            {
656               epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x_shadowcopy;
657               epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y_shadowcopy;
658               epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
659               epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
660            }
594            if (READ_NEXT_WORD(&addr)) // cliptype
595               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);
661596            else
662            {
663               epic12_device_clip.min_x = 0;
664               epic12_device_clip.min_y = 0;
665               epic12_device_clip.max_x = 0x2000-1;
666               epic12_device_clip.max_y = 0x1000-1;
667            }
597               epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
668598            break;
669599
670600         case 0x2000:
r31472r31473
687617
688618void epic12_device::epic12_device_gfx_exec_unsafe(void)
689619{
690   UINT16 cliptype = 0;
691
692620   offs_t addr = epic12_device_gfx_addr & 0x1fffffff;
621   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);
693622
694623//  logerror("GFX EXEC: %08X\n", addr);
695624
696   epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x;
697   epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y;
698   epic12_device_clip.max_x = epic12_device_clip.min_x + 320-1;
699   epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
700
701625   while (1)
702626   {
703627      UINT16 data = READ_NEXT_WORD(&addr);
r31472r31473
709633            return;
710634
711635         case 0xc000:
712            data = READ_NEXT_WORD(&addr);
713            cliptype = data ? 1 : 0;
714
715            if (cliptype)
716            {
717               epic12_device_clip.min_x = epic12_device_gfx_scroll_1_x;
718               epic12_device_clip.min_y = epic12_device_gfx_scroll_1_y;
719               epic12_device_clip.max_x = epic12_device_clip.min_x  + 320-1;
720               epic12_device_clip.max_y = epic12_device_clip.min_y + 240-1;
721            }
636            if (READ_NEXT_WORD(&addr)) // cliptype
637               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);
722638            else
723            {
724               epic12_device_clip.min_x = 0;
725               epic12_device_clip.min_y = 0;
726               epic12_device_clip.max_x = 0x2000-1;
727               epic12_device_clip.max_y = 0x1000-1;
728            }
639               epic12_device_clip.set(0, 0x2000-1, 0, 0x1000-1);
729640            break;
730641
731642         case 0x2000:
r31472r31473
1025936   }
1026937
1027938   space.install_readwrite_handler(addr1, addr2, read , write, U64(0xffffffffffffffff));
1028
1029
1030
1031939}
1032940
1033941READ64_MEMBER( epic12_device::epic12_device_fpga_r )
trunk/src/emu/video/epic12.h
r31472r31473
1/* emulation of Altera Cyclone EPIC12 FPGA programmed as a blitter */
12
23#define MCFG_EPIC12_ADD(_tag) \
34   MCFG_DEVICE_ADD(_tag, EPIC12, 0)
r31472r31473
5051public:
5152   epic12_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5253
53   static void set_rambase(device_t &device, UINT16* rambase);
54   void set_rambase(UINT16* rambase) { epic12_device_ram16 = rambase; }
5455
5556   inline UINT16 READ_NEXT_WORD(offs_t *addr);
5657
r31472r31473
6768   DECLARE_READ64_MEMBER( epic12_device_fpga_r );
6869   DECLARE_WRITE64_MEMBER( epic12_device_fpga_w );
6970
70   void draw_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect );
71   void draw_screen(bitmap_rgb32 &bitmap, const rectangle &cliprect);
7172
7273   UINT16* epic12_device_ram16;
7374   UINT32 epic12_device_gfx_addr;
r31472r31473
9495   inline void epic12_device_gfx_upload_shadow_copy(address_space &space, offs_t *addr);
9596   inline void epic12_device_gfx_create_shadow_copy(address_space &space);
9697   inline UINT16 COPY_NEXT_WORD(address_space &space, offs_t *addr);
97   inline void epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr, int cliptype);
98   inline void epic12_device_gfx_draw_shadow_copy(address_space &space, offs_t *addr);
9899   inline void epic12_device_gfx_upload(offs_t *addr);
99100   inline void epic12_device_gfx_draw(offs_t *addr);
100101   void epic12_device_gfx_exec(void);
r31472r31473
114115   int m_delay_scale;
115116   cpu_device* m_maincpu;
116117
117   static void set_delay_scale(device_t &device, int delay_scale);
118   static void set_is_unsafe(device_t &device, int is_unsafe);
119   static void set_cpu_device(device_t &device, cpu_device* maincpu);
118   void set_delay_scale(int delay_scale) { m_delay_scale = delay_scale; }
119   void set_is_unsafe(int is_unsafe) { m_is_unsafe = is_unsafe; }
120   void set_cpu_device(cpu_device* maincpu) { m_maincpu = maincpu; }
120121
121122   void install_handlers(int addr1, int addr2);
122123
r31472r31473
831832   virtual void device_start();
832833   virtual void device_reset();
833834
834
835
836835   osd_work_queue *    queue;                  /* work queue */
837836   osd_work_item * blitter_request;
838837
r31472r31473
841840   int blitter_busy;
842841
843842   TIMER_CALLBACK_MEMBER( epic12_device_blitter_delay_callback );
844
845
846private:
847843};
848844
849845
850846
851
852
853
854847extern const device_type EPIC12;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team