Annotation of uae/include/events.h, revision 1.1.1.2

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
1.1.1.2 ! root       17: #if !defined(NO_FAST_BLITTER)
1.1       root       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: {
1.1.1.2 ! root       26:     int active;
1.1       root       27:     unsigned long int evtime, oldcycles;
                     28:     evfunc handler;
                     29: };
                     30: 
                     31: enum { 
1.1.1.2 ! root       32:     ev_hsync, ev_copper, ev_cia,
1.1       root       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;
1.1.1.2 ! root       47:     for(i = 0; i < ev_max; i++) {
1.1       root       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:                
1.1.1.2 ! root       66:                for(i = 0; i < ev_max; i++) {
1.1       root       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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.