Previous 199869 Revisions Next

r20483 Saturday 26th January, 2013 at 12:27:52 UTC by Wilbert Pol
(MESS) pokemini.c: Cleanups (nw)
[src/mess/includes]pokemini.h
[src/mess/machine]pokemini.c

trunk/src/mess/machine/pokemini.c
r20482r20483
1010#include "includes/pokemini.h"
1111
1212
13static void pokemini_check_irqs( running_machine &machine )
13void pokemini_state::pokemini_check_irqs()
1414{
15   pokemini_state *state = machine.driver_data<pokemini_state>();
1615   int irq_set[4] = { 1, 0, 0, 0 };
1716   int prio, vector;
1817
1918   /* Check IRQ $03-$04 */
20   prio = ( state->m_pm_reg[0x20] >> 6 ) & 0x03;
19   prio = ( m_pm_reg[0x20] >> 6 ) & 0x03;
2120   if ( ! irq_set[prio] )
2221   {
23      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x40 )
22      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x40 )
2423         irq_set[prio] = 0x04;
2524
26      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x80 )
25      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x80 )
2726         irq_set[prio] = 0x03;
2827   }
2928
3029   /* Check IRQ $05-$06 */
31   prio = ( state->m_pm_reg[0x20] >> 4 ) & 0x03;
30   prio = ( m_pm_reg[0x20] >> 4 ) & 0x03;
3231   if ( ! irq_set[prio] )
3332   {
34      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x10 )
33      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x10 )
3534         irq_set[prio] = 0x06;
3635
37      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x20 )
36      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x20 )
3837         irq_set[prio] = 0x05;
3938   }
4039
4140   /* Check IRQ $07-$08 */
42   prio = ( state->m_pm_reg[0x20] >> 2 ) & 0x03;
41   prio = ( m_pm_reg[0x20] >> 2 ) & 0x03;
4342   if ( ! irq_set[prio] )
4443   {
45      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x04 )
44      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x04 )
4645         irq_set[prio] = 0x08;
4746
48      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x08 )
47      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x08 )
4948         irq_set[prio] = 0x07;
5049   }
5150
5251   /* Check IRQ $09-$0A */
53   prio = ( state->m_pm_reg[0x20] >> 0 ) & 0x03;
52   prio = ( m_pm_reg[0x20] >> 0 ) & 0x03;
5453   if ( ! irq_set[prio] )
5554   {
56      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x01 )
55      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x01 )
5756         irq_set[prio] = 0x0A;
5857
59      if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x02 )
58      if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x02 )
6059         irq_set[prio] = 0x09;
6160   }
6261
6362   /* Check IRQ $0B-$0E */
64   prio = ( state->m_pm_reg[0x21] >> 6 ) & 0x03;
63   prio = ( m_pm_reg[0x21] >> 6 ) & 0x03;
6564   if ( ! irq_set[prio] )
6665   {
67      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x04 )
66      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x04 )
6867         irq_set[prio] = 0x0E;
6968
70      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x08 )
69      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x08 )
7170         irq_set[prio] = 0x0D;
7271
73      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x10 )
72      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x10 )
7473         irq_set[prio] = 0x0C;
7574
76      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x20 )
75      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x20 )
7776         irq_set[prio] = 0x0B;
7877   }
7978
8079   /* Check IRQ $0F-$10 */
81   prio = ( state->m_pm_reg[0x22] >> 0 ) & 0x03;
80   prio = ( m_pm_reg[0x22] >> 0 ) & 0x03;
8281   if ( ! irq_set[prio] )
8382   {
84      if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x40 )
83      if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x40 )
8584         irq_set[prio] = 0x10;
8685
87      if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x80 )
86      if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x80 )
8887         irq_set[prio] = 0x0F;
8988   }
9089
9190   /* Check IRQ $13-$14 */
92   prio = ( state->m_pm_reg[0x21] >> 4 ) & 0x03;
91   prio = ( m_pm_reg[0x21] >> 4 ) & 0x03;
9392   if ( ! irq_set[prio] )
9493   {
95      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x01 )
94      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x01 )
9695         irq_set[prio] = 0x14;
9796
98      if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x02 )
97      if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x02 )
9998         irq_set[prio] = 0x13;
10099   }
101100
102101   /* Check IRQ $15-$1C */
103   prio = ( state->m_pm_reg[0x21] >> 2 ) & 0x03;
102   prio = ( m_pm_reg[0x21] >> 2 ) & 0x03;
104103   if ( ! irq_set[prio] )
105104   {
106      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x01 )
105      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x01 )
107106         irq_set[prio] = 0x1C;
108107
109      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x02 )
108      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x02 )
110109         irq_set[prio] = 0x1B;
111110
112      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x04 )
111      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x04 )
113112         irq_set[prio] = 0x1A;
114113
115      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x08 )
114      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x08 )
116115         irq_set[prio] = 0x19;
117116
118      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x10 )
117      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x10 )
119118         irq_set[prio] = 0x18;
120119
121      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x20 )
120      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x20 )
122121         irq_set[prio] = 0x17;
123122
124      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x40 )
123      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x40 )
125124         irq_set[prio] = 0x16;
126125
127      if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x80 )
126      if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x80 )
128127         irq_set[prio] = 0x15;
129128   }
130129
131130   /* Check IRQ $1D-$1F */
132   prio = ( state->m_pm_reg[0x21] >> 0 ) & 0x03;
133   if ( ! irq_set[prio] && ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x07 ) )
131   prio = ( m_pm_reg[0x21] >> 0 ) & 0x03;
132   if ( ! irq_set[prio] && ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x07 ) )
134133   {
135      if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x01 )
134      if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x01 )
136135         irq_set[prio] = 0x1F;
137136
138      if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x02 )
137      if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x02 )
139138         irq_set[prio] = 0x1E;
140139
141      if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x04 )
140      if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x04 )
142141         irq_set[prio] = 0x1D;
143142   }
144143
r20482r20483
155154   {
156155      //logerror("Triggering IRQ with vector %02x\n", vector );
157156      /* Trigger interrupt and set vector */
158      machine.device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, vector );
157      m_maincpu->set_input_line_and_vector(0, ASSERT_LINE, vector );
159158   }
160159   else
161160   {
162      machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE );
161      m_maincpu->set_input_line(0, CLEAR_LINE );
163162   }
164163}
165164
166165
167static void pokemini_update_sound( running_machine &machine )
166void pokemini_state::pokemini_update_sound()
168167{
169   pokemini_state *state = machine.driver_data<pokemini_state>();
170   device_t *speaker = machine.device(SPEAKER_TAG);
171168   /* Check if sound should be muted */
172   if ( state->m_pm_reg[0x70] & 0x03 )
169   if ( m_pm_reg[0x70] & 0x03 )
173170   {
174      speaker_level_w( speaker, 0 );
171      speaker_level_w( m_speaker, 0 );
175172   }
176173   else
177174   {
178175      ///static const int levels[4] = { 0, 1, 1, 2 };
179      int level; /// silence clang warning/// = levels[ state->m_pm_reg[0x71] & 0x03 ];
176      int level; /// silence clang warning/// = levels[ m_pm_reg[0x71] & 0x03 ];
180177
181//      if ( ( ( state->m_pm_reg[0x48] & 0x80 ) && ( state->m_pm_reg[0x4E] | ( state->m_pm_reg[0x4F] << 8 ) ) > ( state->m_pm_reg[0x4C] | ( state->m_pm_reg[0x4D] << 8 ) ) )
182//        || ( ( state->m_pm_reg[0x48] & 0x80 ) && state->m_pm_reg[0x4F] > state->m_pm_reg[0x4D] ) )
178//      if ( ( ( m_pm_reg[0x48] & 0x80 ) && ( m_pm_reg[0x4E] | ( m_pm_reg[0x4F] << 8 ) ) > ( m_pm_reg[0x4C] | ( m_pm_reg[0x4D] << 8 ) ) )
179//        || ( ( m_pm_reg[0x48] & 0x80 ) && m_pm_reg[0x4F] > m_pm_reg[0x4D] ) )
183180//      {
184181         level = 0;
185182//      }
186183
187      speaker_level_w( speaker, level );
184      speaker_level_w( m_speaker, level );
188185   }
189186}
190187
r20482r20483
234231            }
235232         }
236233
237         pokemini_check_irqs( machine() );
234         pokemini_check_irqs();
238235      }
239236   }
240237}
r20482r20483
253250         if ( m_pm_reg[0x37] == 0xFF )
254251         {
255252            m_pm_reg[0x27] |= 0x08;
256            pokemini_check_irqs( machine() );
253            pokemini_check_irqs();
257254            m_pm_reg[0x36] = m_pm_reg[0x32];
258255            m_pm_reg[0x37] = m_pm_reg[0x33];
259256         }
r20482r20483
261258      else
262259      {
263260         m_pm_reg[0x27] |= 0x04;
264         pokemini_check_irqs( machine() );
261         pokemini_check_irqs();
265262         m_pm_reg[0x36] = m_pm_reg[0x32];
266263      }
267264   }
r20482r20483
275272   if ( m_pm_reg[0x37] == 0xFF )
276273   {
277274      m_pm_reg[0x27] |= 0x08;
278      pokemini_check_irqs( machine() );
275      pokemini_check_irqs();
279276      m_pm_reg[0x37] = m_pm_reg[0x33];
280277   }
281278}
r20482r20483
294291         if ( m_pm_reg[0x3F] == 0xFF )
295292         {
296293            m_pm_reg[0x27] |= 0x20;
297            pokemini_check_irqs( machine() );
294            pokemini_check_irqs();
298295            m_pm_reg[0x3E] = m_pm_reg[0x3A];
299296            m_pm_reg[0x3F] = m_pm_reg[0x3B];
300297         }
r20482r20483
302299      else
303300      {
304301         m_pm_reg[0x27] |= 0x10;
305         pokemini_check_irqs( machine() );
302         pokemini_check_irqs();
306303         m_pm_reg[0x3E] = m_pm_reg[0x3A];
307304      }
308305   }
r20482r20483
316313   if ( m_pm_reg[0x3F] == 0xFF )
317314   {
318315      m_pm_reg[0x27] |= 0x20;
319      pokemini_check_irqs( machine() );
316      pokemini_check_irqs();
320317      m_pm_reg[0x3F] = m_pm_reg[0x3B];
321318   }
322319}
r20482r20483
335332         if ( m_pm_reg[0x4F] == 0xFF )
336333         {
337334            m_pm_reg[0x27] |= 0x02;
338            pokemini_check_irqs( machine() );
335            pokemini_check_irqs();
339336            m_pm_reg[0x4E] = m_pm_reg[0x4A];
340337            m_pm_reg[0x4F] = m_pm_reg[0x4B];
341338         }
r20482r20483
351348      if (  ( m_pm_reg[0x4E] == m_pm_reg[0x4C] ) && ( m_pm_reg[0x4F] == m_pm_reg[0x4D] ) )
352349      {
353350         m_pm_reg[0x27] |= 0x01;
354         pokemini_check_irqs( machine() );
351         pokemini_check_irqs();
355352      }
356      pokemini_update_sound( machine() );
353      pokemini_update_sound();
357354   }
358355}
359356
r20482r20483
365362   if ( m_pm_reg[0x4F] == 0xFF )
366363   {
367364      m_pm_reg[0x27] |= 0x02;
368      pokemini_check_irqs( machine() );
365      pokemini_check_irqs();
369366      m_pm_reg[0x4F] = m_pm_reg[0x4B];
370367   }
371368
r20482r20483
374371      if( m_pm_reg[0x4F] == m_pm_reg[0x4D] )
375372      {
376373         m_pm_reg[0x27] |= 0x01;
377         pokemini_check_irqs( machine() );
374         pokemini_check_irqs();
378375      }
379      pokemini_update_sound( machine() );
376      pokemini_update_sound();
380377   }
381378}
382379
r20482r20483
454451         int index = data & 0x07;
455452         int cycles = ( m_pm_reg[0x19] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
456453
457         m_timers.timer1->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
454         m_timers.timer1->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
458455      }
459456
460457      /* Check for prescaler change for the high counter */
r20482r20483
463460         int index = ( data >> 4 ) & 0x07;
464461         int cycles = ( m_pm_reg[0x19] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
465462
466         m_timers.timer1_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
463         m_timers.timer1_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
467464      }
468465
469466      /* Check if timer1 low should be enabled */
r20482r20483
504501         int index = m_pm_reg[0x18] & 0x07;
505502         int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
506503
507         m_timers.timer1->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
504         m_timers.timer1->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
508505      }
509506
510507      /* Check for prescaler change for the low counter */
r20482r20483
513510         int index = ( m_pm_reg[0x18] >> 4 ) & 0x07;
514511         int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
515512
516         m_timers.timer1_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
513         m_timers.timer1_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
517514      }
518515
519516      {
r20482r20483
583580         int index = data & 0x07;
584581         int cycles = ( m_pm_reg[0x1B] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
585582
586         m_timers.timer2->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
583         m_timers.timer2->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
587584      }
588585
589586      /* Check for prescaler change for the high counter */
r20482r20483
592589         int index = ( data >> 4 ) & 0x07;
593590         int cycles = ( m_pm_reg[0x1B] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
594591
595         m_timers.timer2_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
592         m_timers.timer2_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
596593      }
597594
598595      /* Check if timer2 low should be enabled */
r20482r20483
629626         int index = m_pm_reg[0x1A] & 0x07;
630627         int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
631628
632         m_timers.timer2->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
629         m_timers.timer2->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
633630
634631         if ( ( m_pm_reg[0x1A] & 0x08 ) && ( m_pm_reg[0x38] & 0x04 ) &&
635632               ( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) ||
r20482r20483
649646         int index = ( m_pm_reg[0x1A] >> 4 ) & 0x07;
650647         int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
651648
652         m_timers.timer2_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
649         m_timers.timer2_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
653650
654651         if ( ( m_pm_reg[0x1A] & 0x80 ) && ( m_pm_reg[0x39] & 0x04 ) && ! ( m_pm_reg[0x38] & 0x80 ) &&
655652               ( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) ||
r20482r20483
683680         int index = data & 0x07;
684681         int cycles = ( m_pm_reg[0x1D] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
685682
686         m_timers.timer3->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
683         m_timers.timer3->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
687684      }
688685
689686      /* Check for prescaler change for the high counter */
r20482r20483
692689         int index = ( data >> 4 ) & 0x07;
693690         int cycles = ( m_pm_reg[0x1D] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
694691
695         m_timers.timer3_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
692         m_timers.timer3_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
696693      }
697694
698695      /* Check if timer2 low should be enabled */
r20482r20483
729726         int index = m_pm_reg[0x1C] & 0x07;
730727         int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
731728
732         m_timers.timer3->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
729         m_timers.timer3->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
733730
734731         if ( ( m_pm_reg[0x1C] & 0x08 ) && ( m_pm_reg[0x48] & 0x04 ) &&
735732               ( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) ||
r20482r20483
749746         int index = ( m_pm_reg[0x1C] >> 4 ) & 0x07;
750747         int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
751748
752         m_timers.timer3_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
749         m_timers.timer3_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
753750
754751         if ( ( m_pm_reg[0x1C] & 0x80 ) && ( m_pm_reg[0x49] & 0x04 ) && ! ( m_pm_reg[0x48] & 0x80 ) &&
755752               ( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) ||
r20482r20483
770767               Bit 6-7 R/W VDraw/VBlank trigger Interrupt #1-#2
771768            */
772769      m_pm_reg[0x20] = data;
773      pokemini_check_irqs(machine());
770      pokemini_check_irqs();
774771      break;
775772   case 0x21:  /* Event #15-#22 priority
776773               Bit 0-1 R/W Unknown
r20482r20483
778775               Bit 4-7 R/W Unknown
779776            */
780777      m_pm_reg[0x21] = data;
781      pokemini_check_irqs(machine());
778      pokemini_check_irqs();
782779      break;
783780   case 0x22:  /* Event #9-#14 priority
784781               Bit 0-1 R/W All #9 - #14 events - Interrupt #9-#14
785782               Bit 2-7     Unused
786783            */
787784      m_pm_reg[0x22] = data;
788      pokemini_check_irqs(machine());
785      pokemini_check_irqs();
789786      break;
790787   case 0x23:  /* Event #1-#8 enable
791788               Bit 0   R/W Timer 3 overflow (mirror) - Enable Interrupt #8
r20482r20483
798795               Bit 7   R/W V-Blank trigger - Enable Interrupt #1
799796            */
800797      m_pm_reg[0x23] = data;
801      pokemini_check_irqs(machine());
798      pokemini_check_irqs();
802799      break;
803800   case 0x24:  /* Event #9-#12 enable
804801               Bit 0-5 R/W Unknown
805802               Bit 6-7     Unused
806803            */
807804      m_pm_reg[0x24] = data;
808      pokemini_check_irqs(machine());
805      pokemini_check_irqs();
809806      break;
810807   case 0x25:  /* Event #15-#22 enable
811808               Bit 0   R/W Press key "A" event - Enable interrupt #22
r20482r20483
818815               Bit 7   R/W Press power button event - Enable interrupt #15
819816            */
820817      m_pm_reg[0x25] = data;
821      pokemini_check_irqs(machine());
818      pokemini_check_irqs();
822819      break;
823820   case 0x26:  /* Event #13-#14 enable
824821               Bit 0-2 R/W Unknown
r20482r20483
828825               Bit 7   R/W IR receiver - low to high trigger - Enable interrupt #13
829826            */
830827      m_pm_reg[0x26] = data;
831      pokemini_check_irqs(machine());
828      pokemini_check_irqs();
832829      break;
833830   case 0x27:  /* Interrupt active flag #1-#8
834831               Bit 0       Timer 3 overflow (mirror) / Clear interrupt #8
r20482r20483
841838               Bit 7       VBlank trigger / Clear interrupt #1
842839            */
843840      m_pm_reg[0x27] &= ~data;
844      pokemini_check_irqs(machine());
841      pokemini_check_irqs();
845842      return;
846843   case 0x28:  /* Interrupt active flag #9-#12
847844               Bit 0-1     Unknown
r20482r20483
852849               Bit 6-7     Unknown
853850            */
854851      m_pm_reg[0x28] &= ~data;
855      pokemini_check_irqs(machine());
852      pokemini_check_irqs();
856853      return;
857854   case 0x29:  /* Interrupt active flag #15-#22
858855               Bit 0       Press key "A" event / Clear interrupt #22
r20482r20483
865862               Bit 7       Press power button event / Clear interrupt #15
866863            */
867864      m_pm_reg[0x29] &= ~data;
868      pokemini_check_irqs(machine());
865      pokemini_check_irqs();
869866      return;
870867   case 0x2A:  /* Interrupt active flag #13-#14
871868               Bit 0-5     Unknown
r20482r20483
873870               Bit 7       Unknown / Clear interrupt #13
874871            */
875872      m_pm_reg[0x2A] &= ~data;
876      pokemini_check_irqs(machine());
873      pokemini_check_irqs();
877874      return;
878875   case 0x30:  /* Timer 1 control 1
879876               Bit 0   R/W Unknown
r20482r20483
947944            */
948945   case 0x35:  /* Timer 1 sound-pivot (high, unused)
949946            */
950      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", machine().firstcpu->pc( ), offset, data );
947      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", m_maincpu->pc(), offset, data );
951948      break;
952949   case 0x36:  /* Timer 1 counter (low), read only
953950            */
r20482r20483
10261023            */
10271024   case 0x3D:  /* Timer 2 sound-pivot (high, unused)
10281025            */
1029      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", machine().firstcpu->pc( ), offset, data );
1026      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", m_maincpu->pc(), offset, data );
10301027      break;
10311028   case 0x3E:  /* Timer 2 counter (low), read only
10321029               Bit 0-7 R/W Timer 2 counter value bit 0-7
r20482r20483
10861083         m_timers.timer3_hi->enable( 0 );
10871084      }
10881085      m_pm_reg[0x48] = data;
1089      pokemini_update_sound(machine());
1086      pokemini_update_sound();
10901087      break;
10911088   case 0x49:  /* Timer 3 control 2
10921089               Bit 0   R/W Unknown
r20482r20483
11121109         m_timers.timer3_hi->enable( 0 );
11131110      }
11141111      m_pm_reg[0x49] = data;
1115      pokemini_update_sound(machine());
1112      pokemini_update_sound();
11161113      break;
11171114   case 0x4A:  /* Timer 3 preset value (low)
11181115               Bit 0-7 R/W Timer 3 preset value bit 0-7
11191116            */
11201117      m_pm_reg[0x4A] = data;
1121      pokemini_update_sound(machine());
1118      pokemini_update_sound();
11221119      break;
11231120   case 0x4B:  /* Timer 3 preset value (high)
11241121               Bit 0-7 R/W Timer 3 preset value bit 8-15
11251122            */
11261123      m_pm_reg[0x4B] = data;
1127      pokemini_update_sound(machine());
1124      pokemini_update_sound();
11281125      break;
11291126   case 0x4C:  /* Timer 3 sound-pivot (low)
11301127               Bit 0-7 R/W Timer 3 sound-pivot value bit 0-7
11311128            */
11321129      m_pm_reg[0x4C] = data;
1133      pokemini_update_sound(machine());
1130      pokemini_update_sound();
11341131      break;
11351132   case 0x4D:  /* Timer 3 sound-pivot (high)
11361133               Bit 0-7 R/W Timer 3 sound-pivot value bit 8-15
r20482r20483
11411138               Pulse-Width of 100% = Same as preset-value
11421139            */
11431140      m_pm_reg[0x4D] = data;
1144      pokemini_update_sound(machine());
1141      pokemini_update_sound();
11451142      break;
11461143   case 0x4E:  /* Timer 3 counter (low), read only
11471144               Bit 0-7 R/W Timer 3 counter value bit 0-7
r20482r20483
11841181               Bit 7   R/W IR received bit (mirror, if device not selected: 0)
11851182            */
11861183      if ( m_pm_reg[0x60] & 0x04 )
1187         i2cmem_sda_write(machine().device("i2cmem"), ( data & 0x04 ) ? 1 : 0 );
1184         m_i2cmem->set_sda_line( ( data & 0x04 ) ? 1 : 0 );
11881185
11891186      if ( m_pm_reg[0x60] & 0x08 )
1190         i2cmem_scl_write(machine().device("i2cmem"), ( data & 0x08 ) ? 1 : 0 );
1187         m_i2cmem->set_scl_line( ( data & 0x08 ) ? 1 : 0 );
11911188      break;
11921189   case 0x70:  /* Sound related */
11931190      m_pm_reg[0x70] = data;
1194      pokemini_update_sound(machine());
1191      pokemini_update_sound();
11951192      break;
11961193   case 0x71:  /* Sound volume
11971194               Bit 0-1 R/W Sound volume
r20482r20483
12031200               Bit 3-7     Unused
12041201            */
12051202      m_pm_reg[0x71] = data;
1206      pokemini_update_sound(machine());
1203      pokemini_update_sound();
12071204      break;
12081205   case 0x80:  /* LCD control
12091206               Bit 0   R/W Invert colors; 0 - normal, 1 - inverted
r20482r20483
13441341
13451342   switch( offset )
13461343   {
1347   case 0x52:  return ioport("INPUTS")->read();
1344   case 0x52:  return m_inputs->read();
13481345   case 0x61:
13491346      if ( ! ( m_pm_reg[0x60] & 0x04 ) )
13501347      {
1351         data = ( data & ~ 0x04 ) | ( i2cmem_sda_read( machine().device("i2cmem")) ? 0x04 : 0x00 );
1348         data = ( data & ~ 0x04 ) | ( m_i2cmem->read_sda_line() ? 0x04 : 0x00 );
13521349      }
13531350
13541351      if ( ! ( m_pm_reg[0x60] & 0x08 ) )
r20482r20483
14051402
14061403TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback)
14071404{
1408   address_space &space = machine().device( "maincpu")->memory().space( AS_PROGRAM );
1405   address_space &space = m_maincpu->space( AS_PROGRAM );
14091406   m_prc.count++;
14101407
14111408   /* Check for overflow */
r20482r20483
15111508
15121509         /* Set PRC Render interrupt */
15131510         m_pm_reg[0x27] |= 0x40;
1514         pokemini_check_irqs( machine() );
1511         pokemini_check_irqs();
15151512
15161513         /* Check if the rendered data should be copied to the LCD */
15171514         if ( m_prc.copy_enabled )
r20482r20483
15351532
15361533            /* Set PRC Copy interrupt */
15371534            m_pm_reg[0x27] |= 0x80;
1538            pokemini_check_irqs( machine() );
1535            pokemini_check_irqs();
15391536         }
15401537      }
15411538
15421539      /* Set possible input irqs */
1543      m_pm_reg[0x29] |= ~ machine().root_device().ioport( "INPUTS" )->read();
1540      m_pm_reg[0x29] |= ~ m_inputs->read();
15441541   }
15451542}
15461543
trunk/src/mess/includes/pokemini.h
r20482r20483
4848{
4949public:
5050   pokemini_state(const machine_config &mconfig, device_type type, const char *tag)
51      : driver_device(mconfig, type, tag),
52   m_maincpu(*this, "maincpu")
53   ,
54      m_p_ram(*this, "p_ram"){ }
51      : driver_device(mconfig, type, tag)
52      , m_maincpu(*this, "maincpu")
53      , m_p_ram(*this, "p_ram")
54      , m_speaker(*this, SPEAKER_TAG)
55      , m_i2cmem(*this, "i2cmem")
56      , m_inputs(*this, "INPUTS")
57   { }
5558
5659   required_device<cpu_device> m_maincpu;
5760   required_shared_ptr<UINT8> m_p_ram;
r20482r20483
7578   TIMER_CALLBACK_MEMBER(pokemini_prc_counter_callback);
7679   DECLARE_WRITE8_MEMBER(pokemini_hwreg_w);
7780   DECLARE_READ8_MEMBER(pokemini_hwreg_r);
81
82protected:
83   required_device<speaker_sound_device> m_speaker;
84   required_device<i2cmem_device> m_i2cmem;
85   required_ioport m_inputs;
86
87   void pokemini_check_irqs();
88   void pokemini_update_sound();
7889};
7990
8091

Previous 199869 Revisions Next


© 1997-2024 The MAME Team