From 1b04d708de0286ed2b0b12a562cc147e43f997ed Mon Sep 17 00:00:00 2001 From: beeanyew Date: Sat, 31 Jul 2021 18:53:54 +0200 Subject: [PATCH] Revert "Simplify IRQ handling a bit" This reverts commit df0c88bf4b3c0d679ba05dfa1e5831a04cf6108d. Conflicts: emulator.c --- emulator.c | 58 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/emulator.c b/emulator.c index 0282a00..90a6435 100644 --- a/emulator.c +++ b/emulator.c @@ -116,24 +116,37 @@ uint16_t irq_delay = 0; unsigned int amiga_reset=0, amiga_reset_last=0; unsigned int do_reset=0; -pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER; -pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - void *ipl_task(void *args) { printf("IPL thread running\n"); + uint16_t old_irq = 0; uint32_t value; - pthread_mutex_lock(&lock); - while (1) { value = *(gpio + 13); + if (value & (1 << PIN_TXN_IN_PROGRESS)) + goto noppers; if (!(value & (1 << PIN_IPL_ZERO)) || ipl_enabled[amiga_emulated_ipl()]) { + old_irq = irq_delay; + //NOP if (!irq) { M68K_END_TIMESLICE; + NOP irq = 1; - pthread_cond_wait(&cond1, &lock); - irq = 0; + } + //usleep(0); + } + else { + if (irq) { + if (old_irq) { + old_irq--; + } + else { + irq = 0; + } + M68K_END_TIMESLICE; + NOP + //usleep(0); } } if(do_reset==0) @@ -145,7 +158,7 @@ void *ipl_task(void *args) { if(amiga_reset==0) { printf("Amiga Reset is down...\n"); - do_reset = 1; + do_reset=1; M68K_END_TIMESLICE; } else @@ -155,13 +168,25 @@ void *ipl_task(void *args) { } } + /*if (gayle_ide_enabled) { + if (((gayle_int & 0x80) || gayle_a4k_int) && (get_ide(0)->drive[0].intrq || get_ide(0)->drive[1].intrq)) { + //get_ide(0)->drive[0].intrq = 0; + gayleirq = 1; + M68K_END_TIMESLICE; + } + else + gayleirq = 0; + }*/ + //usleep(0); + //NOP NOP +noppers: NOP NOP NOP NOP NOP NOP NOP NOP - if (end_signal) - goto end_ipl_thread; + //NOP NOP NOP NOP NOP NOP NOP NOP + //NOP NOP NOP NOP NOP NOP NOP NOP + /*NOP NOP NOP NOP NOP NOP NOP NOP + NOP NOP NOP NOP NOP NOP NOP NOP + NOP NOP NOP NOP NOP NOP NOP NOP*/ } -end_ipl_thread: - pthread_mutex_unlock(&lock); - return args; } @@ -194,8 +219,8 @@ cpu_loop: } } - if (irq) { - last_irq = ((ps_read_status_reg() & 0xe000) >> 13); + while (irq) { + last_irq = ((inline_read_status_reg() & 0xe000) >> 13); uint8_t amiga_irq = amiga_emulated_ipl(); if (amiga_irq >= last_irq) { last_irq = amiga_irq; @@ -204,8 +229,7 @@ cpu_loop: last_last_irq = last_irq; M68K_SET_IRQ(last_irq); } - pthread_cond_signal(&cond1); - m68k_execute(state, 5); + m68k_execute(state, 50); } if (!irq && last_last_irq != 0) { M68K_SET_IRQ(0);