Jo Engine  9
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_printf_debug(X, Y, fmt, args...)
 
#define jo_printf(X, Y, ...)
 printf implementation More...
 
#define jo_printf_with_color(X, Y, COLOR_INDEX, ...)
 printf implementation More...
 
#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 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...
 
void jo_print (int x, int y, char *str)
 
static __jo_force_inline void jo_set_printf_palette_color (const unsigned char index, const unsigned short color)
 Set foreground palette color for the specific index. More...
 
static __jo_force_inline void jo_set_printf_color_index (const unsigned char index)
 Set printf foreground color index. 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_clear_screen (void)
 Clear screen (usefull for printf) 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...
 
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_palette_to_cram (unsigned short *restrict data, unsigned short *restrict cram_addr, unsigned int size)
 Copies the image palette data to CRAM. 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...
 
unsigned char __jo_printf_current_palette_index
 

Detailed Description

Jo Engine Tools (printf, etc,)

Author
Johannes Fetz
Bug:
No known bugs.

Data Structure Documentation

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

#define JO_NULL

NULL implementation.

#define jo_printf (   X,
  Y,
  ... 
)

printf implementation

Parameters
XHorizontal position from top left screen corner
YVertical position from top left screen corner
...Arguments
#define jo_printf_debug (   X,
  Y,
  fmt,
  args... 
)
#define jo_printf_with_color (   X,
  Y,
  COLOR_INDEX,
  ... 
)

printf implementation

Parameters
XHorizontal position from top left screen corner
YVertical position from top left screen corner
COLOR_INDEXColor palette index
...Arguments
#define JO_UNUSED_ARG (   ARG)

Mark function argument as unused.

Enumeration Type Documentation

Horizontal move.

Enumerator
None 
Left 
Right 

Language type.

Enumerator
English 
Deutsch 
French 
Espanol 
Italiano 
Japanese 

Function Documentation

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)
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
void jo_clear_screen ( void  )

Clear screen (usefull for printf)

Warning
Try to not use it by adding some whitespace at the end of jo_printf
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
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_language jo_get_current_language ( void  )

Get Sega saturn current language.

Returns
The language
void jo_getdate ( jo_datetime now)

get current date and time

Parameters
nowresult
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
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
static __jo_force_inline void jo_palette_to_cram ( unsigned short *restrict  data,
unsigned short *restrict  cram_addr,
unsigned int  size 
)
static

Copies the image palette data to CRAM.

Parameters
dataData source
cram_addrColor RAM address
sizeData size
void jo_print ( int  x,
int  y,
char *  str 
)
static __jo_force_inline void jo_set_printf_color_index ( const unsigned char  index)
static

Set printf foreground color index.

Parameters
indexpalette color index
static __jo_force_inline void jo_set_printf_palette_color ( const unsigned char  index,
const unsigned short  color 
)
static

Set foreground palette color for the specific index.

Parameters
indexPalette index (0 and 1 are reserved)
colorColor (Example: JO_COLOR_Red)
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
int jo_strlen ( const char *restrict  str)

strlen implementation

Parameters
strThis is the string
Returns
This function returns the length of str
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
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
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
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
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
static __jo_force_inline void jo_yield ( void  )
static

Little pause possible.

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

unsigned char __jo_printf_current_palette_index
char __jo_sprintf_buf[JO_PRINTF_BUF_SIZE]

Internal sprintf buffer.

Warning
MC Hammer: don't touch this