From 8b27dbe623c2d38b447bdfa9c2b16c0ba5183887 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sat, 13 Sep 2014 17:01:20 +0200 Subject: [PATCH] * 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) --- libctru/include/3ds/services/gsp.h | 6 +++--- libctru/source/services/gsp.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) 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]); }