Jo Engine  2024.04.28
Jo Sega Saturn Engine
Data Structures | Macros | Enumerations | Functions | Variables
tools.h File Reference

Jo Engine Tools (printf, etc,) More...

#include "math.h"

Go to the source code of this file.

Data Structures

struct  jo_datetime
 DateTime struct. More...
 

Macros

#define JO_FIXED_TV_WIDTH
 Fixed value of JO_TV_WIDTH. More...
 
#define JO_FIXED_TV_HEIGHT
 Fixed value of JO_TV_HEIGHT. More...
 
#define jo_printf_debug(X, Y, fmt, args...)
 
#define JO_NULL
 NULL implementation. More...
 
#define JO_UNUSED_ARG(ARG)
 Mark function argument as unused. More...
 

Enumerations

enum  jo_language {
  English, Deutsch, French, Espanol,
  Italiano, Japanese
}
 Language type. More...
 
enum  jo_horizontal_move { None, Left, Right }
 Horizontal move. More...
 

Functions

static __jo_force_inline short jo_swap_endian_short (short value)
 Swap Short endian. More...
 
static __jo_force_inline unsigned short jo_swap_endian_ushort (unsigned short value)
 Swap Unsigned short endian. More...
 
static __jo_force_inline unsigned int jo_swap_endian_uint (unsigned int value)
 Swap unsigned int endian. More...
 
static __jo_force_inline int jo_swap_endian_int (int value)
 Swap int endian. More...
 
int sprintf (char *str, const char *format,...)
 sprintf prototypes More...
 
static __jo_force_inline void jo_dma_copy (void *src, void *dest, unsigned int size)
 DMA copy. More...
 
static __jo_force_inline bool jo_tools_is_whitespace (const char c)
 Check if the character is a whitespace. More...
 
static __jo_force_inline int jo_4_char_hash (const char *const str)
 Create an hash code based on the first four character of the string. More...
 
jo_language jo_get_current_language (void)
 Get Sega saturn current language. More...
 
void jo_getdate (jo_datetime *now)
 get current date and time More...
 
int jo_tools_atoi (const char *restrict str)
 atoi implementation More...
 
int jo_strlen (const char *restrict str)
 strlen implementation More...
 
int jo_strcmp (const char *restrict p1, const char *restrict p2)
 strcmp implementation More...
 
static __jo_force_inline bool jo_string_equals (const char *restrict p1, const char *restrict p2)
 Determine if two string equals. More...
 
bool jo_endwith (const char *restrict str, const char *restrict end)
 determine if str end with a specific string More...
 
void jo_memset (const void *const restrict ptr, const int value, unsigned int num)
 Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char) More...
 
static __jo_force_inline void jo_yield (void)
 Little pause possible. More...
 
static __jo_force_inline void jo_spin_wait (int iterations)
 Causes "a thread" to wait the number of times defined by the iterations parameter. More...
 
void jo_map_to_vram (unsigned short *restrict data, unsigned short *restrict vram_addr, unsigned short suuj, unsigned short suui, unsigned short palnum, unsigned int mapoff)
 Copies the image map data to VRAM. More...
 
static __jo_force_inline void jo_cell_to_vram (unsigned char *restrict data, unsigned char *restrict vram_addr, unsigned int size)
 Copies the image cel data to VRAM. More...
 

Variables

char __jo_sprintf_buf [JO_PRINTF_BUF_SIZE]
 Internal sprintf buffer. More...
 

Detailed Description

Jo Engine Tools (printf, etc,)

Author
Johannes Fetz
Bug:
No known bugs.

Data Structure Documentation

◆ jo_datetime

struct jo_datetime

DateTime struct.

Data Fields
unsigned char day
unsigned char hour
unsigned char minute
unsigned char month
unsigned char second
unsigned char week
unsigned short year

Macro Definition Documentation

◆ JO_FIXED_TV_HEIGHT

#define JO_FIXED_TV_HEIGHT

Fixed value of JO_TV_HEIGHT.

◆ JO_FIXED_TV_WIDTH

#define JO_FIXED_TV_WIDTH

Fixed value of JO_TV_WIDTH.

◆ JO_NULL

#define JO_NULL

NULL implementation.

◆ jo_printf_debug

#define jo_printf_debug (   X,
  Y,
  fmt,
  args... 
)

◆ JO_UNUSED_ARG

#define JO_UNUSED_ARG (   ARG)

Mark function argument as unused.

Enumeration Type Documentation

◆ jo_horizontal_move

Horizontal move.

Enumerator
None 
Left 
Right 

◆ jo_language

Language type.

Enumerator
English 
Deutsch 
French 
Espanol 
Italiano 
Japanese 

Function Documentation

◆ jo_4_char_hash()

static __jo_force_inline int jo_4_char_hash ( const char *const  str)
static

Create an hash code based on the first four character of the string.

Parameters
strString
Returns
the hashcode (integer)

◆ jo_cell_to_vram()

static __jo_force_inline void jo_cell_to_vram ( unsigned char *restrict  data,
unsigned char *restrict  vram_addr,
unsigned int  size 
)
static

Copies the image cel data to VRAM.

Parameters
dataData source
vram_addrVRAM address
sizeData size

◆ jo_dma_copy()

static __jo_force_inline void jo_dma_copy ( void *  src,
void *  dest,
unsigned int  size 
)
static

DMA copy.

Parameters
srcData source
destDestination
sizeSize of source
Todo:
Implementation without SGL

◆ jo_endwith()

bool jo_endwith ( const char *restrict  str,
const char *restrict  end 
)

determine if str end with a specific string

Parameters
strThis is the string
endThe ending string
Returns
This function returns true if str end with "end" param otherwise false

◆ jo_get_current_language()

jo_language jo_get_current_language ( void  )

Get Sega saturn current language.

Returns
The language

◆ jo_getdate()

void jo_getdate ( jo_datetime now)

get current date and time

Parameters
nowresult

◆ jo_map_to_vram()

void jo_map_to_vram ( unsigned short *restrict  data,
unsigned short *restrict  vram_addr,
unsigned short  suuj,
unsigned short  suui,
unsigned short  palnum,
unsigned int  mapoff 
)

Copies the image map data to VRAM.

Parameters
dataData source
vram_addrVRAM address
suuiSUUI
suujSUUJ
palnumPalette number
mapoffMapOff

◆ jo_memset()

void jo_memset ( const void *const restrict  ptr,
const int  value,
unsigned int  num 
)

Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char)

Parameters
ptrPointer to the block of memory to fill.
valueValue to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value.
numNumber of bytes to be set to the value.
Remarks
No return value in this implementation

◆ jo_spin_wait()

static __jo_force_inline void jo_spin_wait ( int  iterations)
static

Causes "a thread" to wait the number of times defined by the iterations parameter.

Parameters
iterationsdefines how long "a thread" is to wait

◆ jo_strcmp()

int jo_strcmp ( const char *restrict  p1,
const char *restrict  p2 
)

strcmp implementation

Parameters
p1First string
p2Second string
Returns
Compare p1 and p2, returning less than, equal to or greater than zero if p1 is lexicographically less than, equal to or greater than p2.

◆ jo_string_equals()

static __jo_force_inline bool jo_string_equals ( const char *restrict  p1,
const char *restrict  p2 
)
static

Determine if two string equals.

Parameters
p1First string
p2Second string
Returns
True if p1 and p2 is the same

◆ jo_strlen()

int jo_strlen ( const char *restrict  str)

strlen implementation

Parameters
strThis is the string
Returns
This function returns the length of str

◆ jo_swap_endian_int()

static __jo_force_inline int jo_swap_endian_int ( int  value)
static

Swap int endian.

Parameters
valueLittle or Big endian int
Returns
Endian swapped int

◆ jo_swap_endian_short()

static __jo_force_inline short jo_swap_endian_short ( short  value)
static

Swap Short endian.

Parameters
valueLittle or Big endian short
Returns
Endian swapped short

◆ jo_swap_endian_uint()

static __jo_force_inline unsigned int jo_swap_endian_uint ( unsigned int  value)
static

Swap unsigned int endian.

Parameters
valueLittle or Big endian unsigned int
Returns
Endian swapped unsigned int

◆ jo_swap_endian_ushort()

static __jo_force_inline unsigned short jo_swap_endian_ushort ( unsigned short  value)
static

Swap Unsigned short endian.

Parameters
valueLittle or Big endian unsigned short
Returns
Endian swapped unsigned short

◆ jo_tools_atoi()

int jo_tools_atoi ( const char *restrict  str)

atoi implementation

Parameters
strThis is the string representation of an integral number
Returns
This function returns the converted integral number as an int value. If no valid conversion could be performed, it returns zero

◆ jo_tools_is_whitespace()

static __jo_force_inline bool jo_tools_is_whitespace ( const char  c)
static

Check if the character is a whitespace.

Parameters
cvariable of char type
Returns
true if the character is a whitespace otherwise false

◆ jo_yield()

static __jo_force_inline void jo_yield ( void  )
static

Little pause possible.

◆ sprintf()

int sprintf ( char *  str,
const char *  format,
  ... 
)

sprintf prototypes

Parameters
strString
formatFormat string
...Arguments
Returns
If successful, the total number of characters written is returned excluding the null-character appended at the end of the string, otherwise a negative number is returned in case of failure.

Variable Documentation

◆ __jo_sprintf_buf

char __jo_sprintf_buf[JO_PRINTF_BUF_SIZE]

Internal sprintf buffer.

Warning
MC Hammer: don't touch this