Instead of having a different set of functions for each dual 3D mode,
have one set of functions that is clever enough to select the right code
to run based on the initialization function.
Now that there are 4 different possibilities (not initialized, single
screen 3D mode, dual 3D mode, safe dual 3D mode) it is better to have an
enum instead of multiple bools.
Regular dual 3D mode is very unstable. As soon as you drop one frame,
the last screen to be drawn will be displayed on both screens.
This new system is a lot more complex to setup, but it's reliable, and
it doesn't need a third main VRAM bank for triple buffering, just VRAM I
to act as pseudo framebuffer.
The old dual 3D mode has been kept for compatibility.
Documentation will come soon.
Thanks to @Gericom for the tips!
Now it is possible to select if the display lists are sent with a CPU
copy or with the DMA. This is needed for a future commit that will
introduce safe dual 3D mode.
At the moment, in dual 3D mode, the VBL handler swaps the active screen.
This is wrong, because if the game framerate drops below 60 FPS the
active screen will go out of sync with the main loop (assuming that this
is where NE_ProcessDual() is called.
It makes more sense to modify the flag whenever NE_ProcessDual() is
called.
Note that dropping below 60 FPS may still desync the screens, even
swapping the top and bottom screens. This patch doesn't fix that issue,
it just opens the door to a future fix.
This was a hack that was added to make up for an incorrect 2D projection
setup. It sometimes compensated the distortion caused by that
projection in order to display the 2D sprites correctly.
Commit 193a50c939 ("library: Fix 2D projection") fixed it, so this
patch removes the hack.
The previous test only showed a couple of sizes, and the texture names
weren't very descriptive. The new test shows more sizes, and the texture
names specify their size in pixels.
The current factor of 12 is too big, and it causes significant Y axis
distortion in the 2D projection. It has been lowered to 2.
Check the comment in the code for more information.
This sprite is exactly in the bottom right corner, so it lets us check
if the projection is correct. Between this sprite and the sprite at the
top left corner it is easy to see if the projection covers the whole
screen correctly.
The previous code relied too much on assertions, even for things that
are just regular things that may happen while the application is running
(like running out of memory).
- Many assertions have been turned into permanent checks
- Some functions now return "success" or "failure".
- NE_Init3D() and NE_InitDual3D() (and others) have been reworked to
handle failures gracefully.
It was only used in sinLerp and cosLerp because in the very early days
of the library libnds didn't have the functions and the arrays SIN_LUT
and COS_LUT were used directly. When libnds was updated and it stopped
exposing the arrays Nitro Engine had to adapt. The masking wasn't needed
back then either, it was a mistake, but I forgot to remove it then.
In the case of the noise screen effect, it was just being misused.
This change is a bit pedantic, but it makes the ROMs run better in
DeSmuMe.
Some examples (particularly the dual 3D examples) used to flicker during
one or two seconds right after starting. In dual 3D examples the top and
bottom screen would start swapped, and they would eventually swap and
stop flickering. This would never happen in melonDS or real hardware.
I suspect this is because of the interaction between GFX_FLUSH and
swiWaitForVBlank(), where there would be some timing difference to reach
the first swiWaitForVBlank() or GFX_FLUSH, and that caused the desync.
This commit moves swiWaitForVBlank() to the beginning of the game loop.
This means that, even in the first iteration of the game loop, all
emulators and hardware will be synchronized. This doesn't actually
matter in any other situation, it just makes the first iteration
consistent.
Vertex color commands override normal commands, so the only way to
export color commands is to use the new "--use-vertex-color" option.
This will skip exporting normal commands and it will only export color
commands.