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

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);
                     33: #ifndef WINUAE_FOR_HATARI
                     34: extern void do_cycles_ce020 (unsigned long cycles);
                     35: ///extern void do_cycles_ce020_internal (unsigned long cycles);
                     36: #else
                     37: /* [NP] avoid conflict with do_cycles_ce020( int ) in cpu_prefetch.h */
                     38: extern void do_cycles_ce020_long (unsigned long cycles);
                     39: ///extern void do_cycles_ce020_internal_long (unsigned long cycles);
                     40: #endif
                     41: extern void events_schedule (void);
                     42: extern void do_cycles_slow (unsigned long cycles_to_add);
                     43: extern void do_cycles_fast (unsigned long cycles_to_add);
1.1       root       44: 
1.1.1.3   root       45: extern int is_cycle_ce (void);
1.1       root       46: 
1.1.1.3   root       47: extern unsigned long currcycle, nextevent;
                     48: extern int is_syncline, is_syncline_end;
1.1       root       49: typedef void (*evfunc)(void);
                     50: typedef void (*evfunc2)(uae_u32);
                     51: 
                     52: typedef unsigned long int evt;
                     53: 
                     54: struct ev
                     55: {
1.1.1.3   root       56:     bool active;
1.1       root       57:     evt evtime, oldcycles;
                     58:     evfunc handler;
                     59: };
                     60: 
                     61: struct ev2
                     62: {
1.1.1.3   root       63:     bool active;
1.1       root       64:     evt evtime;
                     65:     uae_u32 data;
                     66:     evfunc2 handler;
                     67: };
                     68: 
                     69: enum {
1.1.1.3   root       70:     ev_cia, ev_audio, ev_misc, ev_hsync,
1.1       root       71:     ev_max
                     72: };
                     73: 
                     74: enum {
                     75:     ev2_blitter, ev2_disk, ev2_misc,
                     76:     ev2_max = 12
                     77: };
                     78: 
1.1.1.3   root       79: #define do_cycles do_cycles_slow
                     80: 
1.1       root       81: extern struct ev eventtab[ev_max];
                     82: extern struct ev2 eventtab2[ev2_max];
                     83: 
1.1.1.3   root       84: extern int hpos_offset;
                     85: extern int maxhpos;
1.1       root       86: 
1.1.1.3   root       87: STATIC_INLINE void cycles_do_special (void)
                     88: {
1.1.1.4 ! root       89:        /* Currently unused in Hatari */
1.1.1.3   root       90: }
                     91: 
                     92: STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
                     93: {
1.1.1.4 ! root       94:        /* Currently unused in Hatari */
1.1.1.3   root       95: }
                     96: 
                     97: STATIC_INLINE unsigned long int get_cycles (void)
                     98: {
                     99:        return currcycle;
                    100: }
                    101: 
                    102: STATIC_INLINE void set_cycles (unsigned long int x)
                    103: {
                    104:        currcycle = x;
                    105:        eventtab[ev_hsync].oldcycles = x;
                    106: #ifdef EVT_DEBUG
                    107:        if (currcycle & (CYCLE_UNIT - 1))
                    108:                write_log (_T("%x\n"), currcycle);
1.1       root      109: #endif
1.1.1.3   root      110: }
1.1       root      111: 
1.1.1.3   root      112: STATIC_INLINE int current_hpos_safe (void)
                    113: {
                    114:     int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
                    115:        return hp;
                    116: }
1.1       root      117: 
1.1.1.3   root      118: extern int current_hpos(void);
1.1       root      119: 
                    120: STATIC_INLINE bool cycles_in_range (unsigned long endcycles)
                    121: {
                    122:        signed long c = get_cycles ();
                    123:        return (signed long)endcycles - c > 0;
                    124: }
                    125: 
1.1.1.3   root      126: extern void MISC_handler (void);
                    127: extern void event2_newevent_xx (int no, evt t, uae_u32 data, evfunc2 func);
1.1.1.4 ! root      128: extern void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func);
1.1.1.3   root      129: 
                    130: STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
                    131: {
                    132:        if (((int)t) <= 0) {
                    133:                func (data);
                    134:                return;
                    135:        }
                    136:        event2_newevent_xx (no, t * CYCLE_UNIT, data, func);
                    137: }
                    138: 
                    139: STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
                    140: {
                    141:        event2_newevent_x (no, t, data, eventtab2[no].handler);
                    142: }
                    143: STATIC_INLINE void event2_newevent2 (evt t, uae_u32 data, evfunc2 func)
                    144: {
                    145:        event2_newevent_x (-1, t, data, func);
                    146: }
                    147: 
                    148: STATIC_INLINE void event2_remevent (int no)
                    149: {
                    150:        eventtab2[no].active = 0;
                    151: }
                    152: 
1.1.1.4 ! root      153: #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.