PIC: Offer a way for callbacks to retrieve what time they were meant to be called at

This commit is contained in:
Jonathan Campbell 2018-12-05 21:52:30 -08:00
parent 8689730070
commit 56da8f99a1
2 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,8 @@ extern Bitu PIC_Ticks;
typedef double pic_tickindex_t;
pic_tickindex_t PIC_GetCurrentEventTime(void);
static INLINE pic_tickindex_t PIC_TickIndex(void) {
return ((pic_tickindex_t)(CPU_CycleMax-CPU_CycleLeft-CPU_Cycles)) / ((pic_tickindex_t)CPU_CycleMax);
}

View File

@ -616,6 +616,13 @@ static void AddEntry(PICEntry * entry) {
static bool InEventService = false;
static pic_tickindex_t srv_lag = 0;
pic_tickindex_t PIC_GetCurrentEventTime(void) {
if (InEventService)
return (pic_tickindex_t)PIC_Ticks + srv_lag;
else
return PIC_FullIndex();
}
void PIC_AddEvent(PIC_EventHandler handler,pic_tickindex_t delay,Bitu val) {
if (GCC_UNLIKELY(!pic_queue.free_entry)) {
LOG(LOG_PIC,LOG_ERROR)("Event queue full");