mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-15 09:18:27 +00:00
Add SDL_ReadS8 and SDL_WriteS8
This commit is contained in:
parent
96bb06d9c7
commit
ef6123886e
5 changed files with 49 additions and 0 deletions
|
@ -625,6 +625,18 @@ extern SDL_DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasiz
|
|||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value);
|
||||
|
||||
/**
|
||||
* Use this function to read a signed byte from an SDL_IOStream.
|
||||
*
|
||||
* \param src the SDL_IOStream to read from
|
||||
* \param value a pointer filled in with the data read
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value);
|
||||
|
||||
/**
|
||||
* Use this function to read 16 bits of little-endian data from an
|
||||
* SDL_IOStream and return in native format.
|
||||
|
@ -837,6 +849,18 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *va
|
|||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value);
|
||||
|
||||
/**
|
||||
* Use this function to write a signed byte to an SDL_IOStream.
|
||||
*
|
||||
* \param dst the SDL_IOStream to write to
|
||||
* \param value the byte value to write
|
||||
* \returns SDL_TRUE on successful write, SDL_FALSE on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value);
|
||||
|
||||
/**
|
||||
* Use this function to write 16 bits in native format to an SDL_IOStream as
|
||||
* little-endian data.
|
||||
|
|
|
@ -615,6 +615,7 @@ SDL3_0.0.0 {
|
|||
SDL_ReadS32LE;
|
||||
SDL_ReadS64BE;
|
||||
SDL_ReadS64LE;
|
||||
SDL_ReadS8;
|
||||
SDL_ReadStorageFile;
|
||||
SDL_ReadSurfacePixel;
|
||||
SDL_ReadU16BE;
|
||||
|
@ -849,6 +850,7 @@ SDL3_0.0.0 {
|
|||
SDL_WriteS32LE;
|
||||
SDL_WriteS64BE;
|
||||
SDL_WriteS64LE;
|
||||
SDL_WriteS8;
|
||||
SDL_WriteStorageFile;
|
||||
SDL_WriteU16BE;
|
||||
SDL_WriteU16LE;
|
||||
|
|
|
@ -640,6 +640,7 @@
|
|||
#define SDL_ReadS32LE SDL_ReadS32LE_REAL
|
||||
#define SDL_ReadS64BE SDL_ReadS64BE_REAL
|
||||
#define SDL_ReadS64LE SDL_ReadS64LE_REAL
|
||||
#define SDL_ReadS8 SDL_ReadS8_REAL
|
||||
#define SDL_ReadStorageFile SDL_ReadStorageFile_REAL
|
||||
#define SDL_ReadSurfacePixel SDL_ReadSurfacePixel_REAL
|
||||
#define SDL_ReadU16BE SDL_ReadU16BE_REAL
|
||||
|
@ -874,6 +875,7 @@
|
|||
#define SDL_WriteS32LE SDL_WriteS32LE_REAL
|
||||
#define SDL_WriteS64BE SDL_WriteS64BE_REAL
|
||||
#define SDL_WriteS64LE SDL_WriteS64LE_REAL
|
||||
#define SDL_WriteS8 SDL_WriteS8_REAL
|
||||
#define SDL_WriteStorageFile SDL_WriteStorageFile_REAL
|
||||
#define SDL_WriteU16BE SDL_WriteU16BE_REAL
|
||||
#define SDL_WriteU16LE SDL_WriteU16LE_REAL
|
||||
|
|
|
@ -651,6 +651,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS32BE,(SDL_IOStream *a, Sint32 *b),(a,b),return
|
|||
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS32LE,(SDL_IOStream *a, Sint32 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS64BE,(SDL_IOStream *a, Sint64 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS64LE,(SDL_IOStream *a, Sint64 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadS8,(SDL_IOStream *a, Sint8 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ReadStorageFile,(SDL_Storage *a, const char *b, void *c, Uint64 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ReadSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU16BE,(SDL_IOStream *a, Uint16 *b),(a,b),return)
|
||||
|
@ -884,6 +885,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS32BE,(SDL_IOStream *a, Sint32 b),(a,b),return
|
|||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS32LE,(SDL_IOStream *a, Sint32 b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS64BE,(SDL_IOStream *a, Sint64 b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS64LE,(SDL_IOStream *a, Sint64 b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS8,(SDL_IOStream *a, Sint8 b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_WriteStorageFile,(SDL_Storage *a, const char *b, const void *c, Uint64 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteU16BE,(SDL_IOStream *a, Uint16 b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_WriteU16LE,(SDL_IOStream *a, Uint16 b),(a,b),return)
|
||||
|
|
|
@ -1117,6 +1117,20 @@ SDL_bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value)
|
|||
return result;
|
||||
}
|
||||
|
||||
SDL_bool SDL_ReadS8(SDL_IOStream *src, Sint8 *value)
|
||||
{
|
||||
Sint8 data = 0;
|
||||
SDL_bool result = SDL_FALSE;
|
||||
|
||||
if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) {
|
||||
result = SDL_TRUE;
|
||||
}
|
||||
if (value) {
|
||||
*value = data;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_bool SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value)
|
||||
{
|
||||
Uint16 data = 0;
|
||||
|
@ -1236,6 +1250,11 @@ SDL_bool SDL_WriteU8(SDL_IOStream *dst, Uint8 value)
|
|||
return (SDL_WriteIO(dst, &value, sizeof(value)) == sizeof(value));
|
||||
}
|
||||
|
||||
SDL_bool SDL_WriteS8(SDL_IOStream *dst, Sint8 value)
|
||||
{
|
||||
return (SDL_WriteIO(dst, &value, sizeof(value)) == sizeof(value));
|
||||
}
|
||||
|
||||
SDL_bool SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value)
|
||||
{
|
||||
const Uint16 swapped = SDL_SwapLE16(value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue