Annotation of hatari/src/cpu/events.h, revision 1.1.1.5

1.1       root        1:  /*
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   *
                      4:   * Events
                      5:   * These are best for low-frequency events. Having too many of them,
                      6:   * or using them for events that occur too frequently, can cause massive
                      7:   * slowdown.
                      8:   *
                      9:   * Copyright 1995-1998 Bernd Schmidt
                     10:   */
                     11: 
1.1.1.4   root       12: #ifndef UAE_EVENTS_H
                     13: #define UAE_EVENTS_H
                     14: 
                     15: #include "uae/types.h"
                     16: 
1.1       root       17: #undef EVENT_DEBUG
                     18: 
1.1.1.4   root       19: #include "machdep/rpt.h"
1.1       root       20: 
1.1.1.3   root       21: extern frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime;
                     22: extern int vsynctimebase, syncbase;
1.1       root       23: extern void reset_frame_rate_hack (void);
1.1.1.3   root       24: extern unsigned long int vsync_cycles;
                     25: extern unsigned long start_cycles;
                     26: extern int event2_count;
                     27: extern bool event_wait;
1.1       root       28: 
                     29: extern void compute_vsynctime (void);
                     30: extern void init_eventtab (void);
1.1.1.3   root       31: extern void do_cycles_ce (unsigned long cycles);
                     32: ////extern void do_cycles_ce_internal (unsigned long cycles);
1.1.1.5 ! root       33: #ifdef WINUAE_FOR_HATARI
        !            34: extern void do_cycles_ce_hatari_blitter (unsigned long cycles);
        !            35: #endif
1.1.1.3   root       36: #ifndef WINUAE_FOR_HATARI
                     37: extern void do_cycles_ce020 (unsigned long cycles);
                     38: ///extern void do_cycles_ce020_internal (unsigned long cycles);
                     39: #else
                     40: /* [NP] avoid conflict with do_cycles_ce020( int ) in cpu_prefetch.h */
                     41: extern void do_cycles_ce020_long (unsigned long cycles);
                     42: ///extern void do_cycles_ce020_internal_long (unsigned long cycles);
                     43: #endif
                     44: extern void events_schedule (void);
                     45: extern void do_cycles_slow (unsigned long cycles_to_add);
                     46: extern void do_cycles_fast (unsigned long cycles_to_add);
1.1       root       47: 
1.1.1.3   root       48: extern int is_cycle_ce (void);
1.1       root       49: 
1.1.1.3   root       50: extern unsigned long currcycle, nextevent;
                     51: extern int is_syncline, is_syncline_end;
1.1       root       52: typedef void (*evfunc)(void);
                     53: typedef void (*evfunc2)(uae_u32);
                     54: 
                     55: typedef unsigned long int evt;
                     56: 
                     57: struct ev
                     58: {
1.1.1.3   root       59:     bool active;
1.1       root       60:     evt evtime, oldcycles;
                     61:     evfunc handler;
                     62: };
                     63: 
                     64: struct ev2
                     65: {
1.1.1.3   root       66:     bool active;
1.1       root       67:     evt evtime;
                     68:     uae_u32 data;
                     69:     evfunc2 handler;
                     70: };
                     71: 
                     72: enum {
1.1.1.3   root       73:     ev_cia, ev_audio, ev_misc, ev_hsync,
1.1       root       74:     ev_max
                     75: };
                     76: 
                     77: enum {
                     78:     ev2_blitter, ev2_disk, ev2_misc,
                     79:     ev2_max = 12
                     80: };
                     81: 
1.1.1.3   root       82: #define do_cycles do_cycles_slow
                     83: 
1.1       root       84: extern struct ev eventtab[ev_max];
                     85: extern struct ev2 eventtab2[ev2_max];
                     86: 
1.1.1.3   root       87: extern int hpos_offset;
                     88: extern int maxhpos;
1.1       root       89: 
1.1.1.3   root       90: STATIC_INLINE void cycles_do_special (void)
                     91: {
1.1.1.4   root       92:        /* Currently unused in Hatari */
1.1.1.3   root       93: }
                     94: 
                     95: STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
                     96: {
1.1.1.4   root       97:        /* Currently unused in Hatari */
1.1.1.3   root       98: }
                     99: 
                    100: STATIC_INLINE unsigned long int get_cycles (void)
                    101: {
                    102:        return currcycle;
                    103: }
                    104: 
                    105: STATIC_INLINE void set_cycles (unsigned long int x)
                    106: {
                    107:        currcycle = x;
                    108:        eventtab[ev_hsync].oldcycles = x;
                    109: #ifdef EVT_DEBUG
                    110:        if (currcycle & (CYCLE_UNIT - 1))
                    111:                write_log (_T("%x\n"), currcycle);
1.1       root      112: #endif
1.1.1.3   root      113: }
1.1       root      114: 
1.1.1.3   root      115: STATIC_INLINE int current_hpos_safe (void)
                    116: {
                    117:     int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
                    118:        return hp;
                    119: }
1.1       root      120: 
1.1.1.3   root      121: extern int current_hpos(void);
1.1       root      122: 
                    123: STATIC_INLINE bool cycles_in_range (unsigned long endcycles)
                    124: {
                    125:        signed long c = get_cycles ();
                    126:        return (signed long)endcycles - c > 0;
                    127: }
                    128: 
1.1.1.3   root      129: extern void MISC_handler (void);
                    130: extern void event2_newevent_xx (int no, evt t, uae_u32 data, evfunc2 func);
1.1.1.4   root      131: extern void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func);
1.1.1.3   root      132: 
                    133: STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
                    134: {
                    135:        if (((int)t) <= 0) {
                    136:                func (data);
                    137:                return;
                    138:        }
                    139:        event2_newevent_xx (no, t * CYCLE_UNIT, data, func);
                    140: }
                    141: 
                    142: STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
                    143: {
                    144:        event2_newevent_x (no, t, data, eventtab2[no].handler);
                    145: }
                    146: STATIC_INLINE void event2_newevent2 (evt t, uae_u32 data, evfunc2 func)
                    147: {
                    148:        event2_newevent_x (-1, t, data, func);
                    149: }
                    150: 
                    151: STATIC_INLINE void event2_remevent (int no)
                    152: {
                    153:        eventtab2[no].active = 0;
                    154: }
                    155: 
1.1.1.4   root      156: #endif /* UAE_EVENTS_H */

unix.superglobalmegacorp.com

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