Previous 199869 Revisions Next

r20537 Sunday 27th January, 2013 at 16:41:13 UTC by Ryan Holtz
[GBA] Cleaned up tag usage outside of the startup path. [MooglyGuy]
[src/mess/drivers]gba.c

trunk/src/mess/drivers/gba.c
r20536r20537
8282   }
8383}
8484
85static void dma_exec(running_machine &machine, FPTR ch);
86
87static void gba_request_irq(running_machine &machine, UINT32 int_type)
85void gba_state::request_irq(UINT32 int_type)
8886{
89   gba_state *state = machine.driver_data<gba_state>();
90
9187   // set flag for later recovery
92   state->m_IF |= int_type;
88   m_IF |= int_type;
9389
9490   // is this specific interrupt enabled?
95   int_type &= state->m_IE;
91   int_type &= m_IE;
9692   if (int_type != 0)
9793   {
9894      // master enable?
99      if (state->m_IME & 1)
95      if (m_IME & 1)
10096      {
101         machine.device("maincpu")->execute().set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
102         machine.device("maincpu")->execute().set_input_line(ARM7_IRQ_LINE, CLEAR_LINE);
97         m_maincpu->set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
98         m_maincpu->set_input_line(ARM7_IRQ_LINE, CLEAR_LINE);
10399      }
104100   }
105101}
r20536r20537
121117   // IRQ
122118   if (ctrl & 0x4000)
123119   {
124      gba_request_irq(machine(), ch_int[ch]);
120      request_irq(ch_int[ch]);
125121   }
126122
127123   // if we're supposed to repeat, don't clear "active" and then the next vbl/hbl will retrigger us
r20536r20537
147143   }
148144}
149145
150static void dma_exec(running_machine &machine, FPTR ch)
146void gba_state::dma_exec(FPTR ch)
151147{
152   int i, cnt;
153   int ctrl;
154   int srcadd, dstadd;
155   UINT32 src, dst;
156   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
157   gba_state *state = machine.driver_data<gba_state>();
148   address_space &space = ((device_t*)m_maincpu)->memory().space(AS_PROGRAM);
149   UINT32 src = m_dma_src[ch];
150   UINT32 dst = m_dma_dst[ch];
151   int ctrl = m_dma_regs[(ch*3)+2] >> 16;
152   int srcadd = m_dma_srcadd[ch];
153   int dstadd = m_dma_dstadd[ch];
158154
159   src = state->m_dma_src[ch];
160   dst = state->m_dma_dst[ch];
161   ctrl = state->m_dma_regs[(ch*3)+2] >> 16;
162   srcadd = state->m_dma_srcadd[ch];
163   dstadd = state->m_dma_dstadd[ch];
164
165   cnt = state->m_dma_cnt[ch];
155   int cnt = m_dma_cnt[ch];
166156   if (!cnt)
167157   {
168158      if (ch == 3)
r20536r20537
198188//          printf("DMA exec: ch %d from %08x to %08x, mode %04x, count %04x (PC %x) (%s)\n", (int)ch, src, dst, ctrl, cnt, activecpu_get_pc(), ((ctrl>>10) & 1) ? "32" : "16");
199189   }
200190
201   for (i = 0; i < cnt; i++)
191   for (int i = 0; i < cnt; i++)
202192   {
203193      if ((ctrl>>10) & 1)
204194      {
r20536r20537
272262      }
273263   }
274264
275   state->m_dma_src[ch] = src;
276   state->m_dma_dst[ch] = dst;
265   m_dma_src[ch] = src;
266   m_dma_dst[ch] = dst;
277267
278//  printf("settng DMA timer %d for %d cycs (tmr %x)\n", ch, cnt, (UINT32)state->m_dma_timer[ch]);
279//  state->m_dma_timer[ch]->adjust(ATTOTIME_IN_CYCLES(0, cnt), ch);
280   state->dma_complete(NULL, ch);
268//  printf("settng DMA timer %d for %d cycs (tmr %x)\n", ch, cnt, (UINT32)m_dma_timer[ch]);
269//  m_dma_timer[ch]->adjust(ATTOTIME_IN_CYCLES(0, cnt), ch);
270   dma_complete(NULL, ch);
281271}
282272
283static void audio_tick(running_machine &machine, int ref)
273void gba_state::audio_tick(int ref)
284274{
285   gba_state *state = machine.driver_data<gba_state>();
286
287   if (!(state->m_SOUNDCNT_X & 0x80))
275   if (!(m_SOUNDCNT_X & 0x80))
288276   {
289277      return;
290278   }
291279
292280   if (!ref)
293281   {
294      if (state->m_fifo_a_ptr != state->m_fifo_a_in)
282      if (m_fifo_a_ptr != m_fifo_a_in)
295283      {
296         if (state->m_fifo_a_ptr == 17)
284         if (m_fifo_a_ptr == 17)
297285         {
298            state->m_fifo_a_ptr = 0;
286            m_fifo_a_ptr = 0;
299287         }
300288
301         if (state->m_SOUNDCNT_H & 0x200)
289         if (m_SOUNDCNT_H & 0x200)
302290         {
303            dac_device *dac = machine.device<dac_device>("direct_a_left");
304
305            dac->write_signed8(state->m_fifo_a[state->m_fifo_a_ptr]^0x80);
291            m_ladac->write_signed8(m_fifo_a[m_fifo_a_ptr]^0x80);
306292         }
307         if (state->m_SOUNDCNT_H & 0x100)
293         if (m_SOUNDCNT_H & 0x100)
308294         {
309            dac_device *dac = machine.device<dac_device>("direct_a_right");
310
311            dac->write_signed8(state->m_fifo_a[state->m_fifo_a_ptr]^0x80);
295            m_radac->write_signed8(m_fifo_a[m_fifo_a_ptr]^0x80);
312296         }
313         state->m_fifo_a_ptr++;
297         m_fifo_a_ptr++;
314298      }
315299
316300      // fifo empty?
317      if (state->m_fifo_a_ptr == state->m_fifo_a_in)
301      if (m_fifo_a_ptr == m_fifo_a_in)
318302      {
319303         // is a DMA set up to feed us?
320         if ((state->m_dma_regs[(1*3)+1] == 0x40000a0) && ((state->m_dma_regs[(1*3)+2] & 0x30000000) == 0x30000000))
304         if ((m_dma_regs[(1*3)+1] == 0x40000a0) && ((m_dma_regs[(1*3)+2] & 0x30000000) == 0x30000000))
321305         {
322306            // channel 1 it is
323            dma_exec(machine, 1);
307            dma_exec(1);
324308         }
325         if ((state->m_dma_regs[(2*3)+1] == 0x40000a0) && ((state->m_dma_regs[(2*3)+2] & 0x30000000) == 0x30000000))
309         if ((m_dma_regs[(2*3)+1] == 0x40000a0) && ((m_dma_regs[(2*3)+2] & 0x30000000) == 0x30000000))
326310         {
327311            // channel 2 it is
328            dma_exec(machine, 2);
312            dma_exec(2);
329313         }
330314      }
331315   }
332316   else
333317   {
334      if (state->m_fifo_b_ptr != state->m_fifo_b_in)
318      if (m_fifo_b_ptr != m_fifo_b_in)
335319      {
336         if (state->m_fifo_b_ptr == 17)
320         if (m_fifo_b_ptr == 17)
337321         {
338            state->m_fifo_b_ptr = 0;
322            m_fifo_b_ptr = 0;
339323         }
340324
341         if (state->m_SOUNDCNT_H & 0x2000)
325         if (m_SOUNDCNT_H & 0x2000)
342326         {
343            dac_device *dac = machine.device<dac_device>("direct_b_left");
344
345            dac->write_signed8(state->m_fifo_b[state->m_fifo_b_ptr]^0x80);
327            m_lbdac->write_signed8(m_fifo_b[m_fifo_b_ptr]^0x80);
346328         }
347         if (state->m_SOUNDCNT_H & 0x1000)
329         if (m_SOUNDCNT_H & 0x1000)
348330         {
349            dac_device *dac = machine.device<dac_device>("direct_b_right");
350
351            dac->write_signed8(state->m_fifo_b[state->m_fifo_b_ptr]^0x80);
331            m_rbdac->write_signed8(m_fifo_b[m_fifo_b_ptr]^0x80);
352332         }
353         state->m_fifo_b_ptr++;
333         m_fifo_b_ptr++;
354334      }
355335
356      if (state->m_fifo_b_ptr == state->m_fifo_b_in)
336      if (m_fifo_b_ptr == m_fifo_b_in)
357337      {
358338         // is a DMA set up to feed us?
359         if ((state->m_dma_regs[(1*3)+1] == 0x40000a4) && ((state->m_dma_regs[(1*3)+2] & 0x30000000) == 0x30000000))
339         if ((m_dma_regs[(1*3)+1] == 0x40000a4) && ((m_dma_regs[(1*3)+2] & 0x30000000) == 0x30000000))
360340         {
361341            // channel 1 it is
362            dma_exec(machine, 1);
342            dma_exec(1);
363343         }
364         if ((state->m_dma_regs[(2*3)+1] == 0x40000a4) && ((state->m_dma_regs[(2*3)+2] & 0x30000000) == 0x30000000))
344         if ((m_dma_regs[(2*3)+1] == 0x40000a4) && ((m_dma_regs[(2*3)+2] & 0x30000000) == 0x30000000))
365345         {
366346            // channel 2 it is
367            dma_exec(machine, 2);
347            dma_exec(2);
368348         }
369349      }
370350   }
r20536r20537
399379   {
400380      if ((m_SOUNDCNT_H & 0x400) == 0)
401381      {
402         audio_tick(machine(), 0);
382         audio_tick(0);
403383      }
404384
405385      if ((m_SOUNDCNT_H & 0x4000) == 0)
406386      {
407         audio_tick(machine(), 1);
387         audio_tick(1);
408388      }
409389   }
410390
r20536r20537
412392   {
413393      if ((m_SOUNDCNT_H & 0x400) == 0x400)
414394      {
415         audio_tick(machine(), 0);
395         audio_tick(0);
416396      }
417397
418398      if ((m_SOUNDCNT_H & 0x4000) == 0x4000)
419399      {
420         audio_tick(machine(), 1);
400         audio_tick(1);
421401      }
422402   }
423403
r20536r20537
433413            m_timer_regs[1] |= m_timer_reload[1];
434414            if( ( m_timer_regs[1] & 0x400000 ) && ( m_IME != 0 ) )
435415            {
436               gba_request_irq( machine(), tmr_ints[1] );
416               request_irq(tmr_ints[1]);
437417            }
438418            if( ( m_timer_regs[2] & 0x40000 ) )
439419            {
r20536r20537
443423                  m_timer_regs[2] |= m_timer_reload[2];
444424                  if( ( m_timer_regs[2] & 0x400000 ) && ( m_IME != 0 ) )
445425                  {
446                     gba_request_irq( machine(), tmr_ints[2] );
426                     request_irq(tmr_ints[2]);
447427                  }
448428                  if( ( m_timer_regs[3] & 0x40000 ) )
449429                  {
r20536r20537
453433                        m_timer_regs[3] |= m_timer_reload[3];
454434                        if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
455435                        {
456                           gba_request_irq( machine(), tmr_ints[3] );
436                           request_irq(tmr_ints[3]);
457437                        }
458438                     }
459439                  }
r20536r20537
471451            m_timer_regs[2] |= m_timer_reload[2];
472452            if( ( m_timer_regs[2] & 0x400000 ) && ( m_IME != 0 ) )
473453            {
474               gba_request_irq( machine(), tmr_ints[2] );
454               request_irq(tmr_ints[2]);
475455            }
476456            if( ( m_timer_regs[3] & 0x40000 ) )
477457            {
r20536r20537
481461                  m_timer_regs[3] |= m_timer_reload[3];
482462                  if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
483463                  {
484                     gba_request_irq( machine(), tmr_ints[3] );
464                     request_irq(tmr_ints[3]);
485465                  }
486466               }
487467            }
r20536r20537
497477            m_timer_regs[3] |= m_timer_reload[3];
498478            if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
499479            {
500               gba_request_irq( machine(), tmr_ints[3] );
480               request_irq(tmr_ints[3]);
501481            }
502482         }
503483      }
r20536r20537
507487   // are we supposed to IRQ?
508488   if ((m_timer_regs[tmr] & 0x400000) && (m_IME != 0))
509489   {
510      gba_request_irq(machine(), tmr_ints[tmr]);
490      request_irq(tmr_ints[tmr]);
511491   }
512492}
513493
514494TIMER_CALLBACK_MEMBER(gba_state::handle_irq)
515495{
516   gba_request_irq(machine(), m_IF);
496   request_irq(m_IF);
517497
518498   m_irq_timer->adjust(attotime::never);
519499}
r20536r20537
521501READ32_MEMBER(gba_state::gba_io_r)
522502{
523503   UINT32 retval = 0;
524   device_t *gb_device = machine().device("custom");
525504
526505   switch( offset )
527506   {
r20536r20537
769748         }
770749         break;
771750      case 0x0060/4:
772         retval = gb_sound_r(gb_device, space, 0) | gb_sound_r(gb_device, space, 1)<<16 | gb_sound_r(gb_device, space, 2)<<24;
751         retval = gb_sound_r(m_gbsound, space, 0) | gb_sound_r(m_gbsound, space, 1)<<16 | gb_sound_r(m_gbsound, space, 2)<<24;
773752         break;
774753      case 0x0064/4:
775         retval = gb_sound_r(gb_device, space, 3) | gb_sound_r(gb_device, space, 4)<<8;
754         retval = gb_sound_r(m_gbsound, space, 3) | gb_sound_r(m_gbsound, space, 4)<<8;
776755         break;
777756      case 0x0068/4:
778         retval = gb_sound_r(gb_device, space, 6) | gb_sound_r(gb_device, space, 7)<<8;
757         retval = gb_sound_r(m_gbsound, space, 6) | gb_sound_r(m_gbsound, space, 7)<<8;
779758         break;
780759      case 0x006c/4:
781         retval = gb_sound_r(gb_device, space, 8) | gb_sound_r(gb_device, space, 9)<<8;
760         retval = gb_sound_r(m_gbsound, space, 8) | gb_sound_r(m_gbsound, space, 9)<<8;
782761         break;
783762      case 0x0070/4:
784         retval = gb_sound_r(gb_device, space, 0xa) | gb_sound_r(gb_device, space, 0xb)<<16 | gb_sound_r(gb_device, space, 0xc)<<24;
763         retval = gb_sound_r(m_gbsound, space, 0xa) | gb_sound_r(m_gbsound, space, 0xb)<<16 | gb_sound_r(m_gbsound, space, 0xc)<<24;
785764         break;
786765      case 0x0074/4:
787         retval = gb_sound_r(gb_device, space, 0xd) | gb_sound_r(gb_device, space, 0xe)<<8;
766         retval = gb_sound_r(m_gbsound, space, 0xd) | gb_sound_r(m_gbsound, space, 0xe)<<8;
788767         break;
789768      case 0x0078/4:
790         retval = gb_sound_r(gb_device, space, 0x10) | gb_sound_r(gb_device, space, 0x11)<<8;
769         retval = gb_sound_r(m_gbsound, space, 0x10) | gb_sound_r(m_gbsound, space, 0x11)<<8;
791770         break;
792771      case 0x007c/4:
793         retval = gb_sound_r(gb_device, space, 0x12) | gb_sound_r(gb_device, space, 0x13)<<8;
772         retval = gb_sound_r(m_gbsound, space, 0x12) | gb_sound_r(m_gbsound, space, 0x13)<<8;
794773         break;
795774      case 0x0080/4:
796         retval = gb_sound_r(gb_device, space, 0x14) | gb_sound_r(gb_device, space, 0x15)<<8;
775         retval = gb_sound_r(m_gbsound, space, 0x14) | gb_sound_r(m_gbsound, space, 0x15)<<8;
797776         if( (mem_mask) & 0xffff0000 )
798777         {
799778            verboselog(machine(), 2, "GBA IO Register Read: SOUNDCNT_H (%08x) = %04x\n", 0x04000000 + ( offset << 2 ) + 2, m_SOUNDCNT_H );
r20536r20537
801780         }
802781         break;
803782      case 0x0084/4:
804         retval = gb_sound_r(gb_device, space, 0x16);
783         retval = gb_sound_r(m_gbsound, space, 0x16);
805784         break;
806785      case 0x0088/4:
807786         if( (mem_mask) & 0x0000ffff )
r20536r20537
815794         }
816795         break;
817796      case 0x0090/4:
818         retval = gb_wave_r(gb_device, space, 0) | gb_wave_r(gb_device, space, 1)<<8 | gb_wave_r(gb_device, space, 2)<<16 | gb_wave_r(gb_device, space, 3)<<24;
797         retval = gb_wave_r(m_gbsound, space, 0) | gb_wave_r(m_gbsound, space, 1)<<8 | gb_wave_r(m_gbsound, space, 2)<<16 | gb_wave_r(m_gbsound, space, 3)<<24;
819798         break;
820799      case 0x0094/4:
821         retval = gb_wave_r(gb_device, space, 4) | gb_wave_r(gb_device, space, 5)<<8 | gb_wave_r(gb_device, space, 6)<<16 | gb_wave_r(gb_device, space, 7)<<24;
800         retval = gb_wave_r(m_gbsound, space, 4) | gb_wave_r(m_gbsound, space, 5)<<8 | gb_wave_r(m_gbsound, space, 6)<<16 | gb_wave_r(m_gbsound, space, 7)<<24;
822801         break;
823802      case 0x0098/4:
824         retval = gb_wave_r(gb_device, space, 8) | gb_wave_r(gb_device, space, 9)<<8 | gb_wave_r(gb_device, space, 10)<<16 | gb_wave_r(gb_device, space, 11)<<24;
803         retval = gb_wave_r(m_gbsound, space, 8) | gb_wave_r(m_gbsound, space, 9)<<8 | gb_wave_r(m_gbsound, space, 10)<<16 | gb_wave_r(m_gbsound, space, 11)<<24;
825804         break;
826805      case 0x009c/4:
827         retval = gb_wave_r(gb_device, space, 12) | gb_wave_r(gb_device, space, 13)<<8 | gb_wave_r(gb_device, space, 14)<<16 | gb_wave_r(gb_device, space, 15)<<24;
806         retval = gb_wave_r(m_gbsound, space, 12) | gb_wave_r(m_gbsound, space, 13)<<8 | gb_wave_r(m_gbsound, space, 14)<<16 | gb_wave_r(m_gbsound, space, 15)<<24;
828807         break;
829808      case 0x00a0/4:
830809      case 0x00a4/4:
r20536r20537
10501029
10511030WRITE32_MEMBER(gba_state::gba_io_w)
10521031{
1053   device_t *gb_device = machine().device("custom");
10541032   switch( offset )
10551033   {
10561034      case 0x0000/4:
r20536r20537
13451323      case 0x0060/4:
13461324         if( (mem_mask) & 0x000000ff )   // SOUNDCNTL
13471325         {
1348            gb_sound_w(gb_device, space, 0, data);
1326            gb_sound_w(m_gbsound, space, 0, data);
13491327         }
13501328         if( (mem_mask) & 0x00ff0000 )
13511329         {
1352            gb_sound_w(gb_device, space, 1, data>>16);  // SOUND1CNT_H
1330            gb_sound_w(m_gbsound, space, 1, data>>16);   // SOUND1CNT_H
13531331         }
13541332         if( (mem_mask) & 0xff000000 )
13551333         {
1356            gb_sound_w(gb_device, space, 2, data>>24);
1334            gb_sound_w(m_gbsound, space, 2, data>>24);
13571335         }
13581336         break;
13591337      case 0x0064/4:
13601338         if( (mem_mask) & 0x000000ff )   // SOUNDCNTL
13611339         {
1362            gb_sound_w(gb_device, space, 3, data);
1340            gb_sound_w(m_gbsound, space, 3, data);
13631341         }
13641342         if( (mem_mask) & 0x0000ff00 )
13651343         {
1366            gb_sound_w(gb_device, space, 4, data>>8);   // SOUND1CNT_H
1344            gb_sound_w(m_gbsound, space, 4, data>>8);   // SOUND1CNT_H
13671345         }
13681346         break;
13691347      case 0x0068/4:
13701348         if( (mem_mask) & 0x000000ff )
13711349         {
1372            gb_sound_w(gb_device, space, 6, data);
1350            gb_sound_w(m_gbsound, space, 6, data);
13731351         }
13741352         if( (mem_mask) & 0x0000ff00 )
13751353         {
1376            gb_sound_w(gb_device, space, 7, data>>8);
1354            gb_sound_w(m_gbsound, space, 7, data>>8);
13771355         }
13781356         break;
13791357      case 0x006c/4:
13801358         if( (mem_mask) & 0x000000ff )
13811359         {
1382            gb_sound_w(gb_device, space, 8, data);
1360            gb_sound_w(m_gbsound, space, 8, data);
13831361         }
13841362         if( (mem_mask) & 0x0000ff00 )
13851363         {
1386            gb_sound_w(gb_device, space, 9, data>>8);
1364            gb_sound_w(m_gbsound, space, 9, data>>8);
13871365         }
13881366         break;
13891367      case 0x0070/4:  //SND3CNTL and H
13901368         if( (mem_mask) & 0x000000ff )   // SOUNDCNTL
13911369         {
1392            gb_sound_w(gb_device, space, 0xa, data);
1370            gb_sound_w(m_gbsound, space, 0xa, data);
13931371         }
13941372         if( (mem_mask) & 0x00ff0000 )
13951373         {
1396            gb_sound_w(gb_device, space, 0xb, data>>16);    // SOUND1CNT_H
1374            gb_sound_w(m_gbsound, space, 0xb, data>>16);   // SOUND1CNT_H
13971375         }
13981376         if( (mem_mask) & 0xff000000 )
13991377         {
1400            gb_sound_w(gb_device, space, 0xc, data>>24);
1378            gb_sound_w(m_gbsound, space, 0xc, data>>24);
14011379         }
14021380         break;
14031381      case 0x0074/4:
14041382         if( (mem_mask) & 0x000000ff )
14051383         {
1406            gb_sound_w(gb_device, space, 0xd, data);
1384            gb_sound_w(m_gbsound, space, 0xd, data);
14071385         }
14081386         if( (mem_mask) & 0x0000ff00 )
14091387         {
1410            gb_sound_w(gb_device, space, 0xe, data>>8);
1388            gb_sound_w(m_gbsound, space, 0xe, data>>8);
14111389         }
14121390         break;
14131391      case 0x0078/4:
14141392         if( (mem_mask) & 0x000000ff )
14151393         {
1416            gb_sound_w(gb_device, space, 0x10, data);
1394            gb_sound_w(m_gbsound, space, 0x10, data);
14171395         }
14181396         if( (mem_mask) & 0x0000ff00 )
14191397         {
1420            gb_sound_w(gb_device, space, 0x11, data>>8);
1398            gb_sound_w(m_gbsound, space, 0x11, data>>8);
14211399         }
14221400         break;
14231401      case 0x007c/4:
14241402         if( (mem_mask) & 0x000000ff )
14251403         {
1426            gb_sound_w(gb_device, space, 0x12, data);
1404            gb_sound_w(m_gbsound, space, 0x12, data);
14271405         }
14281406         if( (mem_mask) & 0x0000ff00 )
14291407         {
1430            gb_sound_w(gb_device, space, 0x13, data>>8);
1408            gb_sound_w(m_gbsound, space, 0x13, data>>8);
14311409         }
14321410         break;
14331411      case 0x0080/4:
14341412         if( (mem_mask) & 0x000000ff )
14351413         {
1436            gb_sound_w(gb_device, space, 0x14, data);
1414            gb_sound_w(m_gbsound, space, 0x14, data);
14371415         }
14381416         if( (mem_mask) & 0x0000ff00 )
14391417         {
1440            gb_sound_w(gb_device, space, 0x15, data>>8);
1418            gb_sound_w(m_gbsound, space, 0x15, data>>8);
14411419         }
14421420
14431421         if ((mem_mask) & 0xffff0000)
r20536r20537
14481426            // DAC A reset?
14491427            if (data & 0x0800)
14501428            {
1451               dac_device *gb_a_l = machine().device<dac_device>("direct_a_left");
1452               dac_device *gb_a_r = machine().device<dac_device>("direct_a_right");
1453
14541429               m_fifo_a_ptr = 17;
14551430               m_fifo_a_in = 17;
1456               gb_a_l->write_signed8(0x80);
1457               gb_a_r->write_signed8(0x80);
1431               m_ladac->write_signed8(0x80);
1432               m_radac->write_signed8(0x80);
14581433            }
14591434
14601435            // DAC B reset?
14611436            if (data & 0x8000)
14621437            {
1463               dac_device *gb_b_l = machine().device<dac_device>("direct_b_left");
1464               dac_device *gb_b_r = machine().device<dac_device>("direct_b_right");
1465
14661438               m_fifo_b_ptr = 17;
14671439               m_fifo_b_in = 17;
1468               gb_b_l->write_signed8(0x80);
1469               gb_b_r->write_signed8(0x80);
1440               m_lbdac->write_signed8(0x80);
1441               m_rbdac->write_signed8(0x80);
14701442            }
14711443         }
14721444         break;
14731445      case 0x0084/4:
14741446         if( (mem_mask) & 0x000000ff )
14751447         {
1476            dac_device *gb_a_l = machine().device<dac_device>("direct_a_left");
1477            dac_device *gb_a_r = machine().device<dac_device>("direct_a_right");
1478            dac_device *gb_b_l = machine().device<dac_device>("direct_b_left");
1479            dac_device *gb_b_r = machine().device<dac_device>("direct_b_right");
1480
1481            gb_sound_w(gb_device, space, 0x16, data);
1448            gb_sound_w(m_gbsound, space, 0x16, data);
14821449            if ((data & 0x80) && !(m_SOUNDCNT_X & 0x80))
14831450            {
14841451               m_fifo_a_ptr = m_fifo_a_in = 17;
14851452               m_fifo_b_ptr = m_fifo_b_in = 17;
1486               gb_a_l->write_signed8(0x80);
1487               gb_a_r->write_signed8(0x80);
1488               gb_b_l->write_signed8(0x80);
1489               gb_b_r->write_signed8(0x80);
1453               m_ladac->write_signed8(0x80);
1454               m_radac->write_signed8(0x80);
1455               m_lbdac->write_signed8(0x80);
1456               m_rbdac->write_signed8(0x80);
14901457            }
14911458            m_SOUNDCNT_X = data;
14921459         }
r20536r20537
15051472      case 0x0090/4:
15061473         if( (mem_mask) & 0x000000ff )
15071474         {
1508            gb_wave_w(gb_device, space, 0, data);
1475            gb_wave_w(m_gbsound, space, 0, data);
15091476         }
15101477         if( (mem_mask) & 0x0000ff00 )
15111478         {
1512            gb_wave_w(gb_device, space, 1, data>>8);
1479            gb_wave_w(m_gbsound, space, 1, data>>8);
15131480         }
15141481         if( (mem_mask) & 0x00ff0000 )
15151482         {
1516            gb_wave_w(gb_device, space, 2, data>>16);
1483            gb_wave_w(m_gbsound, space, 2, data>>16);
15171484         }
15181485         if( (mem_mask) & 0xff000000 )
15191486         {
1520            gb_wave_w(gb_device, space, 3, data>>24);
1487            gb_wave_w(m_gbsound, space, 3, data>>24);
15211488         }
15221489         break;
15231490      case 0x0094/4:
15241491         if( (mem_mask) & 0x000000ff )
15251492         {
1526            gb_wave_w(gb_device, space, 4, data);
1493            gb_wave_w(m_gbsound, space, 4, data);
15271494         }
15281495         if( (mem_mask) & 0x0000ff00 )
15291496         {
1530            gb_wave_w(gb_device, space, 5, data>>8);
1497            gb_wave_w(m_gbsound, space, 5, data>>8);
15311498         }
15321499         if( (mem_mask) & 0x00ff0000 )
15331500         {
1534            gb_wave_w(gb_device, space, 6, data>>16);
1501            gb_wave_w(m_gbsound, space, 6, data>>16);
15351502         }
15361503         if( (mem_mask) & 0xff000000 )
15371504         {
1538            gb_wave_w(gb_device, space, 7, data>>24);
1505            gb_wave_w(m_gbsound, space, 7, data>>24);
15391506         }
15401507         break;
15411508      case 0x0098/4:
15421509         if( (mem_mask) & 0x000000ff )
15431510         {
1544            gb_wave_w(gb_device, space, 8, data);
1511            gb_wave_w(m_gbsound, space, 8, data);
15451512         }
15461513         if( (mem_mask) & 0x0000ff00 )
15471514         {
1548            gb_wave_w(gb_device, space, 9, data>>8);
1515            gb_wave_w(m_gbsound, space, 9, data>>8);
15491516         }
15501517         if( (mem_mask) & 0x00ff0000 )
15511518         {
1552            gb_wave_w(gb_device, space, 0xa, data>>16);
1519            gb_wave_w(m_gbsound, space, 0xa, data>>16);
15531520         }
15541521         if( (mem_mask) & 0xff000000 )
15551522         {
1556            gb_wave_w(gb_device, space, 0xb, data>>24);
1523            gb_wave_w(m_gbsound, space, 0xb, data>>24);
15571524         }
15581525         break;
15591526      case 0x009c/4:
15601527         if( (mem_mask) & 0x000000ff )
15611528         {
1562            gb_wave_w(gb_device, space, 0xc, data);
1529            gb_wave_w(m_gbsound, space, 0xc, data);
15631530         }
15641531         if( (mem_mask) & 0x0000ff00 )
15651532         {
1566            gb_wave_w(gb_device, space, 0xd, data>>8);
1533            gb_wave_w(m_gbsound, space, 0xd, data>>8);
15671534         }
15681535         if( (mem_mask) & 0x00ff0000 )
15691536         {
1570            gb_wave_w(gb_device, space, 0xe, data>>16);
1537            gb_wave_w(m_gbsound, space, 0xe, data>>16);
15711538         }
15721539         if( (mem_mask) & 0xff000000 )
15731540         {
1574            gb_wave_w(gb_device, space, 0xf, data>>24);
1541            gb_wave_w(m_gbsound, space, 0xf, data>>24);
15751542         }
15761543         break;
15771544      case 0x00a0/4:
r20536r20537
16421609                  // immediate start
16431610                  if ((ctrl & 0x3000) == 0)
16441611                  {
1645                     dma_exec(machine(), ch);
1612                     dma_exec(ch);
16461613                     return;
16471614                  }
16481615               }
r20536r20537
17431710                  // request interrupt ?
17441711                  if (data & 0x4000)
17451712                  {
1746                     gba_request_irq( machine(), INT_SIO);
1713                     request_irq(INT_SIO);
17471714                  }
17481715               }
17491716            }
r20536r20537
18291796#if 0
18301797            if (m_IE & m_IF)
18311798            {
1832               gba_request_irq(machine(), m_IF);
1799               request_irq(m_IF);
18331800            }
18341801#endif
18351802         }
r20536r20537
18411808            // if we still have interrupts, yank the IRQ line again
18421809            if (m_IF)
18431810            {
1844               m_irq_timer->adjust(machine().device<cpu_device>("maincpu")->clocks_to_attotime(120));
1811               m_irq_timer->adjust(m_maincpu->clocks_to_attotime(120));
18451812            }
18461813         }
18471814         break;
r20536r20537
18841851               m_HALTCNT = data & 0x000000ff;
18851852
18861853               // either way, wait for an IRQ
1887               machine().device("maincpu")->execute().spin_until_interrupt();
1854               m_maincpu->spin_until_interrupt();
18881855            }
18891856         }
18901857         if( (mem_mask) & 0xffff0000 )
r20536r20537
19521919
19531920READ32_MEMBER(gba_state::gba_10000000_r)
19541921{
1955   UINT32 data, cpsr, pc;
1956   cpu_device *cpu = downcast<cpu_device *>(machine().device( "maincpu"));
1957   pc = cpu->state_int( ARM7_PC);
1958   cpsr = cpu->state_int( ARM7_CPSR);
1922   UINT32 data;
1923   UINT32 pc = m_maincpu->state_int( ARM7_PC);
1924   UINT32 cpsr = m_maincpu->state_int( ARM7_CPSR);
19591925   if (T_IS_SET( cpsr))
19601926   {
19611927      data = space.read_dword( pc + 8);
r20536r20537
20121978   m_DISPSTAT |= DISPSTAT_HBL;
20131979   if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
20141980   {
2015      gba_request_irq(machine(), INT_HBL);
1981      request_irq(INT_HBL);
20161982   }
20171983
20181984   for (ch = 0; ch < 4; ch++)
r20536r20537
20221988      // HBL-triggered DMA?
20231989      if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x2000))
20241990      {
2025         dma_exec(machine(), ch);
1991         dma_exec(ch);
20261992      }
20271993   }
20281994
r20536r20537
20542020      m_DISPSTAT |= DISPSTAT_VCNT;
20552021      if (m_DISPSTAT & DISPSTAT_VCNT_IRQ_EN)
20562022      {
2057         gba_request_irq(machine(), INT_VCNT);
2023         request_irq(INT_VCNT);
20582024      }
20592025   }
20602026
r20536r20537
20872053
20882054      if (m_DISPSTAT & DISPSTAT_VBL_IRQ_EN)
20892055      {
2090         gba_request_irq(machine(), INT_VBL);
2056         request_irq(INT_VBL);
20912057      }
20922058
20932059      for (ch = 0; ch < 4; ch++)
r20536r20537
20972063         // VBL-triggered DMA?
20982064         if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x1000))
20992065         {
2100            dma_exec(machine(), ch);
2066            dma_exec(ch);
21012067         }
21022068      }
21032069   }
r20536r20537
21082074
21092075void gba_state::machine_reset()
21102076{
2111   dac_device *gb_a_l = machine().device<dac_device>("direct_a_left");
2112   dac_device *gb_a_r = machine().device<dac_device>("direct_a_right");
2113   dac_device *gb_b_l = machine().device<dac_device>("direct_b_left");
2114   dac_device *gb_b_r = machine().device<dac_device>("direct_b_right");
2115
21162077   //memset(this, 0, sizeof(this));
21172078   m_SOUNDBIAS = 0x0200;
21182079   m_eeprom_state = EEP_IDLE;
r20536r20537
21462107   m_fifo_a_in = m_fifo_b_in = 17;
21472108
21482109   // and clear the DACs
2149   gb_a_l->write_signed8(0x80);
2150   gb_a_r->write_signed8(0x80);
2151   gb_b_l->write_signed8(0x80);
2152   gb_b_r->write_signed8(0x80);
2110   m_ladac->write_signed8(0x80);
2111   m_radac->write_signed8(0x80);
2112   m_lbdac->write_signed8(0x80);
2113   m_rbdac->write_signed8(0x80);
21532114
21542115   if (m_flash_battery_load != 0)
21552116   {
r20536r20537
23812342
23822343         if (m_eeprom_bits == 0)
23832344         {
2384            mame_printf_verbose("%08x: EEPROM: %02x to %x\n", machine().device("maincpu")->safe_pc(), m_eep_data, m_eeprom_addr );
2345            mame_printf_verbose("%08x: EEPROM: %02x to %x\n", space.device().safe_pc(), m_eep_data, m_eeprom_addr );
23852346            if (m_eeprom_addr >= sizeof( m_gba_eeprom))
23862347            {
23872348               fatalerror( "eeprom: invalid address (%x)\n", m_eeprom_addr);
r20536r20537
31923153
31933154DRIVER_INIT_MEMBER(gba_state,gbadv)
31943155{
3195   machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(gba_state::gba_direct), this));
3156   ((device_t*)m_maincpu)->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(gba_state::gba_direct), this));
31963157}
31973158
31983159/*    YEAR  NAME PARENT COMPAT MACHINE INPUT   INIT   COMPANY     FULLNAME */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team