--- hatari/src/includes/int.h 2019/04/01 07:11:33 1.1.1.2 +++ hatari/src/includes/int.h 2019/04/01 07:15:32 1.1.1.8 @@ -9,15 +9,9 @@ #define HATARI_INT_H /* Interrupt handlers in system */ -enum +typedef enum { INTERRUPT_NULL, - -#ifdef USE_DEBUGGER - INTERRUPT_DEBUGGER, - INTERRUPT_SINGLESTEP, -#endif /*USE_DEBUGGER*/ - INTERRUPT_VIDEO_VBL, INTERRUPT_VIDEO_HBL, INTERRUPT_VIDEO_ENDLINE, @@ -27,33 +21,52 @@ enum INTERRUPT_MFP_TIMERD, INTERRUPT_IKBD_RESETTIMER, INTERRUPT_IKBD_ACIA, - + INTERRUPT_IKBD_MFP, + INTERRUPT_IKBD_AUTOSEND, + INTERRUPT_DMASOUND, + INTERRUPT_DMASOUND_MICROWIRE, + INTERRUPT_FDC, + INTERRUPT_BLITTER, + INTERRUPT_MIDI, + MAX_INTERRUPTS -}; +} interrupt_id; -/* Event timer structure - keeps next timer to occur in structure so don't need to check all entries */ -typedef struct -{ - BOOL bUsed; /* Is interrupt active? */ - int Cycles; - void *pFunction; -} INTERRUPTHANDLER; - -extern void *pIntHandlerFunctions[]; -extern int nCyclesOver; -extern int nFrameCyclesOver; + +#define INT_CPU_CYCLE 1 +#define INT_MFP_CYCLE 2 + +#define INT_CPU_TO_INTERNAL 9600 +#define INT_MFP_TO_INTERNAL 31333 + +/* Convert cpu or mfp cycles to internal cycles */ +#define INT_CONVERT_TO_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)*INT_CPU_TO_INTERNAL : (cyc)*INT_MFP_TO_INTERNAL ) +/* +#define INT_CONVERT_TO_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? cyc*INT_CPU_TO_INTERNAL :\ + ( ( (cyc*INT_MFP_TO_INTERNAL + INT_CPU_TO_INTERNAL*4 - 1) / (INT_CPU_TO_INTERNAL*4) ) * INT_CPU_TO_INTERNAL*4 ) ) +*/ + +/* Convert internal cycles to real mfp or cpu cycles */ +/* Rounding is important : for example 9500 internal is 0.98 cpu and should give 1 cpu cycle, not 0 */ +/* so we do (9500+9600-1)/9600 to get the closest higher integer */ +//#define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc+INT_CPU_TO_INTERNAL-1)/INT_CPU_TO_INTERNAL : (cyc+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL ) +#define INT_CONVERT_FROM_INTERNAL( cyc , type ) ( type == INT_CPU_CYCLE ? (cyc)/INT_CPU_TO_INTERNAL : ((cyc)+INT_MFP_TO_INTERNAL-1)/INT_MFP_TO_INTERNAL ) + + + +extern void (*PendingInterruptFunction)(void); +extern int PendingInterruptCount; extern void Int_Reset(void); -extern void Int_MemorySnapShot_Capture(BOOL bSave); -extern int Int_HandlerFunctionToID(void *pHandlerFunction); -extern void *Int_IDToHandlerFunction(int ID); -extern int Int_FindFrameCycles(void); -extern void Int_SetNewInterrupt(void); +extern void Int_MemorySnapShot_Capture(bool bSave); extern void Int_AcknowledgeInterrupt(void); -extern void Int_AddAbsoluteInterrupt(int CycleTime, int Handler); -extern void Int_AddRelativeInterrupt(int CycleTime, int Handler); -extern void Int_RemovePendingInterrupt(int Handler); -extern BOOL Int_InterruptActive(int Handler); -extern int Int_FindCyclesPassed(int Handler); +extern void Int_AddAbsoluteInterrupt(int CycleTime, int CycleType, interrupt_id Handler); +extern void Int_AddRelativeInterrupt(int CycleTime, int CycleType, interrupt_id Handler); +extern void Int_AddRelativeInterruptNoOffset(int CycleTime, int CycleType, interrupt_id Handler); +extern void Int_AddRelativeInterruptWithOffset(int CycleTime, int CycleType, interrupt_id Handler, int CycleOffset); +extern void Int_RemovePendingInterrupt(interrupt_id Handler); +extern void Int_ResumeStoppedInterrupt(interrupt_id Handler); +extern bool Int_InterruptActive(interrupt_id Handler); +extern int Int_FindCyclesPassed(interrupt_id Handler, int CycleType); #endif /* ifndef HATARI_INT_H */