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

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

unix.superglobalmegacorp.com

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