Commit Graph

125 Commits

Author SHA1 Message Date
jonko0493
8932de1fff rich text: Optionally return cursor position from dry run & allow indenting text
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
The goal of the changes made in this PR is to create something with this
effect ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
    crestfallen.

In order to do this, I need to call `NE_RichTextRender3D` or
`NE_RichTextRender3DAlpha` three times: once to draw the first part of
the sentence with the white font, once to draw "Jonko" in turquoise, and
once to draw the remainder of the sentence in white again. In order to
ensure that text is being drawn in the correct location, I need the
position where the previous call stopped drawing, which leads to the
first change this PR makes: I have added a version of
`DSF_StringRenderDryRun` which accepts pointers to `final_x` and
`final_y` and stores the last position of `font->pointer_x` and
`font->pointer_y` in them and I have added a new variant of
`NE_RichTextRenderDryRun` called `NE_RichTextRenderDryRunWithPos` which
uses that DSF function and has analogous parameters.

These functions get us the position where we need to place the next
cursor, but the next issue is that currently NitroEngine and libDSF only
allow for specifying the position of the overall box to draw text in,
but not where to offset the cursor in that box. This leads to the
following problem ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
                        crestfallen.

Thus, the second change: I have introduced new versions of
`DSF_StringRender3D` and `DSF_StringRender3DAlpha` which accept an
`xStart` position that is added to the `pointerX`. Correspondingly, I
have added versions of `NE_RichTextRender3D` and
`NE_RichTextRender3DAlpha` that use these new functions as well.

Let me know if there are any issues with how I've written this (C is not
my forte, after all), but the first screenshot is this being tested in
production code.
2025-06-11 00:03:38 +01:00
Antonio Niño Díaz
86955bc0a0 rich text: Allow the number of fonts to be specified dynamically
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
This switches the rich text library from using a constant for the max
number of fonts to allowing the user to specify how many fonts should be
used dynamically. To accomplish this, a new method is introduced to the
rich text system: `NE_RichTextStartSystem`, which accepts the number of
slots to allocate. Those slots are allocated and then freed when
`NE_RichTextResetSystem` is called.

To maintain compatibility, I have not removed `NE_MAX_RICH_TEXT_FONTS`
(instead opting to mark it as deprecated), and have added functionality
to automatically call `NE_RichTextStartSystem` with that old value (8)
if the user decides to init a rich text slot before calling
`NE_RichTextStartSystem` (which would likely be the previous default
behavior).
2025-05-25 01:32:55 +02:00
jonko0493
6e1dca996c rich text: Allow the number of fonts to be specified dynamically 2025-05-24 09:37:46 -07:00
Antonio Niño Díaz
926bb4f361 docs: library: Update changelog and version number to 0.15.3 2025-03-26 18:08:47 +00:00
Antonio Niño Díaz
b67c60d5f0 docs: library: Update changelog and library version to 0.15.2 2025-01-15 18:26:00 +00:00
Antonio Niño Díaz
de9ca58286 docs: library: Update changelog and version number 2024-12-23 00:40:45 +01:00
Antonio Niño Díaz
a6738a9ab5 docs: library: Update changelog and version number 2024-12-01 12:07:51 +00:00
Antonio Niño Díaz
4642bdf982 library: Allow users to specify model transformation matrices
A manual matrix overrides scale, translation and rotation. It can be
removed to switch back to individual scale, translation and rotation.
2024-10-11 13:33:21 +02:00
Antonio Niño Díaz
26823c024f docs: library: Update changelog and bump version to 0.14.0 2024-09-10 18:18:30 +01:00
Antonio Niño Díaz
5dda97fe52 Use stdint.h types instead of libnds custom types 2024-07-29 00:09:41 +01:00
Antonio Niño Díaz
3f3e266a4f library: Implement priority setting functions in RichText
This reverts commit 48ff37231f ("library: Remove unimplemented
functions from RichText system").

I thought the 3D drawing functions took a "depth" argument, but I was
wrong. I'm re-introducing the functions (and, this time, with an actual
implementation).
2024-03-30 00:34:39 +00:00
Antonio Niño Díaz
5ce71a9b02 library: Add function to calculate rendered text size
This simply exposes DSF_StringRenderDryRun() in a way that can be easily
used with Nitro Engine.
2024-03-29 22:21:22 +00:00
Antonio Niño Díaz
48ff37231f library: Remove unimplemented functions from RichText system
They were never meant to be there, they are a copy-paste error from taking
the code of the original text system to create the original files of the
rich text system.
2024-03-29 14:56:55 +00:00
Antonio Niño Díaz
8cb10264bb library: Support setting texture coordinates in sprites
This allows you to use one single texture for multiple images, and to
specify the coordinates that a sprite needs to use so that you don't need
to keep track of them.
2024-03-24 16:14:21 +00:00
Antonio Niño Díaz
cf1a3c48e2 library: Fix build on devkitARM 2024-03-20 23:42:15 +00:00
Antonio Niño Díaz
82171bbf69 chore: Simplify copyright years in notices
Instead of listing every individual year, keep only the first and last
years.
2024-03-09 01:42:29 +00:00
Antonio Niño Díaz
636a7d73c3 library: Deprecate NE_ShadingEnable()
This has been replaced by NE_SetupToonShadingTables(), which is a more
sensible name.

A define has been added for compatibility.
2024-03-07 01:48:34 +00:00
Antonio Niño Díaz
521012d4d1 library: Add function to reset rich text system 2024-03-07 01:26:15 +00:00
Antonio Niño Díaz
dd746c0ef5 library: Allow loading font bitmaps from RAM, not just the filesystem 2024-03-07 01:20:00 +00:00
Antonio Niño Díaz
006bcf9d01 library: Add note about texture sizes for rich text 2024-03-03 19:59:49 +00:00
Antonio Niño Díaz
935c06e296 library: Add note about the replacement character 2024-03-02 18:42:00 +00:00
Antonio Niño Díaz
c0d41eabff doc: library: Increase version to 0.11.0 2024-03-02 14:21:47 +00:00
Antonio Niño Díaz
9c3bb283cc library: Add note to old text system 2024-03-02 13:14:45 +00:00
Antonio Niño Díaz
50e14b2c21 library: Add rich text support
This support relies on BMFont: https://www.angelcode.com/products/bmfont/

Nitro Engine doesn't support that format directly. Instead, it uses
LibDSF internally: https://github.com/AntonioND/libdsf
2024-03-02 13:07:44 +00:00
Antonio Niño Díaz
951f0f87ca library: Support autodeleting palettes
In many cases the developer doesn't want to keep track of palettes and
materials as two different objects. This is only required if a palette
needs to be shared between multiple materials.

In cases where there a palette is only used by one material, this new
function can be used so that the developer doesn't need to keep track of
the palette object, only the material.
2024-03-02 12:42:31 +00:00
Antonio Niño Díaz
a7f8353bac library: Set sprite size to the texture size it is assigned
What most people will want to do is to draw sprites with the same size as
the texture, so do that by default.
2024-02-28 02:50:29 +00:00
Antonio Niño Díaz
83dd805fe8 examples: library: docs: Fix "properties" typo everywhere
Function names have also been changed, but this patch adds defines to
preserve compatibility with old names for the time being.
2024-02-05 01:45:14 +00:00
Antonio Niño Díaz
4d0066465e docs: library: Update version to 0.10.0 2024-01-28 02:35:35 +00:00
Antonio Niño Díaz
640d2441f6 library: Add helper to load textures in GRF format 2024-01-25 02:42:38 +00:00
Antonio Niño Díaz
fb503d5972 library: Add deprecation notice 2024-01-25 02:05:24 +00:00
Antonio Niño Díaz
a57af044f4 library: Make some pointers void and const
It doesn't make sense to use other types because the modified functions
treat the data as a constant binary blob.
2024-01-22 02:26:57 +00:00
Antonio Niño Díaz
65b4eb55a3 library: Add alternate functions to load Texel 4x4 textures
They can be used to load textures where the 3 chunks are stored as
different files.
2024-01-21 17:00:12 +00:00
Antonio Niño Díaz
36957b04ab library: Add warning about screenshot function 2024-01-02 01:09:18 +01:00
Antonio Niño Díaz
76dc2f9901 library: Make some small functions static inline 2023-11-17 01:00:40 +01:00
Antonio Niño Díaz
6fde18d712 library: examples: Use stdint.h types 2023-11-17 01:00:40 +01:00
Antonio Niño Díaz
88e222c756 library: Add new process functions that can take arguments
The functions called by NE_Process() and NE_ProcessDual() rely on global
data to know what to draw on the screen.

The functions called by the new NE_ProcessArg() and NE_ProcessDualArg()
can take arguments passed from the caller of the process function. This way
it isn't needed to have global variables.
2023-11-17 00:46:23 +01:00
Antonio Niño Díaz
dfb5422710 docs: library: Update version number to 0.9.1 2023-11-12 01:27:31 +00:00
Antonio Niño Díaz
6408190477 chore: Fix a Doxygen comment 2023-10-19 02:04:55 +01:00
Antonio Niño Díaz
88a1e20393 docs: Update changelog and definitions for version 0.9.0 2023-10-19 01:49:39 +01:00
Antonio Niño Díaz
8445136b6b library: Implement another dual 3D Mode
This one is also stable, but it doesn't support the debug console.
2023-10-10 01:02:45 +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
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
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
bef15fb66e docs: Update changelog and definitions for version 0.8.2 2023-04-20 19:00:27 +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
b6b8792ce2 library: Improve documentation of NE_ProcessDual() 2023-01-21 13:34:50 +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
9f6c719373 library: Decouple meshes from models
Until now, a mesh was always owned by one single model. This made it
very difficult to clone models, because the mesh was always owned by one
of them. Whenever you deleted that model, the mesh was also deleted, and
all the cloned models would be unusable.

With the new system, there is a list of meshes with counters of how many
models use them. This way no matter how many models use the mesh, the
mesh will only be deleted when the last model is deleted.

In addition, in a similar way as before, a mesh has a flag that signals
if free() has to be called on the mesh data when the mesh is deleted.
This is useful when the mesh is loaded from a filesystem and stored in a
buffer allocated with malloc(), which is what Nitro Engine does.

Note that this code should be considered experimental for the time
being, until some tests are added.
2022-11-18 01:23:57 +00:00