Commit Graph

465 Commits

Author SHA1 Message Date
Antonio Niño Díaz
efaf04dadd library: Cleanup of NE shutdown code
Make sure to disable the DMA when leaving dual 3D DMA mode!
2023-10-10 01:02:01 +01:00
Antonio Niño Díaz
50091b0111 library: Use standard libc types 2023-10-09 23:00:02 +01:00
Antonio Niño Díaz
0d5bd874e8 examples: library: Simplify dual 3D mode selection
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.
2023-10-09 22:58:10 +01:00
Antonio Niño Díaz
e1662b7357 library: Refactor library initialization state handling
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.
2023-10-09 01:32:06 +01:00
Antonio Niño Díaz
16258d711f examples: Add safe dual 3D examples 2023-10-09 01:32:06 +01:00
Antonio Niño Díaz
302c22241e examples: Always enable debug console in the templates 2023-10-09 01:32:06 +01:00
Antonio Niño Díaz
b66bf16f6f examples: Update dual 3D template to use safe dual 3D 2023-10-09 01:32:06 +01:00
Antonio Niño Díaz
7915ee80d3 library: Introduce safe dual 3D mode
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!
2023-10-09 01:31:56 +01:00
Antonio Niño Díaz
814fce2f97 library: Let user choose how to draw display lists
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.
2023-10-09 00:59:23 +01:00
Antonio Niño Díaz
3fbdc28df0 examples: Fix build of NFlib template in devkitPro
filesystem.h doesn't include stdbool.h in devkitPro, but it does in
BlocksDS.
2023-10-09 00:53:05 +01:00
Antonio Niño Díaz
4dc5b0e58c library: Fix version string 2023-10-08 02:54:31 +01:00
Antonio Niño Díaz
3ec49a1d79 library: Swap active screen in dual 3D mode correctly
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.
2023-09-26 01:43:15 +01:00
Antonio Niño Díaz
ee37e7fefc library: Remove texcoord offset when drawing 2D quads
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.
2023-09-25 02:28:59 +01:00
Antonio Niño Díaz
2d95590b12 examples: Test more 2D sprite sizes in example
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.
2023-09-25 02:28:59 +01:00
Antonio Niño Díaz
635b52b70c library: Clarify code that sets LCD position
The libnds function calls are easier to understand.
2023-09-10 02:00:48 +02:00
Antonio Niño Díaz
db33780b45 examples: Fix type of a variable 2023-07-16 13:50:51 +01:00
Antonio Niño Díaz
193a50c939 library: Fix 2D projection
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.
2023-07-16 13:50:51 +01:00
Antonio Niño Díaz
8441e9d05e examples: Draw additional sprite in sprites example
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.
2023-07-16 13:50:51 +01:00
Antonio Niño Díaz
f0983a32af docs: Change a few parameters of the Doxyfile 2023-07-16 13:50:51 +01:00
Antonio Niño Díaz
93817c200e examples: Remove outdated warning about NFlib integration 2023-05-09 03:17:29 +02:00
Antonio Niño Díaz
f57fa76576 library: Handle failures 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.
2023-04-21 18:19:02 +01:00
Antonio Niño Díaz
1dd798f250 examples: Truncate NitroFAT filesystem
This was disabled some time ago because the truncate option wasn't
reliable.
2023-04-21 18:04:19 +01:00
Antonio Niño Díaz
3dea475071 examples: Fix build of error handling example in BlocksDS 2023-04-21 18:04:06 +01:00
Antonio Niño Díaz
d1fb135ca0 build: Fix build of the debug version of the library 2023-04-21 18:00:23 +01:00
Antonio Niño Díaz
9537c667a5 docs: Update Doxyfile
Fix Doxygen warnings.
2023-04-20 19:11:56 +01:00
Antonio Niño Díaz
b2e2e75d70 library: Fix bitmask 2023-04-20 19:02:00 +01:00
Antonio Niño Díaz
bef15fb66e docs: Update changelog and definitions for version 0.8.2 2023-04-20 19:00:27 +01:00
Antonio Niño Díaz
9db4c5d61b library: Stop relying on LUT_MASK
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.
2023-04-20 18:25:46 +01:00
awmc000
f27d823a1e
added brief img2ds readme (#17) 2023-04-18 23:10:36 +01:00
Antonio Niño Díaz
4f03b1be5e examples: Fix NFLib template
After a recent change [1] it is required to start the filesystem
manually before initializing NFLib.

[1] ef23e0418a
2023-04-16 12:51:40 +01:00
awmc000
824cb8c4be
Copy/paste error - NE_HBLFunc() is not for vblank? 2023-04-15 13:08:39 -07:00
Antonio Niño Díaz
d659bc8915 build: docs: Support BlocksDS 2023-04-01 15:15:02 +01:00
Antonio Niño Díaz
d044d8c19f tests: Fix assets script 2023-04-01 14:55:07 +01:00
Antonio Niño Díaz
070c9ec083 templates: Remove copy of NFlib
Use the version installed in the system instead.
2023-04-01 14:45:03 +01:00
Antonio Niño Díaz
0622a1d110 examples: Fix typo in example folder name 2023-04-01 14:42:09 +01:00
Antonio Niño Díaz
43a882e98f examples: Start adapting examples for BlocksDS
iprintf() is only present in newlib, not picolibc. It is a non-standard
function, so avoid using it.
2023-04-01 14:39:58 +01:00
Antonio Niño Díaz
8c42302c23 build: Small changes to assets.sh scripts and ROM titles 2023-04-01 14:35:09 +01:00
Antonio Niño Díaz
e3e7c8263d examples: Update animated model files for new md5_to_dsma 2023-04-01 14:35:09 +01:00
Antonio Niño Díaz
704ddfa031 tools: md5_to_dsma: Remove additional dots in created files
Extensions such as ".dsa.bin" can cause problems, turn them into
"_dsa.bin".
2023-04-01 13:57:44 +01:00
Antonio Niño Díaz
820f0fe0c6 docs: Typo 2023-04-01 13:34:21 +01:00
Antonio Niño Díaz
00568feec2 build: Add scripts to build assets in all examples 2023-04-01 13:33:38 +01:00
Antonio Niño Díaz
ba1da50c8a examples: Rename two examples 2023-01-21 19:37:11 +00:00
Antonio Niño Díaz
1acfca1a24 examples: Wait for VBL in the right place
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.
2023-01-21 19:32:02 +00:00
Antonio Niño Díaz
7b67161249 examples: Replace function to set 3D screen
The changes are needed after the following commit:

f246c157f4 ("library: Refactor code that sets the main screen")
2023-01-21 19:31:29 +00:00
Antonio Niño Díaz
d8c45416be library: examples: Fix clear BMP scroll function
It was easy to pass a value bigger than a byte for X and affect both
coordinates.
2023-01-21 19:14:10 +00:00
Antonio Niño Díaz
b6b8792ce2 library: Improve documentation of NE_ProcessDual() 2023-01-21 13:34:50 +00:00
Antonio Niño Díaz
9b13d61d15 examples: Add examples about swapping the main screen 2023-01-21 13:14:21 +00:00
Antonio Niño Díaz
f246c157f4 library: Refactor code that sets the main screen
The old system wasn't super clear about which screen was which. It also
relied on libnds functions, but the new system doesn't.
2023-01-21 13:12:20 +00:00
Antonio Niño Díaz
7c614177f7 examples: Add example of OBJ model with color commands 2023-01-18 01:50:40 +00:00
Antonio Niño Díaz
207feca7fc tools: obj2dl: Support vertex color commands
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.
2023-01-18 01:50:19 +00:00