r7250 Wednesday 3rd February, 2010 at 14:57:25 UTC by Miodrag Milanović
- Fixed broken Coco3 high-res timer emulation (bug #1913)
- Removed unused code (Coco3 hacks) from m6847
[John W. Linville]
[docs]messnew.txt
[src/mess/machine]coco.c
[src/mess/video]coco6847.c coco6847.h m6847.c m6847.h

src/mess/video/coco6847.c
r7249r7250
19881988 *
19891989 *************************************/
19901990
1991static UINT64 divide_mame_time(attotime dividend, attotime divisor)
1992{
1993   /* TODO: it should not be necessary to use floating point here */
1994   double dividend_dbl = attotime_to_double(dividend);
1995   double divisor_dbl = attotime_to_double(divisor);
1996   return (UINT64) (dividend_dbl / divisor_dbl);
1997}
1998
1999
2000
20011991static attotime interval(m6847_timing_type timing)
20021992{
20031993   attotime result;
r7249r7250
20192009
20202010
20212011
2022UINT64 coco6847_time(running_machine *machine, m6847_timing_type timing)
2012attotime coco6847_time_delay(running_machine *machine, m6847_timing_type timing, UINT64 time_delay)
20232013{
2024   attotime current_time = timer_get_time(machine);
2025   attotime divisor = interval(timing);
2026   return divide_mame_time(current_time, divisor);
2014   return attotime_mul(interval(timing), time_delay);
20272015}
20282016
20292017
20302018
2031attotime coco6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time)
2032{
2033   attotime target_mame_time, current_time;
2034   target_mame_time = attotime_mul(interval(timing), target_time);
2035   current_time = timer_get_time(machine);
2036
2037   if (attotime_compare(target_mame_time, current_time) < 0)
2038      fatalerror("coco6847_time_until(): cannot target past times");
2039
2040   return attotime_sub(target_mame_time, current_time);
2041}
2042
2043
2044
20452019attotime coco6847_scanline_time(int scanline)
20462020{
20472021   return attotime_make(0, m6847->scanline_period *
src/mess/video/coco6847.h
r7249r7250
7676int m6847_get_field_sync(running_machine *machine);
7777
7878/* timing functions */
79UINT64 coco6847_time(running_machine *machine,m6847_timing_type timing);
80attotime coco6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time);
79attotime coco6847_time_delay(running_machine *machine, m6847_timing_type timing, UINT64 target_time);
8180
8281/* CoCo 3 hooks */
8382attotime coco6847_scanline_time(int scanline);
src/mess/video/m6847.c
r7249r7250
21952195   return rc;
21962196}
21972197
2198
2199
2200/*************************************
2201 *
2202 *  Timing calculations
2203 *
2204 *************************************/
2205
2206static UINT64 divide_mame_time(attotime dividend, attotime divisor)
2207{
2208   /* TODO: it should not be necessary to use floating point here */
2209   double dividend_dbl = attotime_to_double(dividend);
2210   double divisor_dbl = attotime_to_double(divisor);
2211   return (UINT64) (dividend_dbl / divisor_dbl);
2212}
2213
2214
2215
2216static attotime interval(running_device *device, m6847_timing_type timing)
2217{
2218   mc6847_state *mc6847 = get_safe_token(device);
2219   attotime result;
2220
2221   switch(timing)
2222   {
2223      case M6847_CLOCK:
2224         result = attotime_make(0, mc6847->clock_period);
2225         break;
2226      case M6847_HSYNC:
2227         result = attotime_make(0, mc6847->scanline_period);
2228         break;
2229      default:
2230         fatalerror("invalid timing type");
2231         break;
2232   }
2233   return result;
2234}
2235
2236
2237
2238UINT64 m6847_time(running_device *device, m6847_timing_type timing)
2239{
2240   attotime current_time = timer_get_time(device->machine);
2241   attotime divisor = interval(device, timing);
2242   return divide_mame_time(current_time, divisor);
2243}
2244
2245
2246
2247attotime m6847_time_until(running_device *device, m6847_timing_type timing, UINT64 target_time)
2248{
2249   attotime target_mame_time, current_time;
2250   target_mame_time = attotime_mul(interval(device, timing), target_time);
2251   current_time = timer_get_time(device->machine);
2252
2253   if (attotime_compare(target_mame_time, current_time) < 0)
2254      fatalerror("m6847_time_until(): cannot target past times");
2255
2256   return attotime_sub(target_mame_time, current_time);
2257}
2258
2259
2260
2261attotime m6847_scanline_time(running_device *device, int scanline)
2262{
2263   mc6847_state *mc6847 = get_safe_token(device);
2264
2265   return attotime_make(0, mc6847->scanline_period *
2266         (13 /* FIXME */ + scanline));
2267}
2268
2269
2270
2271/*************************************
2272 *
2273 *  Hacks
2274 *
2275 *************************************/
2276
2277#ifdef UNUSED_FUNCTION
2278void m6847_set_dirty(void) { set_dirty(); }
2279int m6847_get_scanline(void) { return get_scanline(); }
2280#endif
2281
2282int mc6847_get_scanline(running_device *device)
2283{
2284   mc6847_state *mc6847 = get_safe_token(device);
2285   return get_scanline(mc6847) - mc6847->top_border_scanlines;
2286}
src/mess/video/m6847.h
r7249r7250
142142
143143void mc6847_set_palette(running_device *device, UINT32 *palette);
144144
145/* hack for the coco until the 6883sam can be updated */
146int mc6847_get_scanline(running_device *device);
147
148
149145void m6847_video_changed(void);
150146
151/* timing functions */
152UINT64 m6847_time(running_device *device, m6847_timing_type timing);
153attotime m6847_time_until(running_device *device, m6847_timing_type timing, UINT64 target_time);
154
155/* CoCo 3 hooks */
156attotime m6847_scanline_time(running_device *device, int scanline);
157
158147INPUT_PORTS_EXTERN( m6847_artifacting );
159148
160149
src/mess/machine/coco.c
r7249r7250
21832183static void coco3_timer_reset(running_machine *machine)
21842184{
21852185   /* reset the timer; take the value stored in $FF94-5 and start the timer ticking */
2186   UINT64 current_time;
21872186   UINT16 timer_value;
21882187   m6847_timing_type timing;
2189   attotime target_time;
2188   attotime delay_time;
21902189
21912190   /* value is from 0-4095 */
21922191   timer_value = ((coco3_gimereg[4] & 0x0F) * 0x100) | coco3_gimereg[5];
r7249r7250
22022201      /* choose which timing clock source */
22032202      timing = (coco3_gimereg[1] & 0x20) ? M6847_CLOCK : M6847_HSYNC;
22042203
2205      /* determine the current time */
2206      current_time = coco6847_time(machine, timing);
2207
2208      /* calculate the time */
2209      target_time = coco6847_time_until(machine, timing, current_time + timer_value);
2204      /* determine the delay time */
2205      delay_time = coco6847_time_delay(machine, timing, timer_value);
22102206      if (LOG_TIMER)
2211         logerror("coco3_reset_timer(): target_time=%g\n", attotime_to_double(target_time));
2207         logerror("coco3_reset_timer(): delay_time=%g\n", attotime_to_double(delay_time));
22122208
22132209      /* and adjust the timer */
2214      timer_adjust_oneshot(coco3_gime_timer, target_time, 0);
2210      timer_adjust_oneshot(coco3_gime_timer, delay_time, 0);
22152211   }
22162212   else
22172213   {
docs/messnew.txt
r7249r7250
5353
5454- [TX0] Fixed disassembly in the debugger. [Robbbert]
5555
56- [COCO3] Fixed broken Coco3 high-res timer emulation
57  (bug #1913) [John W. Linville]
5658
57
5859Imgtool Changes:
5960----------------
6061(none)

Previous 509078 RevisionsNext 50


© 1998-2010 The MESS Team