Previous 199869 Revisions Next

r23863 Saturday 22nd June, 2013 at 19:53:04 UTC by R. Belmont
(MESS) SNES SA-1 improvements [R. Belmont]
- S-CPU can properly write to SA-1 registers
- SA-1 CPU boots properly from its own vectors
- Interrupt controller implemented
- Message-passing registers and status flags hooked up
[src/mess/drivers]snes.c
[src/mess/machine]sns_sa1.c sns_sa1.h

trunk/src/mess/drivers/snes.c
r23862r23863
639639   if (offset >= 0x400000 && offset < 0x500000)
640640      m_cartslot->chip_write(space, offset, data);        // SA-1 BWRAM (not mirrored above!)
641641   else
642      snessfx_hi_w(space, offset, data, 0xff);
642      snessa1_hi_w(space, offset, data, 0xff);
643643}
644644
645645//---------------------------------------------------------------------------------
trunk/src/mess/machine/sns_sa1.c
r23862r23863
3535#include "emu.h"
3636#include "machine/sns_sa1.h"
3737
38#define SA1_IRQ_SCPU   (0x80)
39#define SA1_IRQ_TIMER   (0x40)
40#define SA1_IRQ_DMA      (0x20)
41#define SA1_NMI_SCPU   (0x10)
3842
43#define SCPU_IRQ_SA1   (0x80)
44#define SCPU_IRQV_ALT   (0x40)
45#define SCPU_IRQ_CHARCONV (0x20)
46#define SCPU_NMIV_ALT   (0x10)
47
3948//-------------------------------------------------
4049//  constructor
4150//-------------------------------------------------
r23862r23863
4857                  device_sns_cart_interface( mconfig, *this ),
4958                  m_sa1(*this, "sa1cpu")
5059{
60
5161}
5262
5363
r23862r23863
96106   m_drm = 0;
97107   m_hcr = 0;
98108   m_vcr = 0;
109   m_scpu_sie = m_sa1_sie = 0;
110   m_scpu_flags = m_sa1_flags = 0;
111
112   // sa-1 CPU starts out not running?
113   m_sa1->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
99114}
100115
101116
r23862r23863
103118 mapper specific handlers
104119 -------------------------------------------------*/
105120
121void sns_sa1_device::recalc_irqs()
122{
123   #if 0   // how do we get the maincpu from here?
124   if (m_scpu_flags & m_scpu_sie & (SCPU_IRQ_SA1|SCPU_IRQ_CHARCONV))
125   {
126      set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
127   }
128   else
129   {
130      set_input_line(G65816_LINE_IRQ, CLEAR_LINE);
131   }
132   #endif
133
134   if (m_sa1_flags & m_sa1_sie & (SA1_IRQ_SCPU|SA1_IRQ_TIMER|SA1_IRQ_DMA))
135   {
136      m_sa1->set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
137   }
138   else
139   {
140      m_sa1->set_input_line(G65816_LINE_IRQ, CLEAR_LINE);
141   }
142
143   if (m_sa1_flags & m_sa1_sie & SA1_NMI_SCPU)
144   {
145      m_sa1->set_input_line(G65816_LINE_NMI, ASSERT_LINE);
146   }
147   else
148   {
149      m_sa1->set_input_line(G65816_LINE_NMI, CLEAR_LINE);
150   }
151}
152
153
106154/*-------------------------------------------------
107155  RAM / SRAM / Registers
108156 -------------------------------------------------*/
r23862r23863
154202   {
155203      case 0x100:
156204         // S-CPU Flag Read
157         value = (m_scpu_ctrl & ~0xa0); // | (IRQ Flags);
205         value = (m_scpu_ctrl & 0x0f) | m_scpu_flags;
158206         break;
159207      case 0x101:
160208         // SA-1 Flag Read
161         value = (m_sa1_ctrl & ~0x0f); // | (IRQ/NMI/Timer Flags);
209         value = (m_sa1_ctrl & 0x0f) | m_sa1_flags;
162210         break;
163211      case 0x102:
164212         // H-Count Read Low
r23862r23863
249297   {
250298      case 0x000:
251299         // SA-1 control flags
252         if (BIT(m_sa1_ctrl, 5) && !BIT(data, 7))
300         if ((BIT(data, 5)) && !(BIT(m_sa1_ctrl, 5)))
253301         {
254            // reset sa-1?
302            printf("Engaging SA-1 reset\n");
303            m_sa1->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
255304         }
305         else if (!(BIT(data, 5)) && (BIT(m_sa1_ctrl, 5)))
306         {
307            printf("Releasing SA-1 reset\n");
308            m_sa1->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
309            m_sa1->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
310            m_sa1->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
311         }
312
256313         m_sa1_ctrl = data;
257314
315         // message to S-CPU
316         m_scpu_ctrl &= 0xf0;
317         m_scpu_ctrl |= (data & 0x0f);
318
258319         if (BIT(m_sa1_ctrl, 7))
259320         {
260            // IRQ
321            m_sa1_flags |= SA1_IRQ_SCPU;
261322         }
262323         if (BIT(m_sa1_ctrl, 4))
263324         {
264            // NMI
325            m_sa1_flags |= SA1_NMI_SCPU;
265326         }
327         recalc_irqs();
266328         break;
267329      case 0x001:
268330         // SNES  SIE   00h   SNES CPU Int Enable (W)
331         m_scpu_sie = data;
332         recalc_irqs();
269333         break;
270334      case 0x002:
271335         // SNES  SIC   00h   SNES CPU Int Clear  (W)
336         if (BIT(data, 7))   // ack IRQ from SA-1
337         {
338            m_scpu_flags &= ~SCPU_IRQ_SA1;
339         }
340         if (BIT(data, 5))   // ack character conversion IRQ
341         {
342            m_scpu_flags &= ~SCPU_IRQ_CHARCONV;
343         }
344         recalc_irqs();
272345         break;
273346      case 0x003:
274347         // SNES  CRV   -     SA-1 CPU Reset Vector Lsb (W)
348         m_sa1_reset &= 0xff00;
349         m_sa1_reset |= data;
275350         break;
276351      case 0x004:
277352         // SNES  CRV   -     SA-1 CPU Reset Vector Msb (W)
353         m_sa1_reset &= 0x00ff;
354         m_sa1_reset |= (data<<8);
278355         break;
279356      case 0x005:
280357         // SNES  CNV   -     SA-1 CPU NMI Vector Lsb (W)
358         m_sa1_nmi &= 0xff00;
359         m_sa1_nmi |= data;
281360         break;
282361      case 0x006:
283362         // SNES  CNV   -     SA-1 CPU NMI Vector Msb (W)
363         m_sa1_nmi &= 0x00ff;
364         m_sa1_nmi |= (data<<8);
284365         break;
285366      case 0x007:
286367         // SNES  CIV   -     SA-1 CPU IRQ Vector Lsb (W)
368         m_sa1_irq &= 0xff00;
369         m_sa1_irq |= data;
287370         break;
288371      case 0x008:
289372         // SNES  CIV   -     SA-1 CPU IRQ Vector Msb (W)
373         m_sa1_irq &= 0x00ff;
374         m_sa1_irq |= (data<<8);
290375         break;
291376      case 0x009:
292377         // S-CPU control flags
293378         m_scpu_ctrl = data;
294379         if (m_scpu_ctrl & 0x80)
295380         {
296            // IRQ
381            m_scpu_flags |= SCPU_IRQ_SA1;
297382         }
383
384         // message to SA-1
385         m_sa1_ctrl &= 0xf0;
386         m_sa1_ctrl |= (data & 0x0f);
387
388         // clear IRQ/NMI override flags in flags word
389         m_scpu_flags &= ~(SCPU_IRQV_ALT|SCPU_NMIV_ALT);
390
391         // and set them
392         m_scpu_flags |= (data & (SCPU_IRQV_ALT|SCPU_NMIV_ALT));
393
394         recalc_irqs();
298395         break;
299396      case 0x00a:
300397         // SA-1  CIE   00h   SA-1 CPU Int Enable (W)
398         m_sa1_sie = data;
399         recalc_irqs();
301400         break;
302401      case 0x00b:
303402         // SA-1  CIC   00h   SA-1 CPU Int Clear  (W)
403         if (BIT(data, 7))
404         {
405            m_sa1_flags &= ~SA1_IRQ_SCPU;
406         }
407         if (BIT(data, 6))
408         {
409            m_sa1_flags &= ~SA1_IRQ_TIMER;
410         }
411         if (BIT(data, 5))
412         {
413            m_sa1_flags &= ~SA1_IRQ_DMA;
414         }
415         if (BIT(data, 4))
416         {
417            m_sa1_flags &= ~SA1_NMI_SCPU;
418         }
419         recalc_irqs();
304420         break;
305421      case 0x00c:
306422         // NMI Vector Low
r23862r23863
771887      }
772888      else if (address < 0x8000)
773889         return read_bwram((m_bwram_sa1 * 0x2000) + (offset & 0x1fff) + (m_bwram_sa1_source * 0x100000));        // SA-1 BWRAM
890      else if (address == 0xffee)
891      {
892         return m_sa1_irq & 0xff;
893      }
894      else if (address == 0xffef)
895      {
896         return m_sa1_irq>>8;
897      }
898      else if (address == 0xffea)
899      {
900         return m_sa1_nmi & 0xff;
901      }
902      else if (address == 0xffeb)
903      {
904         return m_sa1_nmi>>8;
905      }
906      else if (address == 0xfffc)
907      {
908         return m_sa1_reset & 0xff;
909      }
910      else if (address == 0xfffd)
911      {
912         return m_sa1_reset>>8;
913      }
774914      else
775915         return read_l(space, offset);   // ROM
776916
r23862r23863
821961
822962
823963static MACHINE_CONFIG_FRAGMENT( snes_sa1 )
824   MCFG_CPU_ADD("sa1cpu", _5A22, 10000000)
964   MCFG_CPU_ADD("sa1cpu", G65816, 10000000)
825965   MCFG_CPU_PROGRAM_MAP(sa1_map)
826966MACHINE_CONFIG_END
827967
trunk/src/mess/machine/sns_sa1.h
r23862r23863
4444   void write_regs(UINT32 offset, UINT8 data);
4545   void write_iram(UINT32 offset, UINT8 data);
4646   void write_bwram(UINT32 offset, UINT8 data);
47   void recalc_irqs();
4748
48   required_device<_5a22_device> m_sa1;
49   required_device<g65816_device> m_sa1;
4950
5051   UINT8 m_internal_ram[0x800];
5152
5253   // register related
5354   // $2200
5455   UINT8 m_sa1_ctrl;
56   // $2201
57   UINT8 m_scpu_sie;
58   // $2203-$2208
59   UINT16 m_sa1_reset, m_sa1_nmi, m_sa1_irq;
5560   // $2209
5661   UINT8 m_scpu_ctrl;
62   // $220a
63   UINT8 m_sa1_sie;
5764   // $200c-$200d - S-CPU vectors
5865   UINT16 m_irq_vector, m_nmi_vector;
5966   // $2012-$2015
r23862r23863
8491   UINT32 m_vda;
8592   UINT8 m_vbit, m_vlen;
8693   int m_drm;
94   // $2300-$2301
95   UINT8 m_scpu_flags, m_sa1_flags;
8796   // $2302-$2305
8897   UINT16 m_hcr, m_vcr;
8998};

Previous 199869 Revisions Next


© 1997-2024 The MAME Team