FIFO and IPC [solved]
Posted: Wed May 05, 2010 5:00 pm
Short version: Is there a way where I can still access 4 bytes of shared memory between ARM7 and ARM9 with the FIFOfied libnds?
Long version: I'm using a heavily modified ARM7 core for my new version of Colors!. Basically, what it does is that it with maximum speed reads input (>500Hz) from the touch screen. It uses this massive amount of data to automatically build up a statistics-table used to compensate for uneven pressure across the screen. It also resample this data down to around 60Hz creating nice stylus-jump free stylus input, that increases in frequency if the user moves very fast with elaborate movement, as well as decreases if not. I'm using a FIFO user-call to send this over to ARM9.
First off, as ARM9 sometimes can be busy, and can't receive this input for a bunch of frames, it can happen that the FIFO buffer overflows, which causes the ARM7 to lockup or crash. Is this a bug or to be expected? I worked around that by sending back ACKs from the ARM9, so that the ARM7 knows when data is received, and won't try to push data if it's already too much in the queue. There is probably a better solution, right? Can I check on ARM7 how much is in the buffer?
Secondly, while I'm using the FIFO for queuing up the input, letting the ARM9 poll and process it as quickly it can, I sometimes also want the absolutely most recent position for preview purposes, even though there is a bunch of input waiting to be processed. Dumping over the 500Hz input data to have the ARM9 discard 90% of it and just pick the latest one doesn't work (due to the queue full problem above, but is also a waste of processing). So I was hoping to be able to use 4 bytes from the IPC/TransferRegion and constantly write the most recent input into those bytes, so the ARM9 can grab it whenever it need to. With the proper FIFO introduction to libnds (which is great), that doesn't seem possible to do anymore. Or can I expose it somehow?
Finally, in case you are wondering why I'm going through these lengths to just get some input. I'm a huge fan of reducing latency, and there is a noticeable difference between 60Hz input, which gives 17ms latency (last version of Colors!), and a latency of close to 0 (new version of Colors!). (Obviously, this doesn't take how the screen's scan-lining process adds up to 17ms latency as well, but since my vsync is off, the best case is till that the latency can still be zero, even if it's just for an instant . Minimum latency has been a holy grail of mine. Getting close to 0 latency is not possible on PC, iPhone or any other platform that I have worked on, but it _is_ possible for homebrew DS. I've seen it - felt it - working, and it's wonderful
Long version: I'm using a heavily modified ARM7 core for my new version of Colors!. Basically, what it does is that it with maximum speed reads input (>500Hz) from the touch screen. It uses this massive amount of data to automatically build up a statistics-table used to compensate for uneven pressure across the screen. It also resample this data down to around 60Hz creating nice stylus-jump free stylus input, that increases in frequency if the user moves very fast with elaborate movement, as well as decreases if not. I'm using a FIFO user-call to send this over to ARM9.
First off, as ARM9 sometimes can be busy, and can't receive this input for a bunch of frames, it can happen that the FIFO buffer overflows, which causes the ARM7 to lockup or crash. Is this a bug or to be expected? I worked around that by sending back ACKs from the ARM9, so that the ARM7 knows when data is received, and won't try to push data if it's already too much in the queue. There is probably a better solution, right? Can I check on ARM7 how much is in the buffer?
Secondly, while I'm using the FIFO for queuing up the input, letting the ARM9 poll and process it as quickly it can, I sometimes also want the absolutely most recent position for preview purposes, even though there is a bunch of input waiting to be processed. Dumping over the 500Hz input data to have the ARM9 discard 90% of it and just pick the latest one doesn't work (due to the queue full problem above, but is also a waste of processing). So I was hoping to be able to use 4 bytes from the IPC/TransferRegion and constantly write the most recent input into those bytes, so the ARM9 can grab it whenever it need to. With the proper FIFO introduction to libnds (which is great), that doesn't seem possible to do anymore. Or can I expose it somehow?
Finally, in case you are wondering why I'm going through these lengths to just get some input. I'm a huge fan of reducing latency, and there is a noticeable difference between 60Hz input, which gives 17ms latency (last version of Colors!), and a latency of close to 0 (new version of Colors!). (Obviously, this doesn't take how the screen's scan-lining process adds up to 17ms latency as well, but since my vsync is off, the best case is till that the latency can still be zero, even if it's just for an instant . Minimum latency has been a holy grail of mine. Getting close to 0 latency is not possible on PC, iPhone or any other platform that I have worked on, but it _is_ possible for homebrew DS. I've seen it - felt it - working, and it's wonderful