]> Chaos Git - corbenik/ctrulib.git/commitdiff
* Make the GSP event handler signal events in the right order (essential for proper...
authorStapleButter <thetotalworm@gmail.com>
Sat, 13 Sep 2014 15:01:20 +0000 (17:01 +0200)
committerStapleButter <thetotalworm@gmail.com>
Sat, 13 Sep 2014 15:01:20 +0000 (17:01 +0200)
* Add some comments about the GSP events (based on my observations, may not be right)

libctru/include/3ds/services/gsp.h
libctru/source/services/gsp.c

index f7ddfc22217d5fda19df45bb4e772a109bcc3ec0..d324b9a6ef14eb71a495463f437e7783beec138e 100644 (file)
@@ -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
index 7c640190eafdbf4c9ca9545f5dff2ea30c82d229..24fff1dbdb966d181407b509eb10dd965f26e871 100644 (file)
@@ -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]);
                }