DragonMinded / libdragon

Open source library for N64 development.
https://libdragon.dev
The Unlicense
674 stars 98 forks source link

rspq: Fix infinite loop with max command size #558

Closed snacchus closed 1 month ago

snacchus commented 1 month ago

Previously, the maximum command size was 63 words, which is one less word than the size of the command buffer in DMEM. Depending on alignment within the RDRAM buffer, commands with this maximum size could be DMA'd into the DMEM buffer at an offset of one word. In that case, the command ended exactly at the end of the DMEM buffer. Due to an optimization in rspq (which saves some IMEM), this lead to rspq refetching the commands in an infinite loop. This is now fixed by decreasing the maximum command size to 62 instead. Additionally, this makes rspq more robust by moving some magic numbers to macros and adding some (static) asserts.