Previous 199869 Revisions Next

r20843 Friday 8th February, 2013 at 20:15:42 UTC by Wilbert Pol
a310.c/archimds.c: Reduce tagmap lookups (nw)
[src/mame/includes]archimds.h
[src/mame/machine]archimds.c
[src/mess/drivers]a310.c

trunk/src/mess/drivers/a310.c
r20842r20843
7070{
7171public:
7272   a310_state(const machine_config &mconfig, device_type type, const char *tag)
73      : archimedes_state(mconfig, type, tag),
74         m_physram(*this, "physicalram") { }
73      : archimedes_state(mconfig, type, tag)
74      , m_physram(*this, "physicalram")
75      , m_ram(*this, RAM_TAG)
76   { }
7577
7678   required_shared_ptr<UINT32> m_physram;
7779
r20842r20843
8284   DECLARE_DRIVER_INIT(a310);
8385   virtual void machine_start();
8486   virtual void machine_reset();
87
88protected:
89   required_device<ram_device> m_ram;
8590};
8691
8792
r20842r20843
114119
115120DRIVER_INIT_MEMBER(a310_state,a310)
116121{
117   UINT32 ram_size = machine().device<ram_device>(RAM_TAG)->size();
122   UINT32 ram_size = m_ram->size();
118123
119   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x02000000, 0x02000000+(ram_size-1), read32_delegate(FUNC(a310_state::a310_psy_wram_r), this), write32_delegate(FUNC(a310_state::a310_psy_wram_w), this));
124   m_maincpu->space(AS_PROGRAM).install_readwrite_handler( 0x02000000, 0x02000000+(ram_size-1), read32_delegate(FUNC(a310_state::a310_psy_wram_r), this), write32_delegate(FUNC(a310_state::a310_psy_wram_w), this));
120125
121126   archimedes_driver_init();
122127}
trunk/src/mame/machine/archimds.c
r20842r20843
2828
2929#include "emu.h"
3030#include "cpu/arm/arm.h"
31#include "sound/dac.h"
3231#include "includes/archimds.h"
33#include "machine/i2cmem.h"
3432#include "debugger.h"
35#include "machine/wd17xx.h"
3633
3734static const int page_sizes[4] = { 4096, 8192, 16384, 32768 };
3835static const UINT32 pixel_rate[4] = { 8000000, 12000000, 16000000, 24000000};
r20842r20843
4542   m_ioc_regs[IRQ_STATUS_A] |= mask;
4643
4744   if (m_ioc_regs[IRQ_STATUS_A] & m_ioc_regs[IRQ_MASK_A])
48      machine().device("maincpu")->execute().set_input_line(ARM_IRQ_LINE, ASSERT_LINE);
45   {
46      m_maincpu->set_input_line(ARM_IRQ_LINE, ASSERT_LINE);
47   }
4948
5049   if ((m_ioc_regs[IRQ_STATUS_A] & m_ioc_regs[IRQ_MASK_A]) == 0)
51      machine().device("maincpu")->execute().set_input_line(ARM_IRQ_LINE, CLEAR_LINE);
52
50   {
51      m_maincpu->set_input_line(ARM_IRQ_LINE, CLEAR_LINE);
52   }
5353}
5454
5555void archimedes_state::archimedes_request_irq_b(int mask)
r20842r20843
5858
5959   if (m_ioc_regs[IRQ_STATUS_B] & m_ioc_regs[IRQ_MASK_B])
6060   {
61      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM_IRQ_LINE, 1);
61      generic_pulse_irq_line(m_maincpu, ARM_IRQ_LINE, 1);
6262   }
6363}
6464
r20842r20843
6868
6969   if (m_ioc_regs[FIQ_STATUS] & m_ioc_regs[FIQ_MASK])
7070   {
71      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM_FIRQ_LINE, 1);
71      generic_pulse_irq_line(m_maincpu, ARM_FIRQ_LINE, 1);
7272   }
7373}
7474
r20842r20843
113113/* TODO: what type of DMA this is, burst or cycle steal? Docs doesn't explain it (4 usec is the DRAM refresh). */
114114void archimedes_state::vidc_video_tick()
115115{
116   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
117   static UINT8 *vram = machine().root_device().memregion("vram")->base();
116   address_space &space = m_maincpu->space(AS_PROGRAM);
117   static UINT8 *vram = m_region_vram->base();
118118   UINT32 size;
119119
120120   size = m_vidc_vidend-m_vidc_vidstart+0x10;
r20842r20843
131131/* audio DMA */
132132void archimedes_state::vidc_audio_tick()
133133{
134   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
134   address_space &space = m_maincpu->space(AS_PROGRAM);
135135   UINT8 ulaw_comp;
136136   INT16 res;
137137   UINT8 ch;
138   static const char *const dac_port[8] = { "dac0", "dac1", "dac2", "dac3", "dac4", "dac5", "dac6", "dac7" };
139138   static const INT16 mulawTable[256] =
140139   {
141140      -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,
r20842r20843
180179
181180      res = mulawTable[ulaw_comp];
182181
183      machine().device<dac_device>(dac_port[ch & 7])->write_signed16(res^0x8000);
182      m_dac[ch & 7]->write_signed16(res^0x8000);
184183   }
185184
186185   m_vidc_sndcur+=8;
r20842r20843
194193      {
195194         m_snd_timer->adjust(attotime::never);
196195         for(ch=0;ch<8;ch++)
197            machine().device<dac_device>(dac_port[ch & 7])->write_signed16(0x8000);
196         {
197            m_dac[ch & 7]->write_signed16(0x8000);
198         }
198199      }
199200   }
200201}
r20842r20843
259260
260261void archimedes_state::archimedes_init()
261262{
263   static const char *const dac_names[8] = { "dac0", "dac1", "dac2", "dac3", "dac4", "dac5", "dac6", "dac7" };
264
262265   m_memc_pagesize = 0;
263266
264267   m_vbl_timer = timer_alloc(TIMER_VBLANK);
r20842r20843
276279   m_vid_timer = timer_alloc(TIMER_VIDEO);
277280   m_snd_timer = timer_alloc(TIMER_AUDIO);
278281   m_snd_timer->adjust(attotime::never);
282
283   for ( int i = 0; i < 8; i++ )
284   {
285      m_dac[i] = machine().device<dac_device>(dac_names[i]);
286   }
279287}
280288
281289READ32_MEMBER(archimedes_state::archimedes_memc_logical_r)
r20842r20843
287295   {
288296      UINT32 *rom;
289297
290      rom = (UINT32 *)machine().root_device().memregion("maincpu")->base();
298      rom = (UINT32 *)m_region_maincpu->base();
291299
292300      return rom[offset & 0x1fffff];
293301   }
r20842r20843
353361   {
354362      UINT32 *rom;
355363
356      rom = (UINT32 *)machine().root_device().memregion("maincpu")->base();
364      rom = (UINT32 *)m_region_maincpu->base();
357365
358366      return rom[offset & 0x1fffff];
359367   }
r20842r20843
394402
395403void archimedes_state::archimedes_driver_init()
396404{
397   m_archimedes_memc_physmem = reinterpret_cast<UINT32 *>(machine().root_device().memshare("physicalram")->ptr());
398//  address_space &space = machine.device<arm_device>("maincpu")->space(AS_PROGRAM);
405   m_archimedes_memc_physmem = reinterpret_cast<UINT32 *>(memshare("physicalram")->ptr());
406//  address_space &space = m_maincpu->space(AS_PROGRAM);
399407//  space.set_direct_update_handler(direct_update_delegate(FUNC(a310_setopbase), &machine));
400408}
401409
r20842r20843
446454READ32_MEMBER( archimedes_state::ioc_ctrl_r )
447455{
448456   if(IOC_LOG)
449   logerror("IOC: R %s = %02x (PC=%x) %02x\n", ioc_regnames[offset&0x1f], m_ioc_regs[offset&0x1f], space.device() .safe_pc( ),offset & 0x1f);
457   logerror("IOC: R %s = %02x (PC=%x) %02x\n", ioc_regnames[offset&0x1f], m_ioc_regs[offset&0x1f], m_maincpu->pc(),offset & 0x1f);
450458
451459   switch (offset & 0x1f)
452460   {
453461      case CONTROL:
454462      {
455         UINT8 i2c_data;
463         UINT8 i2c_data = 1;
456464         static UINT8 flyback; //internal name for vblank here
457465         int vert_pos;
458466
459467         vert_pos = machine().primary_screen->vpos();
460468         flyback = (vert_pos <= m_vidc_regs[VIDC_VDSR] || vert_pos >= m_vidc_regs[VIDC_VDER]) ? 0x80 : 0x00;
461469
462         i2c_data = (i2cmem_sda_read(space.machine().device("i2cmem")) & 1);
470         if ( m_i2cmem )
471         {
472            i2c_data = (i2cmem_sda_read(m_i2cmem) & 1);
473         }
463474
464475         return (flyback) | (m_ioc_regs[CONTROL] & 0x7c) | (m_i2c_clk<<1) | i2c_data;
465476      }
r20842r20843
524535   {
525536      case CONTROL:   // I2C bus control
526537         //logerror("IOC I2C: CLK %d DAT %d\n", (data>>1)&1, data&1);
527         i2cmem_sda_write(machine().device("i2cmem"), data & 0x01);
528         i2cmem_scl_write(machine().device("i2cmem"), (data & 0x02) >> 1);
538         if ( m_i2cmem )
539         {
540            i2cmem_sda_write(m_i2cmem, data & 0x01);
541            i2cmem_scl_write(m_i2cmem, (data & 0x02) >> 1);
542         }
529543         m_i2c_clk = (data & 2) >> 1;
530544         break;
531545
r20842r20843
632646READ32_MEMBER(archimedes_state::archimedes_ioc_r)
633647{
634648   UINT32 ioc_addr;
635   device_t *fdc = (device_t *)space.machine().device("wd1772");
636649
637650   ioc_addr = offset*4;
638651
r20842r20843
649662         {
650663            case 0: return ioc_ctrl_r(space,offset,mem_mask);
651664            case 1:
652               if (fdc) {
665               if (m_wd1772) {
653666                  logerror("17XX: R @ addr %x mask %08x\n", offset*4, mem_mask);
654                  return wd17xx_data_r(fdc, space, offset&0xf);
667                  return wd17xx_data_r(m_wd1772, space, offset&0xf);
655668               } else {
656669                  logerror("Read from FDC device?\n");
657670                  return 0;
r20842r20843
666679               logerror("IOC: Internal Podule Read\n");
667680               return 0xffff;
668681            case 5:
669               if (fdc) {
682               if (m_wd1772) {
670683                  switch(ioc_addr & 0xfffc)
671684                  {
672685                     case 0x50: return 0; //fdc type, new model returns 5 here
r20842r20843
688701WRITE32_MEMBER(archimedes_state::archimedes_ioc_w)
689702{
690703   UINT32 ioc_addr;
691   device_t *fdc = (device_t *)space.machine().device("wd1772");
692704
693705   ioc_addr = offset*4;
694706
r20842r20843
705717         {
706718            case 0: ioc_ctrl_w(space,offset,data,mem_mask); return;
707719            case 1:
708                  if (fdc) {
720                  if (m_wd1772) {
709721                     logerror("17XX: %x to addr %x mask %08x\n", data, offset*4, mem_mask);
710                     wd17xx_data_w(fdc, space, offset&0xf, data&0xff);
722                     wd17xx_data_w(m_wd1772, space, offset&0xf, data&0xff);
711723                  } else {
712724                     logerror("Write to FDC device?\n");
713725                  }
r20842r20843
722734               logerror("IOC: Internal Podule Write\n");
723735               return;
724736            case 5:
725               if (fdc) {
737               if (m_wd1772) {
726738                  switch(ioc_addr & 0xfffc)
727739                  {
728740                     case 0x18: // latch B
729                        wd17xx_dden_w(fdc, BIT(data, 1));
741                        wd17xx_dden_w(m_wd1772, BIT(data, 1));
730742                        return;
731743
732744                     case 0x40: // latch A
733                        if (data & 1) { wd17xx_set_drive(fdc,0); }
734                        if (data & 2) { wd17xx_set_drive(fdc,1); }
735                        if (data & 4) { wd17xx_set_drive(fdc,2); }
736                        if (data & 8) { wd17xx_set_drive(fdc,3); }
745                        if (data & 1) { wd17xx_set_drive(m_wd1772,0); }
746                        if (data & 2) { wd17xx_set_drive(m_wd1772,1); }
747                        if (data & 4) { wd17xx_set_drive(m_wd1772,2); }
748                        if (data & 8) { wd17xx_set_drive(m_wd1772,3); }
737749
738                        wd17xx_set_side(fdc,(data & 0x10)>>4);
750                        wd17xx_set_side(m_wd1772,(data & 0x10)>>4);
739751                        //bit 5 is motor on
740752                        return;
741753                  }
trunk/src/mame/includes/archimds.h
r20842r20843
88#define _ARCHIMEDES_H_
99
1010#include "machine/aakart.h"
11#include "sound/dac.h"
12#include "machine/i2cmem.h"
13#include "machine/wd17xx.h"
1114
1215// interrupt definitions.  these are for the real Archimedes computer - arcade
1316// and gambling knockoffs likely are a bit different.
r20842r20843
4043{
4144public:
4245   archimedes_state(const machine_config &mconfig, device_type type, const char *tag)
43      : driver_device(mconfig, type, tag),
44      m_kart(*this, "kart")
45      { }
46      : driver_device(mconfig, type, tag)
47      , m_kart(*this, "kart")
48      , m_maincpu(*this, "maincpu")
49      , m_i2cmem(*this, "i2cmem")
50      , m_wd1772(*this, "wd1772")
51      , m_region_maincpu(*this, "maincpu")
52      , m_region_vram(*this, "vram")
53   { }
4654
4755   optional_device<aakart_device> m_kart;
4856   void archimedes_init();
r20842r20843
7886
7987   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8088   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
89
90protected:
91   required_device<cpu_device> m_maincpu;
92   optional_device<device_t> m_i2cmem;
93   optional_device<device_t> m_wd1772;
94   required_memory_region m_region_maincpu;
95   required_memory_region m_region_vram;
96   dac_device *m_dac[8];
97
8198private:
8299
83100   static const device_timer_id TIMER_VBLANK = 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team