Difference between revisions of "Types"

From MSX Game Library

Line 1: Line 1:
You can use standard C types but MSXgl provide some shortcut that help to write short code and makes data size and sign explicit (which is so important for creating efficient code on a Z80).
+
You can use standard C types to define variables but MSXgl provide some shortcut that help to write short code and makes data size and sign explicit (which is so important for creating efficient code on a Z80).
  
 
MSXgl's types can be found in [https://github.com/aoineko-fr/MSXgl/blob/main/engine/src/core.h core.h].
 
MSXgl's types can be found in [https://github.com/aoineko-fr/MSXgl/blob/main/engine/src/core.h core.h].
Line 5: Line 5:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Type !! Desc. !! SDCC equivalent
+
! Type !! Desc. !! [[SDCC]] equivalent
 
|-
 
|-
 
| '''<tt>bool</tt>''' || Boolean (8 bits) || <tt>unsigned char</tt>
 
| '''<tt>bool</tt>''' || Boolean (8 bits) || <tt>unsigned char</tt>
Line 36: Line 36:
 
|}
 
|}
  
Related consant:
+
Related constants:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
#define NULL 0 // Pointer "NULL" value
 
#define NULL 0 // Pointer "NULL" value

Revision as of 09:03, 22 January 2024

You can use standard C types to define variables but MSXgl provide some shortcut that help to write short code and makes data size and sign explicit (which is so important for creating efficient code on a Z80).

MSXgl's types can be found in core.h.

Type Desc. SDCC equivalent
bool Boolean (8 bits) unsigned char
i8 8 bits signed integer signed char
u8 8 bits unsigned integer unsigned char
i16 16 bits signed integer signed short
u16 16 bits unsigned integer unsigned short
i32 32 bits signed integer signed long
u32 32 bits unsigned integer unsigned long
i64 64 bits signed integer signed long long
u64 64 bits unsigned integer unsigned long long
f32 32 bits float (IEEE 754) float
c8 8 bits character (ASCII, UTF-8) unsigned char
c16 16 bits character (UTF-16, JIS, etc.) unsigned short
ptr Pointer void*
callback Callback default signature void (*)(void)

Related constants:

#define NULL	0	// Pointer "NULL" value
#define TRUE	1	// Value for "TRUE" boolean
#define FALSE	0	// Value for "FALSE" boolean

See also: