Fix rirq_sort when called from within interrupt

This commit is contained in:
drmortalwombat 2024-11-30 13:01:09 +01:00
parent c12bca7b4e
commit 907452d918
2 changed files with 12 additions and 6 deletions

View File

@ -591,7 +591,7 @@ void rirq_wait(void)
npos++; npos++;
} }
void rirq_sort(void) void rirq_sort(bool inirq)
{ {
#if 1 #if 1
byte maxr = rasterIRQRows[rasterIRQIndex[1]]; byte maxr = rasterIRQRows[rasterIRQIndex[1]];
@ -641,10 +641,15 @@ void rirq_sort(void)
#endif #endif
npos++; npos++;
if (inirq)
nextIRQ = NUM_IRQS - 1;
else
{
nextIRQ = 0; nextIRQ = 0;
byte yp = rasterIRQNext[nextIRQ]; byte yp = rasterIRQNext[nextIRQ];
if (yp != 0xff) if (yp != 0xff)
vic.raster = yp - 1; vic.raster = yp - 1;
}
} }
void rirq_start(void) void rirq_start(void)

View File

@ -180,7 +180,8 @@ void rirq_stop(void);
// Sort the raster IRQ, must be performed at the end of the frame after changing // Sort the raster IRQ, must be performed at the end of the frame after changing
// the vertical position of one of the interrupt operatins. // 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 // Wait for the last raster IRQ op to have completed. Must be called before a
// sort if the raster IRQ system is active // sort if the raster IRQ system is active