|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * Events ! 5: * ! 6: * (c) 1995 Bernd Schmidt ! 7: */ ! 8: ! 9: /* This is tunable. 4 gives good results. */ ! 10: #ifdef LINUX_SOUND_SLOW_MACHINE ! 11: #define cycles_per_instruction 8 ! 12: #else ! 13: #define cycles_per_instruction 4 ! 14: #endif ! 15: ! 16: #undef DEFFERED_INT ! 17: #if !defined(NO_FAST_BLITTER) || !defined(NO_FAST_DISK) ! 18: #define DEFERRED_INT ! 19: #endif ! 20: ! 21: extern unsigned long int cycles, nextevent, nextev_count; ! 22: typedef void (*evfunc)(void); ! 23: ! 24: struct ev ! 25: { ! 26: bool active; ! 27: unsigned long int evtime, oldcycles; ! 28: evfunc handler; ! 29: }; ! 30: ! 31: enum { ! 32: ev_copper, ev_hsync, ev_cia, ! 33: #ifdef DEFERRED_INT ! 34: ev_deferint, ! 35: #endif ! 36: ev_max ! 37: }; ! 38: ! 39: extern struct ev eventtab[ev_max]; ! 40: ! 41: static __inline__ void events_schedule(void) ! 42: { ! 43: int i; ! 44: ! 45: unsigned long int mintime = ~0L; ! 46: nextevent = cycles + mintime; ! 47: for(i = ev_copper; i < ev_max; i++) { ! 48: unsigned long int eventtime = eventtab[i].evtime + eventtab[i].oldcycles - cycles; ! 49: if (eventtab[i].active && eventtime < mintime) { ! 50: mintime = eventtime; ! 51: nextevent = cycles + mintime; ! 52: } ! 53: } ! 54: nextev_count = nextevent - cycles; ! 55: } ! 56: ! 57: static __inline__ void do_cycles(void) ! 58: { ! 59: if (nextev_count <= cycles_per_instruction) { ! 60: int j; ! 61: for(j = 0; j < cycles_per_instruction; j++) { ! 62: if (++cycles == nextevent) { ! 63: unsigned long int old_nextevent = nextevent; ! 64: int i; ! 65: ! 66: for(i = ev_copper; i < ev_max; i++) { ! 67: if (eventtab[i].active && (eventtab[i].evtime + eventtab[i].oldcycles) == old_nextevent) { ! 68: (*eventtab[i].handler)(); ! 69: } ! 70: } ! 71: events_schedule(); ! 72: } else nextev_count--; ! 73: } ! 74: } else { ! 75: nextev_count -= cycles_per_instruction; ! 76: cycles += cycles_per_instruction; ! 77: } ! 78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.