Commit Graph

22 Commits

Author SHA1 Message Date
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
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
6e53a01d83 library: tests: Add function to search free space within a range
This is needed to load compressed textures, as it is needed to look for
empty space in two banks at the same time.
2022-10-29 14:10:35 +01:00
Antonio Niño Díaz
63a74c71f2 library: Support allocating chunks at specified addresses 2022-10-28 01:12:42 +01:00
Antonio Niño Díaz
8d512b55f6 library: Extract common code in allocation functions 2022-10-27 23:16:49 +01:00
Antonio Niño Díaz
3b09697a91 library: tests: Add function to allocate from end of pool
Add tests for it.
2022-10-27 23:07:28 +01:00
Antonio Niño Díaz
f3f4af0daf library: Refactor allocator
Remove support for asking for a specific alignment. Now, the only
supported alignment is 16 bytes, and all sizes are rounded up to 16
bytes. This is the minimum alignment needed for some palettes, which is
the most restrictive case.

This change is a bit wasteful, but it only really matters for 4-color
palettes and textures, which can be aligned to 8 bytes, and it isn't a
problem because:

- 4-color palettes, which can be aligned to 8 bytes, would rarely use
  fewer than 4 colors. Even if they do use fewer than 4 colors, it would
  only waste 8 bytes.

- Textures: It's impossible that a texture doesn't have a size that is
  multiple of 16. It can only happen if the texture has a width of 8
  pixels and a height that isn't a multiple of two... which is a very
  unusual situation.

The benefit of this change is that the code is much easier to understand
and much more maintainable, which will be needed when support for
compressed textures is added, as the code will need to support more
features.
2022-10-27 01:14:40 +01:00
Antonio Niño Díaz
76ccdc379e library: Cleanup source code files 2022-10-16 02:58:48 +01:00
Antonio Niño Díaz
c05b5ab2e1 library: Clean code and documentation of some files 2022-10-14 02:50:35 +01:00
Antonio Niño Díaz
62bb24f88a Fix types in NEMemInfo struct 2019-06-09 20:41:38 +01:00
Antonio Niño Díaz
f26f2af79f Reduce nesting in NE_Free()
This makes it easier to read the code
2019-06-09 20:36:40 +01:00
Antonio Niño Díaz
5d6b3b706e Fix casts in NEAlloc.c
The correct integer type to hold the value of a pointer is uintptr_t.
2019-06-09 17:55:33 +01:00
Antonio Niño Díaz
c9b3321317 Fix NE_Alloc() prototype types 2019-06-09 17:45:00 +01:00
Antonio Niño Díaz
11fc7a1046 Improve readability of NE_Free() 2019-06-05 17:02:39 +01:00
Antonio Niño Díaz
6a839bb446 Simplify loop in NE_Free() 2019-06-05 16:53:58 +01:00
Antonio Niño Díaz
3cd3ff231c Improve readability of NE_Alloc() 2019-06-05 16:52:33 +01:00
Antonio Niño Díaz
976cf4d4c6 Simplify NE_DebugPrint messages
The function name is now part of the macro.
2019-06-05 14:19:04 +01:00
Antonio Niño Díaz
a9ae923fff Simplify NE_Assert messages
The function name is now part of the macro.
2019-06-05 14:06:10 +01:00
Antonio Niño Díaz
700971beef Simplify NE_AssertPointer messages
Now the name of the function is added as part of the macro.
2019-06-05 13:41:35 +01:00
Antonio Niño Díaz
5be032ed44 Fix coding style of library
With a bit of help of `indent -linux`, but mostly by hand. Also used
`iconv -f ISO-8859-1 -t UTF-8//TRANSLIT` to convert to UTF-8.

There is still some refactoring left to do.
2019-06-04 01:02:56 +01:00
Antonio Niño Díaz
8f8bf4d249 Run dos2unix on library source files 2019-05-30 18:45:00 +01:00
Antonio Niño Díaz
f042d0be3e
Initial dump of code of v0.6.1
This commit is a simple dump of the files of [1]. This needs to undergo
some reorganization.

[1] http://www.skylyrac.net/old-site/nitroengine.html
2019-05-29 01:01:57 +01:00