Previous 199869 Revisions Next

r34991 Thursday 12th February, 2015 at 20:20:05 UTC by hap
added timer
[src/emu/cpu/ucom4]ucom4.c ucom4.h ucom4op.inc

trunk/src/emu/cpu/ucom4/ucom4.c
r243502r243503
1010  I've also looked at asterick's JavaScript D553 emulator for verification, with permission.
1111
1212  TODO:
13  - add external interrupt
1314  - what happens with uCOM-43 opcodes on an uCOM-44/45 MCU?
1415  - what's the data after the ROM data for? (eg. 2000-2047, official ROM size is 2000)
1516
r243502r243503
122123   m_datamask = (1 << m_datawidth) - 1;
123124   m_dph_mask = m_datamask >> 4;
124125
126   m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ucom4_cpu_device::simple_timer_cb), this));
127
125128   m_read_a.resolve_safe(0xf);
126129   m_read_b.resolve_safe(0xf);
127130   m_read_c.resolve_safe(0xf);
r243502r243503
187190
188191void ucom4_cpu_device::device_reset()
189192{
190   m_inte_f = 1;
191193   m_pc = 0;
192194   m_op = 0;
193195   m_skip = false;
194196
197   m_timer->adjust(attotime::never);
198
195199   // clear i/o
196200   for (int i = NEC_UCOM4_PORTC; i <= NEC_UCOM4_PORTI; i++)
197201      output_w(i, 0xf);
trunk/src/emu/cpu/ucom4/ucom4.h
r243502r243503
141141   UINT8 m_bitmask;        // opcode bit argument
142142   bool m_skip;            // skip next opcode
143143   int m_icount;
144   emu_timer *m_timer;
144145   
145146   UINT16 m_pc;            // program counter
146147   UINT8 m_acc;            // 4-bit accumulator
r243502r243503
179180   void output_w(int index, UINT8 data);
180181
181182   bool check_op_43();
183   TIMER_CALLBACK_MEMBER( simple_timer_cb );
182184   UINT8 ucom43_reg_r(int index);
183185   void ucom43_reg_w(int index, UINT8 data);
184186
trunk/src/emu/cpu/ucom4/ucom4op.inc
r243502r243503
429429void ucom4_cpu_device::op_tit()
430430{
431431   // TIT: skip next on Interrupt F/F, reset Interrupt F/F
432   op_illegal();
432   m_skip = (m_int_f != 0);
433   m_int_f = 0;
433434}
434435
435436
r243502r243503
489490   return (m_family == NEC_UCOM43);
490491}
491492
493TIMER_CALLBACK_MEMBER( ucom4_cpu_device::simple_timer_cb )
494{
495   m_timer_f = 1;
496}
497
492498// extra registers reside in RAM
493499enum
494500{
r243502r243503
512518}
513519
514520
521
515522// Transfer
516523
517524void ucom4_cpu_device::op_taw()
r243502r243503
712719   if (!check_op_43()) return;
713720   
714721   // STM X: Reset Timer F/F, Start Timer with X
715   op_illegal();
722   m_timer_f = 0;
716723
724   // on the default clockrate of 400kHz, the minimum time interval is
725   // 630usec and the maximum interval is 40320usec(630*64)
726   attotime base = attotime::from_hz(unscaled_clock() / 4 / 63);
727   m_timer->adjust(base * ((m_arg & 0x3f) + 1));
728
717729   if ((m_arg & 0xc0) != 0x80)
718730      logerror("%s STM opcode unexpected upper arg $%02X at $%03X\n", tag(), m_arg & 0xc0, m_pc);
719731}
r243502r243503
723735   if (!check_op_43()) return;
724736   
725737   // TTM: skip next on Timer F/F
726   op_illegal();
738   m_skip = (m_timer_f != 0);
727739}
728740
729741
r243502r243503
734746   if (!check_op_43()) return;
735747   
736748   // EI: Set Interrupt Enable F/F
737   op_illegal();
749   m_inte_f = 1;
738750}
739751
740752void ucom4_cpu_device::op_di()
r243502r243503
742754   if (!check_op_43()) return;
743755   
744756   // DI: Reset Interrupt Enable F/F
745   op_illegal();
757   m_inte_f = 0;
746758}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team