diff --git a/include/c64/rasterirq.c b/include/c64/rasterirq.c index 9807961..2c7a1d5 100644 --- a/include/c64/rasterirq.c +++ b/include/c64/rasterirq.c @@ -591,7 +591,7 @@ void rirq_wait(void) npos++; } -void rirq_sort(void) +void rirq_sort(bool inirq) { #if 1 byte maxr = rasterIRQRows[rasterIRQIndex[1]]; @@ -641,10 +641,15 @@ void rirq_sort(void) #endif npos++; - nextIRQ = 0; - byte yp = rasterIRQNext[nextIRQ]; - if (yp != 0xff) - vic.raster = yp - 1; + if (inirq) + nextIRQ = NUM_IRQS - 1; + else + { + nextIRQ = 0; + byte yp = rasterIRQNext[nextIRQ]; + if (yp != 0xff) + vic.raster = yp - 1; + } } void rirq_start(void) diff --git a/include/c64/rasterirq.h b/include/c64/rasterirq.h index cc78bdc..07c4919 100644 --- a/include/c64/rasterirq.h +++ b/include/c64/rasterirq.h @@ -180,7 +180,8 @@ void rirq_stop(void); // Sort the raster IRQ, must be performed at the end of the frame after changing // the vertical position of one of the interrupt operatins. -void rirq_sort(void); +// Set the inirq flag to true when calling this from an interrupt +void rirq_sort(bool inirq = false); // Wait for the last raster IRQ op to have completed. Must be called before a // sort if the raster IRQ system is active