Previous 15994 Revisions Next

r847 Saturday 18th August, 2007 at 23:44:31 UTC by R. Belmont
[A310] More correct timer emulation.
[src/mess/drivers]a310.c

src/mess/drivers/a310.c
r846r847
8080static INT16 a310_pages[(32*1024*1024)/(4096)];   // the logical RAM area is 32 megs, and the smallest page size is 4k
8181static UINT32 a310_vidregs[256];
8282static UINT8 a310_iocregs[0x80/4];
83static UINT32 a310_timercnt[4];
83static UINT32 a310_timercnt[4], a310_timerout[4];
8484static UINT32 a310_sndstart, a310_sndend, a310_sndcur;
8585
8686static mame_timer *vbl_timer, *timer[4], *snd_timer;
r846r847
367367   "(write) Timer 3 latch command"               // 31
368368};
369369
370static void update_timer_cnt(int tmr)
370static void latch_timer_cnt(int tmr)
371371{
372372   double time;
373   UINT32 cnt;
374373
375374   time = mame_time_to_double(mame_timer_timeelapsed(timer[tmr]));
376375   time *= 2000000.0;   // find out how many 2 MHz ticks have gone by
377   cnt = a310_timercnt[tmr] - (UINT32)time;
378   a310_iocregs[16+(4*tmr)] = cnt&0xff;
379   a310_iocregs[17+(4*tmr)] = (cnt>>8)&0xff;
376   a310_timerout[tmr] = a310_timercnt[tmr] - (UINT32)time;
380377}
381378
382379static READ32_HANDLER(ioc_r)
r846r847
390387            break;
391388
392389         case 16:   // timer 0 read
390            return a310_timerout[0]&0xff;
391            break;
393392         case 17:
394            update_timer_cnt(0);
393            return (a310_timerout[0]>>8)&0xff;
395394            break;
396395         case 20:   // timer 1 read
396            return a310_timerout[1]&0xff;
397            break;
397398         case 21:
398            update_timer_cnt(1);
399            return (a310_timerout[1]>>8)&0xff;
399400            break;
400401         case 24:   // timer 2 read
402            return a310_timerout[2]&0xff;
403            break;
401404         case 25:
402            update_timer_cnt(2);
405            return (a310_timerout[2]>>8)&0xff;
403406            break;
404407         case 28:   // timer 3 read
408            return a310_timerout[3]&0xff;
409            break;
405410         case 29:
406            update_timer_cnt(3);
411            return (a310_timerout[3]>>8)&0xff;
407412            break;
408413      }
409414
r846r847
428433{
429434   if (offset >= 0x80000 && offset < 0xc0000)
430435   {
431      logerror("IOC: W %02x @ reg %s (PC=%x)\n", data&0xff, ioc_regnames[offset&0x1f], activecpu_get_pc());
436//      logerror("IOC: W %02x @ reg %s (PC=%x)\n", data&0xff, ioc_regnames[offset&0x1f], activecpu_get_pc());
432437
433438      switch (offset&0x1f)
434439      {
440         case 0:   // control
441            logerror("IOC I2C: CLK %d DAT %d\n", (data>>1)&1, data&1);
442            break;
443
435444         case 5:    // IRQ clear A
436445            a310_iocregs[4] &= ~(data&0xff);
437446
r846r847
445454         case 16:
446455         case 17:
447456            a310_iocregs[offset&0x1f] = data & 0xff;
448            a310_timercnt[0] = a310_iocregs[17]<<8 | a310_iocregs[16];
449457            break;
450458
451459         case 20:
452460         case 21:
453461            a310_iocregs[offset&0x1f] = data & 0xff;
454            a310_timercnt[1] = a310_iocregs[21]<<8 | a310_iocregs[20];
455462            break;
456463
457464         case 24:
458465         case 25:
459466            a310_iocregs[offset&0x1f] = data & 0xff;
460            a310_timercnt[2] = a310_iocregs[25]<<8 | a310_iocregs[24];
461467            break;
462468
463469         case 28:
464470         case 29:
465471            a310_iocregs[offset&0x1f] = data & 0xff;
466            a310_timercnt[3] = a310_iocregs[29]<<8 | a310_iocregs[28];
467472            break;
468473
469474         case 19:   // Timer 0 latch
470            a310_timercnt[0] = a310_iocregs[17]<<8 | a310_iocregs[16];
475            latch_timer_cnt(0);
471476            break;
472477
473478         case 23:   // Timer 1 latch
474            a310_timercnt[1] = a310_iocregs[21]<<8 | a310_iocregs[20];
479            latch_timer_cnt(1);
475480            break;
476481
477482         case 27:   // Timer 2 latch
478            a310_timercnt[2] = a310_iocregs[25]<<8 | a310_iocregs[24];
483            latch_timer_cnt(2);
479484            break;
480485
481486         case 31:   // Timer 3 latch
482            a310_timercnt[3] = a310_iocregs[29]<<8 | a310_iocregs[28];
487            latch_timer_cnt(3);
483488            break;
484489
485490         case 18:   // Timer 0 start
491            a310_timercnt[0] = a310_iocregs[17]<<8 | a310_iocregs[16];
486492            a310_set_timer(0);
487493            break;
488494
489495         case 22:   // Timer 1 start
496            a310_timercnt[1] = a310_iocregs[21]<<8 | a310_iocregs[20];
490497            a310_set_timer(1);
491498            break;
492499
493500         case 26:   // Timer 2 start
501            a310_timercnt[2] = a310_iocregs[25]<<8 | a310_iocregs[24];
494502            a310_set_timer(2);
495503            break;
496504
497505         case 30:   // Timer 3 start
506            a310_timercnt[3] = a310_iocregs[29]<<8 | a310_iocregs[28];
498507            a310_set_timer(3);
499508            break;
500509
r846r847
891900   ROM_LOAD("ic25.rom", 0x080000, 0x80000, CRC(15d89664) SHA1(78f5d0e6f1e8ee603317807f53ff8fe65a3b3518))
892901   ROM_LOAD("ic26.rom", 0x100000, 0x80000, CRC(a81ceb7c) SHA1(46b870876bc1f68f242726415f0c49fef7be0c72))
893902   ROM_LOAD("ic27.rom", 0x180000, 0x80000, CRC(707b0c6c) SHA1(345199a33fed23996374b9db8170a52ab63f0380))
894
895903   ROM_REGION(0x00800, REGION_GFX1, 0)
896904ROM_END
897905
898/*    YEAR  NAME  PARENT COMPAT    MACHINE  INPUT    INIT  CONFIG  COMPANY   FULLNAME */
899COMP( 1988, a310, 0,     0,      a310,    a310,  a310, NULL,   "Acorn", "Archimedes 310", GAME_NOT_WORKING)
906/*    YEAR  NAME  PARENT  COMPAT  MACHINE  INPUT    INIT  CONFIG  COMPANY   FULLNAME */
907COMP( 1988, a310, 0,      0,      a310,    a310,  a310, NULL,   "Acorn", "Archimedes 310 (Risc OS 3.11)", GAME_NOT_WORKING)
908

Previous 15994 Revisions Next


© 1998-2018 The MESS Team