Commit Graph

53 Commits

Author SHA1 Message Date
ThorTuwy
e6242613c9 library: Fix 32x64 sprite size definition 2025-02-09 12:48:26 +01:00
Antonio Niño Díaz
b9cbe66d3a library: Update link to nds-hb-menu 2024-11-28 02:50:51 +00:00
Antonio Niño Díaz
d892d6cc8a library: Fix '\n' in NF_WriteText16()
Also, slightly rework the code of NF_WriteText() to match the code sytle
of the rest of the library.
2024-07-06 12:44:24 +01:00
Antonio Niño Díaz
70fe30ef29 library: Fix typo 2024-06-22 11:27:25 +01:00
BG2CNT
c5c64a5cc1
library: fix up "\n" bug in NF_WriteText 2024-06-17 22:56:46 +02:00
Antonio Niño Díaz
e6567ee10f library: Improve error checking when loading files 2024-06-03 02:20:28 +01:00
Antonio Niño Díaz
06557f1773 library: Support colmaps with extensions .map and .img
Currently it is needed to rename the extension of the collision maps
from .img and .map to .dat and .cmp for NFlib to find the files. This
patch makes it also try to load the original extensions so that the
renaming isn't required.
2023-12-24 03:05:46 +01:00
Antonio Niño Díaz
ba8ba3c3b3 library: Add helper to detect if a file exists 2023-12-24 03:05:33 +01:00
Antonio Niño Díaz
331eee9737 library: Support fonts with extension .img
Currently it is needed to rename the extension of the font to .fnt from
.img for NFlib to find the files. This patch makes it also try to load a
.img file so that the renaming isn't required.
2023-12-24 02:48:44 +01:00
Antonio Niño Díaz
05610e6f8b library: Add missing include 2023-07-15 11:28:54 +01:00
Antonio Niño Díaz
02321a1864 library: Delete 3D sprites when overwriten
When a 3D sprite is created on top of a previously created 3D sprite, it
is needed to delete the previous one. If not, the sprite count will be
incorrect.

This doesn't happen with other subsystems of the library.
2023-06-05 23:51:40 +01:00
Antonio Niño Díaz
0e185267fa library: Improve handling of 3D sprite textures
All state is set when the textures are created, there is no need to
clear it when the textures are deleted.
2023-06-05 23:47:15 +01:00
Antonio Niño Díaz
90287a7133 library: Simplify struct handling of 3D sprites
Only initialize the structure when a new sprite is created. The "inuse"
field of the struct is enough to disable it completely, and the state
is set to the default values when it is created again.
2023-06-05 21:27:13 +01:00
Antonio Niño Díaz
5c31f779c8 library: Small style fixes 2023-06-05 21:12:18 +01:00
Antonio Niño Díaz
aef2292857 library: Share most code that loads file from the filesystem
Instead of repeating the same code whenever a file needs to be loaded,
move it to a function.
2023-05-30 22:50:22 +01:00
Antonio Niño Díaz
ce24bbc52e library: Small cleanup 2023-05-30 22:48:47 +01:00
Antonio Niño Díaz
e15a8402b5 library: Cleanup memory allocation
Only call calloc() if the buffer actually needs to be zeroed. For
buffers that are going to be filled right away, malloc() is faster.
2023-05-30 01:47:45 +01:00
Antonio Niño Díaz
039eda9343 library: Replace some shifts by multiplications and divisions 2023-05-30 01:37:01 +01:00
Antonio Niño Díaz
470c39d031 library: Add copyright notice 2023-05-29 23:25:36 +01:00
Antonio Niño Díaz
021a5a0048 library: Cleanup and translate the remaining source files 2023-05-29 23:15:53 +01:00
Antonio Niño Díaz
18fc4a63ba library: Cleanup and translate more source files 2023-05-28 02:09:25 +01:00
Antonio Niño Díaz
0329934b90 library: Cleanup and translate some source files 2023-05-26 00:54:32 +01:00
Antonio Niño Díaz
0428b7a1ea library: Translate file headers 2023-05-25 22:11:19 +01:00
Antonio Niño Díaz
5280f3fe64 library: Cleanup affine background source files 2023-05-25 21:56:27 +01:00
Antonio Niño Díaz
6fc5d73d80 library: Cleanup and translate some source files 2023-05-25 02:00:31 +01:00
Antonio Niño Díaz
2f13ecd7b8 library: Cleanup and translate 256 color sprite module 2023-05-24 02:53:36 +01:00
Antonio Niño Díaz
e1506cc74f library: Cleanup of types
Types like u8 and u16 aren't always a good idea. For example:

    void function(u8 x, u8 y)
    {
        u32 value = (x << 16) | y;
    }

The left shift of x will overflow because x is 8 bits wide. It is better
to make both arguments 32 bit wide.

It may also cause the compiler to introduce bit masking operations at
the caller side because the caller doesn't know how the function
behaves internally.

In order to prevent this kind of issues, it's better to use 32 bit
variables unless there is a very good reason to use smaller types (like
in structs, to save RAM).
2023-05-24 02:53:36 +01:00
Antonio Niño Díaz
f9d6b71a40 library: Translate and cleanup more source files 2023-05-23 02:16:53 +01:00
Antonio Niño Díaz
5150862e16 library: Translate and cleanup more source files 2023-05-22 01:02:17 +01:00
Antonio Niño Díaz
dc67afb8c9 library: Translate and cleanup some source files 2023-05-21 22:29:57 +01:00
Antonio Niño Díaz
c3d6122d95 library: Mark NF_Error as noreturn 2023-05-21 22:23:21 +01:00
Antonio Niño Díaz
b31a3e7d20 library: Make some functions static inline 2023-05-15 02:15:02 +01:00
Antonio Niño Díaz
c34dbb2912 library: Remove version number from source files
This is misleading unless it's updated every single time there is a
commit, which isn't realistic.
2023-05-11 23:49:33 +01:00
Antonio Niño Díaz
0394efbf77 Small cleanup of loop variables 2023-05-03 01:48:58 +01:00
Antonio Niño Díaz
e0296e0856 Remove superfluous comments 2023-05-03 01:48:58 +01:00
Antonio Niño Díaz
54d5435650 Reorganize includes
libc includes go first, then libraries like libnds and dswifi, then
NFLib includes.
2023-05-03 01:48:58 +01:00
Antonio Niño Díaz
fe33d66d91 Remove trailing whitespace 2023-05-03 01:21:56 +01:00
Antonio Niño Díaz
080a46a5bd Fix warning incorrect type warning 2023-05-02 02:23:16 +01:00
Antonio Niño Díaz
fc0d3365b6 Move wifi helpers to the main library 2023-05-02 02:23:16 +01:00
Antonio Niño Díaz
d9d06081ca Remove PAlib definitions and use libnds instead 2023-05-01 03:17:37 +01:00
Antonio Niño Díaz
92f39078a1 library: Fix typo in function name 2023-05-01 03:02:26 +01:00
Antonio Niño Díaz
027e5579be Fix typo in "collision" everywhere
Some defines have been added to preserve backwards compatibility with
the old names.
2023-04-30 14:53:37 +01:00
Antonio Niño Díaz
c693abda87 Increase size of NF_ROOTFOLDER 2023-04-28 01:40:33 +01:00
Antonio Niño Díaz
b7efd8954b Fix remaining Wextra warning 2023-04-22 01:53:16 +01:00
Antonio Niño Díaz
0c0a9e743e Enable -Wextra
- Fix most new warnings (silence a few of them, though).

- Replace all sprintf() by the safer snprintf().
2023-04-22 01:48:47 +01:00
Antonio Niño Díaz
4a257af310 Improve detection of device that contains the NDS ROM
When accessing the filesystem, what a user normally wants is to access
the same drive that holds the NDS ROM being run.

On the DS it is easy. The only available drive is the one of the DLDI
driver.

On DSi, it isn't so easy. It is possible to run a ROM that is either on
the SD card or in a flashcard (accessed with DLDI).

The easiest way to determine the right drive to use is to use argv[0].
The loader stores the location of the NDS ROM there, including the
drive.

The trivial detection should only be used as a fallback mechanism if
argv[0] isn't present.
2023-04-19 00:47:52 +01:00
lifehackerhansol
ef23e0418a
Do not force libfilesystem or libfat dependency
This removes dependency from the (frankly awful) libfilesystem, as well
as libfat.

fatInitDefault() or nitroFSInit() should be initialized outside of
NFlib, if one requires it. Within NFLib, we will only check whether
NitroFS is accessible, and fail otherwise.

This allows a user to still use libfat, libfilesystem or any other
NitroFS / FAT implementation, should one wish to use it, as long as the
implementation of NitroFS mounts to `nitro:/`, or the storage medium is
mounted to `sd:/` or `fat:/`.

This is a breaking change: users will need to update their code to
handle NitroFS and/or FAT inits on their own.

This also removes unnecessary filesystem.h and fat.h includes from all
other files.
2023-04-13 11:30:37 -07:00
Antonio Niño Díaz
61fde2b572 Use UTF-8 across all codebase
This has been done with:

    for f in `ls`; do
        iconv -f ISO-8859-1 -t UTF-8//TRANSLIT "$f" -o "$f".2;
        mv "$f".2 "$f"
    done
2023-04-13 18:51:09 +01:00
Antonio Niño Díaz
151db13cc0 license: Fix licenses
- Creative Commons (except for CC0) shouldn't be used for code:

   https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software

   MIT has the same spirit as the CC-BY license.

- CC-BY has been retained for the assets included in the repository.

- Also, the years were wrong, this library was started in 2009.

- Make all examples use the CC0 license.
2023-04-01 19:56:45 +01:00
Antonio Niño Díaz
f3e86a56d1 build: docs: Introduce and document build system for BlocksDS
Also, some minor fixes to the examples so that they can build.
2023-04-01 19:06:03 +01:00