Previous 15994 Revisions Next

r1348 Wednesday 28th November, 2007 at 13:10:47 UTC by Curt Coder
[ATARIST] Some refactoring and optimization, ST boots 6 seconds faster now!
[src/mess/machine]68901mfp.c
[src/mess/video]atarist.c

src/mess/video/atarist.c
r1347r1348
3737static emu_timer *atarist_glue_timer;
3838static emu_timer *atarist_shifter_timer;
3939
40pen_t INLINE atarist_shift_mode_0(void)
40INLINE pen_t atarist_shift_mode_0(void)
4141{
4242   int color = (BIT(shifter.rr[3], 15) << 3) | (BIT(shifter.rr[2], 15) << 2) | (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15);
4343
r1347r1348
4949   return Machine->pens[color];
5050}
5151
52pen_t INLINE atarist_shift_mode_1(void)
52INLINE pen_t atarist_shift_mode_1(void)
5353{
5454   int color = (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15);
5555
r1347r1348
6868   return Machine->pens[color];
6969}
7070
71pen_t INLINE atarist_shift_mode_2(void)
71INLINE pen_t atarist_shift_mode_2(void)
7272{
7373   int color = BIT(shifter.rr[0], 15);
7474
r1347r1348
125125   *BITMAP_ADDR32(tmpbitmap, y, x) = pen;
126126}
127127
128void INLINE atarist_shifter_load(void)
128INLINE void atarist_shifter_load(void)
129129{
130130   UINT8 *RAM = memory_region(REGION_CPU1) + shifter.ofs;
131131
src/mess/machine/68901mfp.c
r1347r1348
44
55   - poll TAI/TBI pins
66   - daisy chaining
7   - correct irq_timer period
7   - correct gpio_timer period
88   - disable GPIO3/4 interrupts when timer A/B in pulse mode
99   - spurious interrupt
1010
r1347r1348
4545
4646   UINT16 ier, ipr, isr, imr;
4747   UINT8 vr;
48   emu_timer *irq_timer;
48   int irqlevel;
4949
5050   UINT8 tacr, tbcr, tcdcr;
5151   UINT8 tdr[MFP68901_MAX_TIMERS];
r1347r1348
6363   int   rx_parity, tx_parity;
6464   int   rx_state, tx_state, xmit_state;
6565   int rxtx_word, rxtx_start, rxtx_stop;
66
67   emu_timer *rx_timer, *tx_timer;
6866} mfp_68901;
6967
7068static mfp_68901 mfp[MAX_MFP];
r1347r1348
9290
9391static const int PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
9492
95static void mfp68901_check_interrupts(int which)
93INLINE void mfp68901_check_interrupts(int which)
9694{
9795   mfp_68901 *mfp_p = &mfp[which];
9896
99   int intr = (mfp_p->ipr & mfp_p->imr) ? HOLD_LINE : CLEAR_LINE;
100   mfp_p->intf->irq_callback(which, intr);
97   int irqlevel = (mfp_p->ipr & mfp_p->imr) ? HOLD_LINE : CLEAR_LINE;
98
99   if (irqlevel != mfp_p->irqlevel)
100   {
101      mfp_p->intf->irq_callback(which, irqlevel);
102   }
101103}
102104
103static void mfp68901_poll_gpio(int which)
105INLINE void mfp68901_interrupt(int which, UINT16 mask)
104106{
105107   mfp_68901 *mfp_p = &mfp[which];
106108
107   UINT8 gpio = 0, gpold, gpnew;
108   int bit;
109   mfp_p->ipr |= mask;
109110
110   if (mfp_p->intf->gpio_r)
111   {
112      gpio = mfp_p->intf->gpio_r(0); // read the state of GPIO the pins from the driver
113   }
111   mfp68901_check_interrupts(which);
112}
114113
115   gpold = (mfp_p->gpip & ~mfp_p->ddr) ^ mfp_p->aer;
116   gpnew = (gpio & ~mfp_p->ddr) ^ mfp_p->aer;
114static TIMER_CALLBACK( mfp68901_gpio_poll_tick )
115{
116   mfp_68901 *mfp_p = &mfp[param];
117117
118   UINT8 gpio = mfp_p->intf->gpio_r(0);
119
120   UINT8 gpold = (mfp_p->gpip & ~mfp_p->ddr) ^ mfp_p->aer;
121   UINT8 gpnew = (gpio & ~mfp_p->ddr) ^ mfp_p->aer;
122
123   int bit;
124
118125   for (bit = 0; bit < 8; bit++) // loop thru each bit from 0 to 7
119126   {
120127      if ((BIT(gpold, bit) == 1) && (BIT(gpnew, bit) == 0)) // if transition from 1 to 0 is detected...
121128      {
122         logerror("MFP68901 #%u Edge Transition Detected on GPIO%u\n", which, bit);
129         logerror("MFP68901 #%u Edge Transition Detected on GPIO%u\n", param, bit);
123130
124131         if (mfp_p->ier & MFP68901_INT_MASK_GPIO[bit]) // AND interrupt enabled bit is set...
125132         {
126            logerror("MFP68901 #%u Interrupt Pending for GPIO%u\n", which, bit);
133            logerror("MFP68901 #%u Interrupt Pending for GPIO%u\n", param, bit);
127134
128            mfp_p->ipr |= MFP68901_INT_MASK_GPIO[bit]; // set interrupt pending bit
135            mfp68901_interrupt(param, MFP68901_INT_MASK_GPIO[bit]); // set interrupt pending bit
129136         }
130137      }
131138   }
r1347r1348
133140   mfp_p->gpip = (gpio & ~mfp_p->ddr) | (mfp_p->gpip & mfp_p->ddr);
134141}
135142
136static TIMER_CALLBACK( mfp68901_tick )
137{
138   mfp68901_poll_gpio(param);
139   mfp68901_check_interrupts(param);
140}
141
142143/* USART */
143144
144static void mfp68901_rx_buffer_full(int which)
145INLINE void mfp68901_rx_buffer_full(int which)
145146{
146147   mfp_68901 *mfp_p = &mfp[which];
147148
148149   if (mfp_p->ier & MFP68901_IR_RCV_BUFFER_FULL)
149150   {
150      mfp_p->ipr |= MFP68901_IR_RCV_BUFFER_FULL;
151      mfp68901_interrupt(which, MFP68901_IR_RCV_BUFFER_FULL);
151152   }
152153}
153154
154static void mfp68901_rx_error(int which)
155INLINE void mfp68901_rx_error(int which)
155156{
156157   mfp_68901 *mfp_p = &mfp[which];
157158
158159   if (mfp_p->ier & MFP68901_IR_RCV_ERROR)
159160   {
160      mfp_p->ipr |= MFP68901_IR_RCV_ERROR;
161      mfp68901_interrupt(which, MFP68901_IR_RCV_ERROR);
161162   }
162163   else
163164   {
r1347r1348
165166   }
166167}
167168
168static void mfp68901_tx_buffer_empty(int which)
169INLINE void mfp68901_tx_buffer_empty(int which)
169170{
170171   mfp_68901 *mfp_p = &mfp[which];
171172
172173   if (mfp_p->ier & MFP68901_IR_XMIT_BUFFER_EMPTY)
173174   {
174      mfp_p->ipr |= MFP68901_IR_XMIT_BUFFER_EMPTY;
175      mfp68901_interrupt(which, MFP68901_IR_XMIT_BUFFER_EMPTY);
175176   }
176177}
177178
178static void mfp68901_tx_error(int which)
179INLINE void mfp68901_tx_error(int which)
179180{
180181   mfp_68901 *mfp_p = &mfp[which];
181182
182183   if (mfp_p->ier & MFP68901_IR_XMIT_ERROR)
183184   {
184      mfp_p->ipr |= MFP68901_IR_XMIT_ERROR;
185      mfp68901_interrupt(which, MFP68901_IR_XMIT_ERROR);
185186   }
186187   else
187188   {
r1347r1348
189190   }
190191}
191192
192static int mfp68901_parity(UINT8 b)
193INLINE int mfp68901_parity(UINT8 b)
193194{
194195   b ^= b >> 4;
195196   b ^= b >> 2;
r1347r1348
197198   return b & 1;
198199}
199200
200static TIMER_CALLBACK( rx_tick )
201INLINE void mfp68901_serial_rx(int which)
201202{
202   mfp_68901 *mfp_p = &mfp[param];
203   mfp_68901 *mfp_p = &mfp[which];
203204
204205   if (mfp_p->rsr & MFP68901_RSR_RCV_ENABLE)
205206   {
r1347r1348
274275                     // incoming word received and receive buffer is empty
275276                     mfp_p->rsr |= MFP68901_RSR_BUFFER_FULL;
276277                     mfp_p->udr = mfp_p->rx_buffer;
277                     mfp68901_rx_buffer_full(param);
278                     mfp68901_rx_buffer_full(which);
278279                  }
279280               }
280281            }
r1347r1348
294295   }
295296}
296297
297static void mfp68901_transmit_disabled(int which)
298static TIMER_CALLBACK( rx_tick )
298299{
300   mfp68901_serial_rx(param);
301}
302
303INLINE void mfp68901_transmit_disabled(int which)
304{
299305   mfp_68901 *mfp_p = &mfp[which];
300306
301307   switch (mfp_p->tsr & MFP68901_TSR_OUTPUT_MASK)
r1347r1348
313319   }
314320}
315321
316static void mfp68901_transmit(int which)
322INLINE void mfp68901_transmit(int which)
317323{
318324   mfp_68901 *mfp_p = &mfp[which];
319325
r1347r1348
419425   }
420426}
421427
422static TIMER_CALLBACK( tx_tick )
428INLINE void mfp68901_serial_tx(int which)
423429{
424   mfp_68901 *mfp_p = &mfp[param];
430   mfp_68901 *mfp_p = &mfp[which];
425431
426432   switch (mfp_p->xmit_state)
427433   {
428434   case MFP68901_XMIT_OFF:
429      mfp68901_transmit_disabled(param);
435      mfp68901_transmit_disabled(which);
430436      break;
431437
432438   case MFP68901_XMIT_STARTING:
r1347r1348
462468      break;
463469
464470   case MFP68901_XMIT_ON:
465      mfp68901_transmit(param);
471      mfp68901_transmit(which);
466472      break;
467473   }
468474}
469475
476static TIMER_CALLBACK( tx_tick )
477{
478   mfp68901_serial_tx(param);
479}
480
470481static UINT8 mfp68901_register_r(int which, int reg)
471482{
472483   mfp_68901 *mfp_p = &mfp[which];
r1347r1348
976987   }
977988}
978989
979void mfp68901_timer_count(int which, int index)
990INLINE void mfp68901_timer_count(int which, int index)
980991{
981992   mfp_68901 *mfp_p = &mfp[which];
982993
r1347r1348
988999      {
9891000         if (mfp_p->intf->rx_clock == MFP68901_LOOPBACK_TIMER[index])
9901001         {
991            timer_adjust(mfp_p->rx_timer, attotime_zero, which, attotime_never);
1002            mfp68901_serial_rx(which);
9921003         }
9931004
9941005         if (mfp_p->intf->tx_clock == MFP68901_LOOPBACK_TIMER[index])
9951006         {
996            timer_adjust(mfp_p->tx_timer, attotime_zero, which, attotime_never);
1007            mfp68901_serial_tx(which);
9971008         }
9981009      }
9991010
r1347r1348
10041015
10051016      if (mfp_p->ier & MFP68901_INT_MASK_TIMER[index])
10061017      {
1007         mfp_p->ipr |= MFP68901_INT_MASK_TIMER[index];
1018         mfp68901_interrupt(which, MFP68901_INT_MASK_TIMER[index]);
10081019      }
10091020
10101021      mfp_p->tmc[index] = mfp_p->tdr[index];
r1347r1348
10151026   }
10161027}
10171028
1018void mfp68901_ti_w(int which, int index, int value)
1029INLINE void mfp68901_ti_w(int which, int index, int value)
10191030{
10201031   mfp_68901 *mfp_p = &mfp[which];
1032
10211033   int bit = MFP68901_GPIO_TIMER[index];
10221034   int aer = BIT(mfp_p->aer, bit);
10231035   int cr = index ? mfp_p->tbcr : mfp_p->tacr;
r1347r1348
10401052   case MFP68901_TCR_TIMER_PULSE_64:
10411053   case MFP68901_TCR_TIMER_PULSE_100:
10421054   case MFP68901_TCR_TIMER_PULSE_200:
1043      timer_enable(mfp_p->timer[index], (value == aer) ? 1 : 0);
1055      timer_enable(mfp_p->timer[index], (value == aer));
10441056
10451057      if (((mfp_p->ti[index] ^ aer) == 0) && ((value ^ aer) == 1))
10461058      {
10471059         if (mfp_p->ier & MFP68901_INT_MASK_GPIO[bit])
10481060         {
1049            mfp_p->ipr |= MFP68901_INT_MASK_GPIO[bit];
1061            mfp68901_interrupt(which, MFP68901_INT_MASK_GPIO[bit]);
10501062         }
10511063      }
10521064
r1347r1348
11031115         }
11041116
11051117         mfp_p->ipr &= ~(1 << ch);
1106
11071118         mfp68901_check_interrupts(which);
11081119
11091120         return (mfp_p->vr & 0xf0) | ch;
r1347r1348
11391150{
11401151   mfp_68901 *mfp_p = &mfp[which];
11411152
1142   if (which >= MAX_MFP)
1143   {
1144      return;
1145   }
1153   assert(which < MAX_MFP);
11461154
1155   // initial settings
1156
11471157   memset(mfp_p, 0, sizeof(mfp));
11481158
11491159   mfp_p->tsr = MFP68901_TSR_BUFFER_EMPTY;
11501160
11511161   mfp_p->intf = intf;
11521162
1163   // counter timers
1164
11531165   mfp_p->timer[MFP68901_TIMER_A] = timer_alloc(timer_a);
11541166   mfp_p->timer[MFP68901_TIMER_B] = timer_alloc(timer_b);
11551167   mfp_p->timer[MFP68901_TIMER_C] = timer_alloc(timer_c);
11561168   mfp_p->timer[MFP68901_TIMER_D] = timer_alloc(timer_d);
11571169
1158   mfp_p->rx_timer = timer_alloc(rx_tick);
1159   
1170   // serial receive timer
1171
11601172   if (mfp_p->intf->rx_clock > 0)
11611173   {
1162      timer_adjust(mfp_p->rx_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->rx_clock));
1174      timer_pulse(ATTOTIME_IN_HZ(mfp_p->intf->rx_clock), which, rx_tick);
11631175   }
11641176   
1165   mfp_p->tx_timer = timer_alloc(tx_tick);
1177   // serial transmit timer
11661178
11671179   if (mfp_p->intf->tx_clock > 0)
11681180   {
1169      timer_adjust(mfp_p->tx_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->tx_clock));
1181      timer_pulse(ATTOTIME_IN_HZ(mfp_p->intf->tx_clock), which, tx_tick);
11701182   }
11711183
1172   mfp_p->irq_timer = timer_alloc(mfp68901_tick);
1173   timer_adjust(mfp_p->irq_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->chip_clock / 4));
1184   // general purpose I/O poll timer
11741185
1186   if (mfp_p->intf->gpio_r)
1187   {
1188      timer_pulse(ATTOTIME_IN_HZ(mfp_p->intf->chip_clock / 4), which, mfp68901_gpio_poll_tick);
1189   }
1190
1191   // save state support
1192
11751193   state_save_register_item("mfp68901", which, mfp_p->gpip);
11761194   state_save_register_item("mfp68901", which, mfp_p->aer);
11771195   state_save_register_item("mfp68901", which, mfp_p->ddr);
r1347r1348
12061224   state_save_register_item("mfp68901", which, mfp_p->rxtx_stop);
12071225   state_save_register_item("mfp68901", which, mfp_p->rsr_read);
12081226   state_save_register_item("mfp68901", which, mfp_p->next_rsr);
1227   state_save_register_item("mfp68901", which, mfp_p->irqlevel);
12091228}
12101229
12111230/* Read/Write Handlers */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team