Annotation of uae/src/include/events.h, revision 1.1.1.3

1.1       root        1:  /*
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   *
                      4:   * Events
1.1.1.3 ! root        5:   *
        !             6:   * Note that this file must be included after sound.h and sounddep/sound.h,
        !             7:   * since DONT_WANT_SOUND can get overridden in those.
        !             8:   *
        !             9:   * Copyright 1995, 1996, 1997 Bernd Schmidt
1.1       root       10:   */
                     11: 
1.1.1.3 ! root       12: extern unsigned long int cycles, nextevent, is_lastline;
        !            13: extern unsigned long int sample_evtime;
1.1       root       14: typedef void (*evfunc)(void);
                     15: 
                     16: struct ev
                     17: {
                     18:     int active;
                     19:     unsigned long int evtime, oldcycles;
                     20:     evfunc handler;
                     21: };
                     22: 
1.1.1.3 ! root       23: enum {
1.1       root       24:     ev_hsync, ev_copper, ev_cia,
                     25:     ev_blitter, ev_diskblk, ev_diskindex,
                     26: #ifndef DONT_WANT_SOUND
                     27:     ev_aud0, ev_aud1, ev_aud2, ev_aud3,
                     28:     ev_sample,
                     29: #endif
                     30:     ev_max
                     31: };
                     32: 
                     33: extern struct ev eventtab[ev_max];
                     34: 
                     35: static __inline__ void events_schedule(void)
                     36: {
                     37:     int i;
1.1.1.3 ! root       38: 
1.1       root       39:     unsigned long int mintime = ~0L;
                     40:     for(i = 0; i < ev_max; i++) {
1.1.1.3 ! root       41:        if (eventtab[i].active) {
1.1       root       42:            unsigned long int eventtime = eventtab[i].evtime - cycles;
                     43:            if (eventtime < mintime)
1.1.1.3 ! root       44:                mintime = eventtime;
1.1       root       45:        }
                     46:     }
                     47:     nextevent = cycles + mintime;
                     48: }
                     49: 
                     50: static __inline__ void do_cycles_slow(void)
                     51: {
1.1.1.3 ! root       52:     unsigned long cycles_to_add = currprefs.m68k_speed;
        !            53: 
        !            54: #ifdef FRAME_RATE_HACK
        !            55:     if (is_lastline && eventtab[ev_hsync].evtime-cycles <= cycles_to_add
        !            56:        && (long int)(read_processor_time () - vsyncmintime) < 0)
        !            57:        return;
        !            58: #endif
        !            59:     if ((nextevent - cycles) <= cycles_to_add) {
        !            60:        for (; cycles_to_add != 0; cycles_to_add--) {
1.1       root       61:            if (++cycles == nextevent) {
                     62:                int i;
1.1.1.3 ! root       63: 
1.1       root       64:                for(i = 0; i < ev_max; i++) {
                     65:                    if (eventtab[i].active && eventtab[i].evtime == cycles) {
                     66:                        (*eventtab[i].handler)();
                     67:                    }
                     68:                }
                     69:                events_schedule();
                     70:            }
                     71:        }
                     72:     }
1.1.1.3 ! root       73:     cycles += cycles_to_add;
1.1       root       74: }
                     75: 
                     76: static __inline__ void do_cycles_fast(void)
                     77: {
1.1.1.3 ! root       78: #ifdef FRAME_RATE_HACK
        !            79:     if (is_lastline && eventtab[ev_hsync].evtime-cycles <= 1
        !            80:        && (long int)(read_processor_time () - vsyncmintime) < 0)
        !            81:        return;
        !            82: #endif
1.1       root       83:     cycles++;
                     84:     if (nextevent == cycles) {
                     85:        int i;
1.1.1.3 ! root       86: 
1.1       root       87:        for(i = 0; i < ev_max; i++) {
                     88:            if (eventtab[i].active && eventtab[i].evtime == cycles) {
                     89:                (*eventtab[i].handler)();
                     90:            }
                     91:        }
                     92:        events_schedule();
                     93:     }
                     94: 
                     95: }
                     96: 
1.1.1.3 ! root       97: #if /* M68K_SPEED == 1 */  0
1.1       root       98: #define do_cycles do_cycles_fast
                     99: #else
                    100: #define do_cycles do_cycles_slow
                    101: #endif

unix.superglobalmegacorp.com

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