From: StapleButter Date: Sat, 13 Sep 2014 15:01:20 +0000 (+0200) Subject: * Make the GSP event handler signal events in the right order (essential for proper... X-Git-Tag: v0.2.0~83^2~3 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=8b27dbe623c2d38b447bdfa9c2b16c0ba5183887;p=corbenik%2Fctrulib.git * Make the GSP event handler signal events in the right order (essential for proper PICA200 sync) * Add some comments about the GSP events (based on my observations, may not be right) --- diff --git a/libctru/include/3ds/services/gsp.h b/libctru/include/3ds/services/gsp.h index f7ddfc2..d324b9a 100644 --- a/libctru/include/3ds/services/gsp.h +++ b/libctru/include/3ds/services/gsp.h @@ -37,12 +37,12 @@ typedef struct typedef enum { - GSPEVENT_PSC0 = 0, + GSPEVENT_PSC0 = 0, // memory fill completed GSPEVENT_PSC1, GSPEVENT_VBlank0, GSPEVENT_VBlank1, - GSPEVENT_PPF, - GSPEVENT_P3D, + GSPEVENT_PPF, // display transfer finished + GSPEVENT_P3D, // command list processing finished GSPEVENT_DMA, GSPEVENT_MAX, // used to know how many events there are diff --git a/libctru/source/services/gsp.c b/libctru/source/services/gsp.c index 7c64019..24fff1d 100644 --- a/libctru/source/services/gsp.c +++ b/libctru/source/services/gsp.c @@ -85,15 +85,15 @@ void gspEventThreadMain(u32 arg) svcClearEvent(gspEvent); int count = gspEventData[1]; - int last = gspEventData[0] + count; + int cur = gspEventData[0]; + int last = cur + count; while (last >= 0x34) last -= 0x34; - int cur = last; int i; for (i = 0; i < count; i ++) { int curEvt = gspEventData[0xC + cur]; - cur --; - if (cur < 0) cur += 0x34; + cur ++; + if (cur >= 0x34) cur -= 0x34; if (curEvt >= GSPEVENT_MAX) continue; svcSignalEvent(gspEvents[curEvt]); }