void add_interupt_event(int type, unsigned int delay) { unsigned int count = Count + delay/**2*/; int special = 0; if(type == SPECIAL_INT /*|| type == COMPARE_INT*/) special = 1; if(Count > 0x80000000) SPECIAL_done = 0; if (get_event(type)) { printf("two events of type %x in queue\n", type); } interupt_queue *aux = q; if (q == NULL) { q = malloc(sizeof(interupt_queue)); q->next = NULL; q->count = count; q->type = type; next_interupt = q->count; //print_queue(); return; } if(before_event(count, q->count, q->type) && !special) { q = malloc(sizeof(interupt_queue)); q->next = aux; q->count = count; q->type = type; next_interupt = q->count; //print_queue(); return; } while (aux->next != NULL && (!before_event(count, aux->next->count, aux->next->type) || special)) aux = aux->next; if (aux->next == NULL) { aux->next = malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = NULL; aux->count = count; aux->type = type; } else { interupt_queue *aux2; if (type != SPECIAL_INT) while(aux->next != NULL && aux->next->count == count) aux = aux->next; aux2 = aux->next; aux->next = malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = aux2; aux->count = count; aux->type = type; } }
void add_interrupt_event_count(int type, unsigned int count) { struct node* event; struct node* e; int special; special = (type == SPECIAL_INT); if(g_cp0_regs[CP0_COUNT_REG] > UINT32_C(0x80000000)) SPECIAL_done = 0; if (get_event(type)) { DebugMessage(M64MSG_WARNING, "two events of type 0x%x in interrupt queue", type); } event = alloc_node(&q.pool); if (event == NULL) { DebugMessage(M64MSG_ERROR, "Failed to allocate node for new interrupt event"); return; } event->data.count = count; event->data.type = type; if (q.first == NULL) { q.first = event; event->next = NULL; next_interrupt = q.first->data.count; } else if (before_event(count, q.first->data.count, q.first->data.type) && !special) { event->next = q.first; q.first = event; next_interrupt = q.first->data.count; } else { for(e = q.first; e->next != NULL && (!before_event(count, e->next->data.count, e->next->data.type) || special); e = e->next); if (e->next == NULL) { e->next = event; event->next = NULL; } else { if (!special) for(; e->next != NULL && e->next->data.count == count; e = e->next); event->next = e->next; e->next = event; } } }
void add_interupt_event_count(int type, unsigned int count) { struct node* event; struct node* e; int special; special = (type == SPECIAL_INT); if(g_cp0_regs[CP0_COUNT_REG] > UINT32_C(0x80000000)) SPECIAL_done = 0; if (get_event(type)) { DebugMessage(M64MSG_WARNING, "two events of type 0x%x in interrupt queue", type); /* FIXME: hack-fix for freezing in Perfect Dark * http://code.google.com/p/mupen64plus/issues/detail?id=553 * https://github.com/mupen64plus-ae/mupen64plus-ae/commit/802d8f81d46705d64694d7a34010dc5f35787c7d */ return; } event = alloc_node(&q.pool); if (event == NULL) { DebugMessage(M64MSG_ERROR, "Failed to allocate node for new interrupt event"); return; } event->data.count = count; event->data.type = type; if (q.first == NULL) { q.first = event; event->next = NULL; next_interupt = q.first->data.count; } else if (before_event(count, q.first->data.count, q.first->data.type) && !special) { event->next = q.first; q.first = event; next_interupt = q.first->data.count; } else { for(e = q.first; e->next != NULL && (!before_event(count, e->next->data.count, e->next->data.type) || special); e = e->next); if (e->next == NULL) { e->next = event; event->next = NULL; } else { if (!special) for(; e->next != NULL && e->next->data.count == count; e = e->next); event->next = e->next; e->next = event; } } }
void add_interupt_event(int type, unsigned int delay) { #ifdef NEW_COUNT unsigned int count = ((Count + delay) & 0x0FFFFFFF); #else unsigned int count = Count + delay/**2*/; #endif #ifdef USE_SPECIAL int special = 0; #endif interupt_queue *aux = q; #ifdef USE_SPECIAL if(type == SPECIAL_INT /*|| type == COMPARE_INT*/) special = 1; if(Count > 0x80000000) SPECIAL_done = 0; #endif DEBUG_PRINT("add_interupt_event() type %d, at %u, Count %u\n",type,count, Count); if (get_event(type)) { DebugMessage(M64MSG_WARNING, "two events of type 0x%x in interrupt queue", type); } if (q == NULL) { q = (interupt_queue *) queue_malloc(sizeof(interupt_queue)); q->next = NULL; q->count = count; q->type = type; next_interupt = q->count; //print_queue(); return; } #ifdef USE_SPECIAL if(before_event(count, q->count, q->type) && !special) #else if(before_event(count, q->count, q->type)) #endif { q = (interupt_queue *) queue_malloc(sizeof(interupt_queue)); q->next = aux; q->count = count; q->type = type; next_interupt = q->count; //print_queue(); return; } //if not at end of list and (count is after next item of type or special) then get next #ifdef USE_SPECIAL while (aux->next != NULL && (!before_event(count, aux->next->count, aux->next->type) || special)) #else while (aux->next != NULL && (!before_event(count, aux->next->count, aux->next->type))) #endif { aux = aux->next; } if (aux->next == NULL) { aux->next = (interupt_queue *) queue_malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = NULL; aux->count = count; aux->type = type; } else { interupt_queue *aux2; #ifdef USE_SPECIAL if (type != SPECIAL_INT) #endif while(aux->next != NULL && aux->next->count == count) aux = aux->next; aux2 = aux->next; aux->next = (interupt_queue *) queue_malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = aux2; aux->count = count; aux->type = type; } }
void add_interupt_event(int type, unsigned long delay) { unsigned long count = Count + delay; int special = 0; if(type == SPECIAL_INT) { special = 1; } if(Count > 0x80000000) { SPECIAL_done = 0; } if (get_event(type)) { //printf("two events of type %x in queue\n", type); } interupt_queue *aux = q; if (q == NULL) { q = queue_malloc(sizeof(interupt_queue)); q->next = NULL; q->count = count; q->type = type; next_interupt = q->count; return; } if(before_event(count, q->count, q->type) && !special) { q = queue_malloc(sizeof(interupt_queue)); q->next = aux; q->count = count; q->type = type; next_interupt = q->count; return; } while (aux->next != NULL && (!before_event(count, aux->next->count, aux->next->type) || special)) { aux = aux->next; } if (aux->next == NULL) { aux->next = queue_malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = NULL; aux->count = count; aux->type = type; } else { interupt_queue *aux2; if (type != SPECIAL_INT) { while(aux->next != NULL && aux->next->count == count) { aux = aux->next; } } aux2 = aux->next; aux->next = queue_malloc(sizeof(interupt_queue)); aux = aux->next; aux->next = aux2; aux->count = count; aux->type = type; } }