|
|
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: extern unsigned long int cycles, nextevent; ! 17: typedef void (*evfunc)(void); ! 18: ! 19: struct ev ! 20: { ! 21: int active; ! 22: unsigned long int evtime, oldcycles; ! 23: evfunc handler; ! 24: }; ! 25: ! 26: enum { ! 27: ev_hsync, ev_copper, ev_cia, ! 28: ev_blitter, ev_diskblk, ev_diskindex, ! 29: #ifndef DONT_WANT_SOUND ! 30: ev_aud0, ev_aud1, ev_aud2, ev_aud3, ! 31: ev_sample, ! 32: #endif ! 33: ev_max ! 34: }; ! 35: ! 36: extern struct ev eventtab[ev_max]; ! 37: ! 38: static __inline__ void events_schedule(void) ! 39: { ! 40: int i; ! 41: ! 42: unsigned long int mintime = ~0L; ! 43: for(i = 0; i < ev_max; i++) { ! 44: if (eventtab[i].active) { ! 45: unsigned long int eventtime = eventtab[i].evtime - cycles; ! 46: if (eventtime < mintime) ! 47: mintime = eventtime; ! 48: } ! 49: } ! 50: nextevent = cycles + mintime; ! 51: } ! 52: ! 53: static __inline__ void do_cycles_slow(void) ! 54: { ! 55: if ((nextevent - cycles) <= cycles_per_instruction) { ! 56: int j; ! 57: for(j = 0; j < cycles_per_instruction; j++) { ! 58: if (++cycles == nextevent) { ! 59: int i; ! 60: ! 61: for(i = 0; i < ev_max; i++) { ! 62: if (eventtab[i].active && eventtab[i].evtime == cycles) { ! 63: (*eventtab[i].handler)(); ! 64: } ! 65: } ! 66: events_schedule(); ! 67: } ! 68: } ! 69: } else { ! 70: cycles += cycles_per_instruction; ! 71: } ! 72: } ! 73: ! 74: static __inline__ void do_cycles_fast(void) ! 75: { ! 76: cycles++; ! 77: if (nextevent == cycles) { ! 78: int i; ! 79: ! 80: for(i = 0; i < ev_max; i++) { ! 81: if (eventtab[i].active && eventtab[i].evtime == cycles) { ! 82: (*eventtab[i].handler)(); ! 83: } ! 84: } ! 85: events_schedule(); ! 86: } ! 87: ! 88: } ! 89: ! 90: #ifdef FASTER_CPU ! 91: #define do_cycles do_cycles_fast ! 92: #else ! 93: #define do_cycles do_cycles_slow ! 94: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.