Previous 15994 Revisions Next

r12483 Friday 5th August, 2011 at 01:00:58 UTC by Angelo Salese
Rewrote SMPC intback commands from scratch, improves inputs compatibility dramatically
[src/mame/machine]smpc.c stvcd.c

src/mame/machine/smpc.c
r12482r12483
153153#include "machine/eeprom.h"
154154
155155#define LOG_SMPC 0
156#define LOG_PAD_CMD 0
156157
157158READ8_HANDLER( stv_SMPC_r )
158159{
r12482r12483
262263   /* TODO: VDP1 / VDP2 / SCU / SCSP default power ON values */
263264}
264265
265static void smpc_intbackhelper(running_machine &machine)
266static TIMER_CALLBACK( stv_smpc_intback )
266267{
267268   saturn_state *state = machine.driver_data<saturn_state>();
268   int pad,i;
269   static const char *const padnames[] = { "JOY1", "JOY2" };
270
271   if (state->m_smpc.intback_stage == 1)
272   {
273      state->m_smpc.intback_stage++;
274      return;
275   }
276
277//  if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2);
278   for(i=0;i<2;i++)
279   {
280      pad = input_port_read(machine, padnames[i]);
281      state->m_smpc_ram[0x21+i*8] = 0xf1;   // no tap, direct connect
282      state->m_smpc_ram[0x23+i*8] = 0x02;   // saturn pad
283      state->m_smpc_ram[0x25+i*8] = pad>>8;
284      state->m_smpc_ram[0x27+i*8] = pad & 0xff;
285   }
286
287   if (state->m_smpc.intback_stage == 3)
288   {
289      state->m_smpc.smpcSR = (0x80 | state->m_smpc.pmode);   // pad 2, no more data, echo back pad mode set by intback
290   }
291   else
292   {
293      state->m_smpc.smpcSR = (0xe0 | state->m_smpc.pmode);   // pad 1, more data, echo back pad mode set by intback
294   }
295
296   state->m_smpc.intback_stage++;
297}
298
299/* sys_type 1 == STV, 0 == SATURN */
300static TIMER_CALLBACK( smpc_intback )
301{
302   saturn_state *state = machine.driver_data<saturn_state>();
303269   system_time systime;
304270   machine.base_datetime(systime);
305   UINT8 sys_type = param;
306271
307272   state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
308273
309   if(sys_type == 0)
310   {
311      state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100);
312       state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100);
313      state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1);
314       state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday);
315       state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour);
316       state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute);
317       state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second);
318   }
319
320274   state->m_smpc_ram[0x31]=0x00;  //?
321275
322276   //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE");
r12482r12483
331285                            0 << 0;  //SOUNDRES
332286   state->m_smpc_ram[0x37]= 0 << 6; //CDRES
333287
334   state->m_smpc_ram[0x39]=sys_type ? 0xff : state->m_smpc.SMEM[0];
335   state->m_smpc_ram[0x3b]=sys_type ? 0xff : state->m_smpc.SMEM[1];
336   state->m_smpc_ram[0x3d]=sys_type ? 0xff : state->m_smpc.SMEM[2];
337   state->m_smpc_ram[0x3f]=sys_type ? 0xff : state->m_smpc.SMEM[3];
288   state->m_smpc_ram[0x39]=0xff;
289   state->m_smpc_ram[0x3b]=0xff;
290   state->m_smpc_ram[0x3d]=0xff;
291   state->m_smpc_ram[0x3f]=0xff;
338292
339293   state->m_smpc_ram[0x41]=0xff;
340294   state->m_smpc_ram[0x43]=0xff;
r12482r12483
352306   state->m_smpc_ram[0x5b]=0xff;
353307   state->m_smpc_ram[0x5d]=0xff;
354308
355   if(sys_type == 0)
356   {
357      state->m_smpc.smpcSR = 0x60;      // peripheral data ready, no reset, etc.
358      state->m_smpc.pmode = state->m_smpc_ram[1]>>4;
309   //  /*This is for RTC,cartridge code and similar stuff...*/
310   //if(LOG_SMPC) printf ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
311   if(!(state->m_scu.ism & IRQ_SMPC))
312      device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47);
313   else
314      state->m_scu.ist |= (IRQ_SMPC);
359315
360      state->m_smpc.intback_stage = 1;
316   /* clear hand-shake flag */
317   state->m_smpc_ram[0x63] = 0x00;
318}
361319
362      smpc_intbackhelper(machine);
320static TIMER_CALLBACK( intback_peripheral )
321{
322   saturn_state *state = machine.driver_data<saturn_state>();
323   int pad,pad_num;
324   static const char *const padnames[] = { "JOY1", "JOY2" };
325
326   /* doesn't work? */
327   //pad_num = state->m_smpc.intback_stage - 1;
328
329   if(LOG_PAD_CMD) printf("%d\n",pad_num);
330
331//  if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2);
332   for(pad_num=0;pad_num<2;pad_num++)
333   {
334      pad = input_port_read(machine, padnames[pad_num]);
335      state->m_smpc_ram[0x21+pad_num*8] = 0xf1;   // no tap, direct connect
336      state->m_smpc_ram[0x23+pad_num*8] = 0x02;   // saturn pad
337      state->m_smpc_ram[0x25+pad_num*8] = pad>>8;
338      state->m_smpc_ram[0x27+pad_num*8] = pad & 0xff;
363339   }
364340
365   //  /*This is for RTC,cartridge code and similar stuff...*/
366   //if(LOG_SMPC) printf ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
341   if (state->m_smpc.intback_stage == 2)
342   {
343      state->m_smpc.smpcSR = (0x80 | state->m_smpc.pmode);   // pad 2, no more data, echo back pad mode set by intback
344      state->m_smpc.intback_stage = 0;
345   }
346   else
347   {
348      state->m_smpc.smpcSR = (0xc0 | state->m_smpc.pmode);   // pad 1, more data, echo back pad mode set by intback
349      state->m_smpc.intback_stage ++;
350   }
351
367352   if(!(state->m_scu.ism & IRQ_SMPC))
368353      device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47);
369354   else
r12482r12483
371356
372357   /* clear hand-shake flag */
373358   state->m_smpc_ram[0x63] = 0x00;
359
374360}
375361
362static TIMER_CALLBACK( saturn_smpc_intback )
363{
364   saturn_state *state = machine.driver_data<saturn_state>();
365   system_time systime;
366   machine.base_datetime(systime);
367
368   if(state->m_smpc_ram[1] != 0)
369   {
370      {
371         state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
372
373         state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100);
374            state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100);
375         state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1);
376            state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday);
377            state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour);
378            state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute);
379            state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second);
380
381         state->m_smpc_ram[0x31]=0x00;  //?
382
383         //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE");
384
385         state->m_smpc_ram[0x35]= 0 << 7 |
386                                  state->m_vdp2.dotsel << 6 |
387                                  1 << 5 |
388                                  1 << 4 |
389                                  0 << 3 | //MSHNMI
390                                  1 << 2 |
391                                  0 << 1 | //SYSRES
392                                  0 << 0;  //SOUNDRES
393         state->m_smpc_ram[0x37]= 0 << 6; //CDRES
394
395         state->m_smpc_ram[0x39]=state->m_smpc.SMEM[0];
396         state->m_smpc_ram[0x3b]=state->m_smpc.SMEM[1];
397         state->m_smpc_ram[0x3d]=state->m_smpc.SMEM[2];
398         state->m_smpc_ram[0x3f]=state->m_smpc.SMEM[3];
399
400         state->m_smpc_ram[0x41]=0xff;
401         state->m_smpc_ram[0x43]=0xff;
402         state->m_smpc_ram[0x45]=0xff;
403         state->m_smpc_ram[0x47]=0xff;
404         state->m_smpc_ram[0x49]=0xff;
405         state->m_smpc_ram[0x4b]=0xff;
406         state->m_smpc_ram[0x4d]=0xff;
407         state->m_smpc_ram[0x4f]=0xff;
408         state->m_smpc_ram[0x51]=0xff;
409         state->m_smpc_ram[0x53]=0xff;
410         state->m_smpc_ram[0x55]=0xff;
411         state->m_smpc_ram[0x57]=0xff;
412         state->m_smpc_ram[0x59]=0xff;
413         state->m_smpc_ram[0x5b]=0xff;
414         state->m_smpc_ram[0x5d]=0xff;
415      }
416
417      state->m_smpc.intback_stage = (state->m_smpc_ram[3] & 8) >> 3; // first peripheral
418      state->m_smpc.smpcSR = 0x40 | state->m_smpc.intback_stage << 5;
419      state->m_smpc.pmode = state->m_smpc_ram[1]>>4;
420
421      if(!(state->m_scu.ism & IRQ_SMPC))
422         device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47);
423      else
424         state->m_scu.ist |= (IRQ_SMPC);
425
426      /* clear hand-shake flag */
427      state->m_smpc_ram[0x63] = 0x00;
428   }
429   else if(state->m_smpc_ram[3] & 8)
430   {
431      state->m_smpc.intback_stage = (state->m_smpc_ram[3] & 8) >> 3; // first peripheral
432      state->m_smpc.smpcSR = 0x40;
433      machine.scheduler().timer_set(attotime::from_usec(0), FUNC(intback_peripheral),0);
434   }
435   else
436   {
437      printf("SMPC intback bogus behaviour called %02x %02x\n",state->m_smpc_ram[1],state->m_smpc_ram[3]);
438   }
439
440}
441
376442static void smpc_rtc_write(running_machine &machine)
377443{
378444   saturn_state *state = machine.driver_data<saturn_state>();
r12482r12483
505571         /*"Interrupt Back"*/
506572         case 0x10:
507573            if(LOG_SMPC) printf ("SMPC: Status Acquire\n");
508            space->machine().scheduler().timer_set(attotime::from_msec(16), FUNC(smpc_intback),1); //TODO: variable time
574            space->machine().scheduler().timer_set(attotime::from_msec(16), FUNC(stv_smpc_intback),0); //TODO: variable time
509575            break;
510576         /* RTC write*/
511577         case 0x16:
r12482r12483
606672
607673   last = state->m_smpc_ram[offset];
608674
609   if ((state->m_smpc.intback_stage > 0) && (offset == 1) && (((data ^ 0x80)&0x80) == (last&0x80)))
675   if (offset == 1)
610676   {
611      if (LOG_SMPC) logerror("SMPC: CONTINUE request, stage %d\n", state->m_smpc.intback_stage);
612      if (state->m_smpc.intback_stage != 3)
677      if(state->m_smpc.intback_stage)
613678      {
614         state->m_smpc.intback_stage = 2;
679         if(data & 0x40)
680         {
681            if(LOG_PAD_CMD) printf("SMPC: BREAK request\n");
682            state->m_smpc.smpcSR &= 0x0f;
683            state->m_smpc.intback_stage = 0;
684         }
685         else if(data & 0x80)
686         {
687            if(LOG_PAD_CMD) printf("SMPC: CONTINUE request\n");
688            space->machine().scheduler().timer_set(attotime::from_usec(200), FUNC(intback_peripheral),0); /* TODO: is timing correct? */
689            state->m_smpc_ram[0x63] = 0x01; //TODO: set hand-shake flag?
690         }
615691      }
616      smpc_intbackhelper(machine);
617      device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47);
618692   }
619693
620   if ((offset == 1) && (data & 0x40))
621   {
622      if (LOG_SMPC) logerror("SMPC: BREAK request\n");
623      state->m_smpc.intback_stage = 0;
624   }
625
626694   state->m_smpc_ram[offset] = data;
627695
628696   if (offset == 0x75)   // PDR1
r12482r12483
686754
687755            timing = 100;
688756
689            if(state->m_smpc_ram[1] == 0x01) // non-peripheral data
757            if(state->m_smpc_ram[1] != 0) // non-peripheral data
690758               timing = 200;
691759
692760            if(state->m_smpc_ram[3] & 8) // peripheral data
693761               timing = 15000;
694762
695            space->machine().scheduler().timer_set(attotime::from_usec(timing), FUNC(smpc_intback),0); //TODO: is variable time correct
763            if(LOG_PAD_CMD) printf("INTBACK %02x %02x\n",state->m_smpc_ram[1],state->m_smpc_ram[3]);
764
765            space->machine().scheduler().timer_set(attotime::from_usec(timing), FUNC(saturn_smpc_intback),0); //TODO: is variable time correct?
696766            break;
697767         /* RTC write*/
698768         case 0x16:
src/mame/machine/stvcd.c
r12482r12483
14311431         break;
14321432
14331433      case 0x6400:    // put sector data
1434         /* TODO: After Burner 2 and Dungeon Master Nexus trips this */
1434         /* TODO: After Burner 2, Out Run, Fantasy Zone and Dungeon Master Nexus trips this */
14351435         // ...
1436         {
1437            //UINT8 sectnum = cr4 & 0xff;
1438            //UINT8 filtnum = cr3>>8;
14361439
1440
1441         }
1442
14371443         popmessage("Put sector data command issued, contact MAMEdev");
14381444         hirqreg |= (CMOK|EHST);
14391445         break;
r12482r12483
19781984         {
19791985            if (curblock.chan != flt->chan)
19801986            {
1981               logerror("channel number reject");
1987               logerror("channel number reject\n");
19821988               match = 0;
19831989            }
19841990         }
r12482r12483
19871993         {
19881994            if((curblock.subm & flt->smmask) != flt->smval)
19891995            {
1990               logerror("sub mode reject");
1996               logerror("sub mode reject\n");
19911997               match = 0;
19921998            }
19931999         }
r12482r12483
19962002         {
19972003            if((curblock.cinf & flt->cimask) != flt->cival)
19982004            {
1999               logerror("coding information reject");
2005               logerror("coding information reject\n");
20002006               match = 0;
20012007            }
20022008         }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team