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.
This commit is contained in:
Antonio Niño Díaz 2024-01-22 02:26:57 +00:00
parent 142e1662b6
commit a57af044f4
4 changed files with 22 additions and 18 deletions

View File

@ -38,7 +38,7 @@ NE_Palette *NE_PaletteCreate(void);
/// @param path Path of the palette.
/// @param format Format of the palette.
/// @return It returns 1 on success, 0 on error.
int NE_PaletteLoadFAT(NE_Palette *pal, char *path, NE_TextureFormat format);
int NE_PaletteLoadFAT(NE_Palette *pal, const char *path, NE_TextureFormat format);
/// Assign a palette in RAM to a palette object, given its number of colors.
///
@ -47,7 +47,7 @@ int NE_PaletteLoadFAT(NE_Palette *pal, char *path, NE_TextureFormat format);
/// @param numcolor Number of colors of the palette.
/// @param format Format of the palette.
/// @return It returns 1 on success, 0 on error.
int NE_PaletteLoad(NE_Palette *pal, u16 *pointer, u16 numcolor,
int NE_PaletteLoad(NE_Palette *pal, const void *pointer, u16 numcolor,
NE_TextureFormat format);
/// Assign a palette in RAM to a palette object, given its size.
@ -60,7 +60,7 @@ int NE_PaletteLoad(NE_Palette *pal, u16 *pointer, u16 numcolor,
/// @param size Size of the palette in bytes.
/// @param format Format of the palette.
/// @return It returns 1 on success, 0 on error.
int NE_PaletteLoadSize(NE_Palette *pal, u16 *pointer, size_t size,
int NE_PaletteLoadSize(NE_Palette *pal, const void *pointer, size_t size,
NE_TextureFormat format);
/// Deletes a palette object.

View File

@ -97,7 +97,7 @@ void NE_MaterialColorDelete(NE_Material *tex);
/// @return It returns 1 on success, 0 on error.
int NE_MaterialTexLoadFAT(NE_Material *tex, NE_TextureFormat fmt,
int sizeX, int sizeY, NE_TextureFlags flags,
char *path);
const char *path);
/// Loads a texture in Texel 4x4 format from the filesystem and assigns it to a
/// material object.
@ -112,7 +112,8 @@ int NE_MaterialTexLoadFAT(NE_Material *tex, NE_TextureFormat fmt,
/// @param path1 Path of the texture file (part that goes in slot 1).
/// @return It returns 1 on success, 0 on error.
int NE_MaterialTex4x4LoadFAT(NE_Material *tex, int sizeX, int sizeY,
NE_TextureFlags flags, char *path02, char *path1);
NE_TextureFlags flags, const char *path02,
const char *path1);
/// Loads a texture from RAM and assigns it to a material object.
///
@ -140,7 +141,7 @@ int NE_MaterialTex4x4LoadFAT(NE_Material *tex, int sizeX, int sizeY,
/// @return It returns 1 on success, 0 on error.
int NE_MaterialTexLoad(NE_Material *tex, NE_TextureFormat fmt,
int sizeX, int sizeY, NE_TextureFlags flags,
void *texture);
const void *texture);
/// Loads a texture from RAM and assigns it to a material object.
///
@ -154,7 +155,8 @@ int NE_MaterialTexLoad(NE_Material *tex, NE_TextureFormat fmt,
/// @param texture1 Pointer to the texture data (part that goes in slot 1).
/// @return It returns 1 on success, 0 on error.
int NE_MaterialTex4x4Load(NE_Material *tex, int sizeX, int sizeY,
NE_TextureFlags flags, void *texture02, void *texture1);
NE_TextureFlags flags, const void *texture02,
const void *texture1);
/// Copies the texture of a material into another material.
///

View File

@ -53,7 +53,7 @@ NE_Palette *NE_PaletteCreate(void)
return NULL;
}
int NE_PaletteLoadFAT(NE_Palette *pal, char *path, NE_TextureFormat format)
int NE_PaletteLoadFAT(NE_Palette *pal, const char *path, NE_TextureFormat format)
{
if (!ne_palette_system_inited)
return 0;
@ -68,15 +68,15 @@ int NE_PaletteLoadFAT(NE_Palette *pal, char *path, NE_TextureFormat format)
return 0;
}
char *ptr = NE_FATLoadData(path);
void *ptr = NE_FATLoadData(path);
NE_AssertPointer(ptr, "Couldn't load file from FAT");
int ret = NE_PaletteLoadSize(pal, (u16 *)ptr, size, format);
int ret = NE_PaletteLoadSize(pal, ptr, size, format);
free(ptr);
return ret;
}
int NE_PaletteLoad(NE_Palette *pal, u16 *pointer, u16 numcolor,
int NE_PaletteLoad(NE_Palette *pal, const void *pointer, u16 numcolor,
NE_TextureFormat format)
{
if (!ne_palette_system_inited)
@ -127,7 +127,7 @@ int NE_PaletteLoad(NE_Palette *pal, u16 *pointer, u16 numcolor,
return 1;
}
int NE_PaletteLoadSize(NE_Palette *pal, u16 *pointer, size_t size,
int NE_PaletteLoadSize(NE_Palette *pal, const void *pointer, size_t size,
NE_TextureFormat format)
{
return NE_PaletteLoad(pal, pointer, size >> 1, format);

View File

@ -177,7 +177,7 @@ void NE_MaterialColorDelete(NE_Material *tex)
int NE_MaterialTexLoadFAT(NE_Material *tex, NE_TextureFormat fmt,
int sizeX, int sizeY, NE_TextureFlags flags,
char *path)
const char *path)
{
NE_AssertPointer(tex, "NULL material pointer");
NE_AssertPointer(path, "NULL path pointer");
@ -197,7 +197,8 @@ int NE_MaterialTexLoadFAT(NE_Material *tex, NE_TextureFormat fmt,
}
int NE_MaterialTex4x4LoadFAT(NE_Material *tex, int sizeX, int sizeY,
NE_TextureFlags flags, char *path02, char *path1)
NE_TextureFlags flags, const char *path02,
const char *path1)
{
NE_AssertPointer(tex, "NULL material pointer");
NE_AssertPointer(path02, "NULL path02 pointer");
@ -337,7 +338,8 @@ static int ne_alloc_compressed_tex(size_t size, void **slot02, void **slot1)
}
int NE_MaterialTex4x4Load(NE_Material *tex, int sizeX, int sizeY,
NE_TextureFlags flags, void *texture02, void *texture1)
NE_TextureFlags flags, const void *texture02,
const void *texture1)
{
NE_AssertPointer(tex, "NULL material pointer");
@ -422,7 +424,7 @@ int NE_MaterialTex4x4Load(NE_Material *tex, int sizeX, int sizeY,
int NE_MaterialTexLoad(NE_Material *tex, NE_TextureFormat fmt,
int sizeX, int sizeY, NE_TextureFlags flags,
void *texture)
const void *texture)
{
NE_AssertPointer(tex, "NULL material pointer");
NE_Assert(fmt != 0, "No texture format provided");
@ -433,8 +435,8 @@ int NE_MaterialTexLoad(NE_Material *tex, NE_TextureFormat fmt,
size_t size02 = (sizeX * sizeY) >> 2;
void *texture02 = texture;
void *texture1 = (void *)((uintptr_t)texture + size02);
const void *texture02 = texture;
const void *texture1 = (const void *)((uintptr_t)texture + size02);
return NE_MaterialTex4x4Load(tex, sizeX, sizeY, flags,
texture02, texture1);