Previous 199869 Revisions Next

r32159 Wednesday 17th September, 2014 at 20:50:32 UTC by O. Galibert
If we were documented, we'd be dangerous (nw)
[docs]m6502.txt
[src/emu/cpu/h8]h8.c h8.h h8_adc.c h8_sci.c h8_timer16.c h8_timer8.c
[src/emu/cpu/m6502]m6502.c m6502.h m740.c
[src/emu/cpu/mcs96]i8x9x.c mcs96.c mcs96.h

trunk/src/emu/cpu/m6502/m6502.c
r32158r32159
129129   inst_substate = 0;
130130   inst_state_base = 0;
131131   sync = false;
132   end_cycles = 0;
133132   inhibit_interrupts = false;
134133}
135134
r32158r32159
143142   apu_irq_state = false;
144143   irq_taken = false;
145144   v_state = false;
146   end_cycles = 0;
147145   sync = false;
148146   sync_w(CLEAR_LINE);
149147   inhibit_interrupts = false;
r32158r32159
400398   return v;
401399}
402400
403UINT64 m6502_device::get_cycle()
404{
405   return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount;
406}
407
408401void m6502_device::execute_run()
409402{
410   // get_cycle() is currently unused, and this precalculation
411   // enormously slows down drivers with high interleave
412#if 0
413   end_cycles = machine().time().as_ticks(clock()) + icount;
414#endif
415403   if(inst_substate)
416404      do_exec_partial();
417405
r32158r32159
424412      }
425413      do_exec_full();
426414   }
427   end_cycles = 0;
428415}
429416
430417void m6502_device::execute_set_input(int inputnum, int state)
trunk/src/emu/cpu/m6502/m6502.h
r32158r32159
6161   DECLARE_WRITE_LINE_MEMBER( irq_line );
6262   DECLARE_WRITE_LINE_MEMBER( nmi_line );
6363
64   UINT64 get_cycle();
6564   bool get_sync() const { return sync; }
6665   void disable_direct() { direct_disabled = true; }
6766
r32158r32159
201200   int icount;
202201   bool nmi_state, irq_state, apu_irq_state, v_state;
203202   bool irq_taken, sync, direct_disabled, inhibit_interrupts;
204   UINT64 end_cycles;
205203
206204   static const disasm_entry disasm_entries[0x100];
207205
trunk/src/emu/cpu/m6502/m740.c
r32158r32159
7777   apu_irq_state = false;
7878   irq_taken = false;
7979   v_state = false;
80   end_cycles = 0;
8180   sync = false;
8281   inhibit_interrupts = false;
8382   SP = 0x00ff;
trunk/src/emu/cpu/h8/h8_timer16.c
r32158r32159
199199      return;
200200
201201   if(!cur_time)
202      cur_time = cpu->get_cycle();
202      cur_time = cpu->total_cycles();
203203
204204   if(!channel_active) {
205205      last_clock_update = cur_time;
r32158r32159
257257   }
258258
259259   if(!cur_time)
260      cur_time = cpu->get_cycle();
260      cur_time = cpu->total_cycles();
261261
262262   if(counter_incrementing) {
263263      UINT32 event_delay = 0xffffffff;
r32158r32159
297297         event_time = 0;
298298
299299      if(event_time && 0)
300         logerror("%s: next event in %d cycles (%ld)\n", tag(), int(event_time - cpu->get_cycle()), long(event_time));
300         logerror("%s: next event in %d cycles (%ld)\n", tag(), int(event_time - cpu->total_cycles()), long(event_time));
301301
302302   } else {
303303      logerror("decrementing counter\n");
trunk/src/emu/cpu/h8/h8_adc.c
r32158r32159
152152   if(current_time)
153153      next_event = current_time + conversion_time(first, poweron);
154154   else {
155      next_event = cpu->get_cycle() + conversion_time(first, poweron);
155      next_event = cpu->total_cycles() + conversion_time(first, poweron);
156156      cpu->internal_update();
157157   }
158158}
trunk/src/emu/cpu/h8/h8_timer8.c
r32158r32159
212212      return;
213213
214214   if(!cur_time)
215      cur_time = cpu->get_cycle();
215      cur_time = cpu->total_cycles();
216216
217217   UINT64 base_time = (last_clock_update + clock_divider/2) / clock_divider;
218218   UINT64 new_time = (cur_time + clock_divider/2) / clock_divider;
r32158r32159
262262   }
263263
264264   if(!cur_time)
265      cur_time = cpu->get_cycle();
265      cur_time = cpu->total_cycles();
266266
267267   UINT32 event_delay = 0xffffffff;
268268   if(clear_type == CLEAR_A || clear_type == CLEAR_B)
trunk/src/emu/cpu/h8/h8.c
r32158r32159
130130   MACF = 0;
131131   inst_state = STATE_RESET;
132132   inst_substate = 0;
133   end_cycles = 0;
134133}
135134
136135void h8_device::device_reset()
137136{
138137   inst_state = STATE_RESET;
139138   inst_substate = 0;
140   end_cycles = 0;
141139
142140   irq_vector = 0;
143141   irq_level = -1;
r32158r32159
162160   return 0;
163161}
164162
165UINT64 h8_device::get_cycle()
166{
167   return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount;
168}
169
170163void h8_device::recompute_bcount(UINT64 event_time)
171164{
172   if(!event_time || event_time >= end_cycles) {
165   if(!event_time || event_time >= total_cycles() + icount) {
173166      bcount = 0;
174167      return;
175168   }
176   bcount = end_cycles - event_time;
169   bcount = total_cycles() - event_time;
177170}
178171
179172void h8_device::execute_run()
180173{
181   start_cycles = machine().time().as_ticks(clock());
182   end_cycles = start_cycles + icount;
174   internal_update(total_cycles());
183175
184   internal_update(start_cycles);
185
186176   if(inst_substate)
187177      do_exec_partial();
188178
r32158r32159
196186         do_exec_full();
197187      }
198188      while(bcount && icount && icount <= bcount)
199         internal_update(end_cycles - bcount);
189         internal_update(total_cycles() + icount - bcount);
200190      if(inst_substate)
201191         do_exec_partial();
202192   }
203   end_cycles = 0;
204193}
205194
206195void h8_device::add_event(UINT64 &event_time, UINT64 new_event)
r32158r32159
213202
214203void h8_device::internal_update()
215204{
216   internal_update(get_cycle());
205   internal_update(total_cycles());
217206}
218207
219208const address_space_config *h8_device::memory_space_config(address_spacenum spacenum) const
trunk/src/emu/cpu/h8/h8.h
r32158r32159
7676
7777   h8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, bool mode_a16, address_map_delegate map_delegate);
7878
79   UINT64 get_cycle();
8079   void internal_update();
8180
8281   void set_irq(int irq_vector, int irq_level, bool irq_nmi);
r32158r32159
214213
215214   int inst_state, inst_substate;
216215   int icount, bcount;
217   UINT64 start_cycles, end_cycles;
218216   int irq_vector, taken_irq_vector;
219217   int irq_level, taken_irq_level;
220218   bool irq_required, irq_nmi;
trunk/src/emu/cpu/h8/h8_sci.c
r32158r32159
461461      case CLKM_INTERNAL_ASYNC_OUT:
462462      case CLKM_INTERNAL_SYNC_OUT:
463463         logerror("%s: Starting internal clock\n", tag());
464         clock_base = cpu->get_cycle();
464         clock_base = cpu->total_cycles();
465465         cpu->internal_update();
466466         break;
467467
468468      case CLKM_EXTERNAL_RATE_ASYNC:
469469         logerror("%s: Simulating external clock async\n", tag());
470         clock_base = UINT64(cpu->get_cycle()*internal_to_external_ratio);
470         clock_base = UINT64(cpu->total_cycles()*internal_to_external_ratio);
471471         cpu->internal_update();
472472         break;
473473
474474      case CLKM_EXTERNAL_RATE_SYNC:
475475         logerror("%s: Simulating external clock sync\n", tag());
476         clock_base = UINT64(cpu->get_cycle()*2*internal_to_external_ratio);
476         clock_base = UINT64(cpu->total_cycles()*2*internal_to_external_ratio);
477477         cpu->internal_update();
478478         break;
479479
trunk/src/emu/cpu/mcs96/mcs96.c
r32158r32159
9494   return 1;
9595}
9696
97UINT64 mcs96_device::get_cycle()
98{
99   return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount;
100}
101
10297void mcs96_device::recompute_bcount(UINT64 event_time)
10398{
104   if(!event_time || event_time >= end_cycles) {
99   if(!event_time || event_time >= total_cycles()+icount) {
105100      bcount = 0;
106101      return;
107102   }
108   bcount = end_cycles - event_time;
103   bcount = total_cycles() - event_time;
109104}
110105
111106void mcs96_device::check_irq()
r32158r32159
115110
116111void mcs96_device::execute_run()
117112{
118   UINT64 start_cycles = machine().time().as_ticks(clock());
119   end_cycles = start_cycles + icount;
113   internal_update(total_cycles());
120114
121   internal_update(start_cycles);
115   //   if(inst_substate)
116   //      do_exec_partial();
122117
123   if(/*inst_substate*/ 0)
124      do_exec_partial();
125
126118   while(icount > 0) {
127119      while(icount > bcount) {
128120         int picount = inst_state >= 0x200 ? -1 : icount;
r32158r32159
132124         }
133125      }
134126      while(bcount && icount <= bcount)
135         internal_update(end_cycles - bcount);
127         internal_update(total_cycles() + icount - bcount);
128      //      if(inst_substate)
129      //         do_exec_partial();
136130   }
137   end_cycles = 0;
138131}
139132
140133void mcs96_device::execute_set_input(int inputnum, int state)
trunk/src/emu/cpu/mcs96/mcs96.h
r32158r32159
4848
4949   mcs96_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int data_width, const char *shortname, const char *source);
5050
51   UINT64 get_cycle();
52
5351protected:
5452   enum {
5553      STATE_FETCH = 0x200,
r32158r32159
127125   address_space *program;
128126   direct_read_data *direct;
129127
130   UINT64 end_cycles;
131128   int icount, bcount, inst_state, cycles_scaling;
132129   UINT8 pending_irq;
133130   UINT16 PC, PPC, PSW;
trunk/src/emu/cpu/mcs96/i8x9x.c
r32158r32159
8787         hso_info[i].active = true;
8888         hso_info[i].command = hso_command;
8989         hso_info[i].time = hso_time;
90         internal_update(get_cycle());
90         internal_update(total_cycles());
9191         return;
9292      }
9393   hso_cam_hold.active = true;
r32158r32159
105105void i8x9x_device::serial_send(UINT8 data)
106106{
107107   serial_send_buf = data;
108   serial_send_timer = get_cycle() + 9600;
108   serial_send_timer = total_cycles() + 9600;
109109}
110110
111111void i8x9x_device::serial_send_done()
r32158r32159
123123   case 0x02:
124124      ad_command = data;
125125      if(ad_command & 8)
126         ad_start(get_cycle());
126         ad_start(total_cycles());
127127      break;
128128   case 0x03:
129129      logerror("%s: hsi_mode %02x (%04x)\n", tag(), data, PPC);
r32158r32159
229229      return pending_irq;
230230   case 0x0a:
231231      logerror("%s: read timer1 l (%04x)\n", tag(), PPC);
232      return timer_value(1, get_cycle());
232      return timer_value(1, total_cycles());
233233   case 0x0b:
234234      logerror("%s: read timer1 h (%04x)\n", tag(), PPC);
235      return timer_value(1, get_cycle()) >> 8;
235      return timer_value(1, total_cycles()) >> 8;
236236   case 0x0c:
237237      logerror("%s: read timer2 l (%04x)\n", tag(), PPC);
238      return timer_value(2, get_cycle());
238      return timer_value(2, total_cycles());
239239   case 0x0d:
240240      logerror("%s: read timer2 h (%04x)\n", tag(), PPC);
241      return timer_value(2, get_cycle()) >> 8;
241      return timer_value(2, total_cycles()) >> 8;
242242   case 0x0e: {
243243      static int last = -1;
244244      if(io->read_word(P0*2) != last) {
r32158r32159
282282      logerror("%s: read hsi time (%04x)\n", tag(), PPC);
283283      return 0x0000;
284284   case 0x0a:
285      return timer_value(1, get_cycle());
285      return timer_value(1, total_cycles());
286286   case 0x0c:
287287      logerror("%s: read timer2 (%04x)\n", tag(), PPC);
288      return timer_value(2, get_cycle());
288      return timer_value(2, total_cycles());
289289   default:
290290      return io_r8(adr) | (io_r8(adr+1) << 8);
291291   }
trunk/docs/m6502.txt
r32158r32159
9595of the sync line is given by the cpu method get_sync(), making
9696implementing the decryption in the handler possible.
9797
98In a final addition, the cpu method get_cycle() gives the current time
99in cycles since the start of the machine from the point of view of the
100cpu.  Or, in other words, what is usually called the cycle number for
101the cpu when somebody talks about bus contention or wait states.  The
102call is designed to be fast (no system-wide sync, usually no call to
103machine.time()) and is precise.  Cycle number for every access is
104exact at the sub-instruction level.
98Also, as for every executable device, the cpu method total_cycles()
99gives the current time in cycles since the start of the machine from
100the point of view of the cpu.  Or, in other words, what is usually
101called the cycle number for the cpu when somebody talks about bus
102contention or wait states.  The call is designed to be fast (no
103system-wide sync, no call to machine.time()) and is precise.  Cycle
104number for every access is exact at the sub-instruction level.
105105
106106The 4510 special nomap line is accessible through get_nomap().
107107

Previous 199869 Revisions Next


© 1997-2024 The MAME Team