Files

471 lines
8.3 KiB
C
Raw Permalink Normal View History

2026-04-17 18:22:45 +08:00
#ifndef BASETYPES_H_INCLUDED
#define BASETYPES_H_INCLUDED
typedef unsigned char UInt08;
typedef unsigned char U08;
typedef signed char Int08;
typedef unsigned short UInt16;
typedef unsigned short U16;
typedef signed short Int16;
typedef unsigned int UInt32;
typedef unsigned int U32;
typedef int Int32;
typedef float Flt32;
/* 8λ<38><CEBB>ͬ<EFBFBD><CDAC> */
typedef union
{
U08 value;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ (single) */
struct
{
U08 b0 :1;
U08 b1 :1;
U08 b2 :1;
U08 b3 :1;
U08 b4 :1;
U08 b5 :1;
U08 b6 :1;
U08 b7 :1;
}sbit;
/* ˫λ<CBAB><CEBB><EFBFBD>ʽṹ1 (double) */
struct
{
U08 b01 :2;
U08 b23 :2;
U08 b45 :2;
U08 b67 :2;
}sbit02;
/* ˫λ<CBAB><CEBB><EFBFBD>ʽṹ2 (double) */
struct
{
U08 b0 :1;
U08 b12 :2;
U08 b34 :2;
U08 b56 :2;
U08 b7 :1;
}sbit12;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ1 (ternate) */
struct
{
U08 b02 :3;
U08 b35 :3;
U08 b67 :2;
}sbit03;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ2 (ternate) */
struct
{
U08 b0 :1;
U08 b13 :3;
U08 b46 :3;
U08 b7 :1;
}sbit13;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ3 (ternate) */
struct
{
U08 b01 :2;
U08 b24 :3;
U08 b57 :3;
}sbit23;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ1 (hex) */
struct
{
U08 b03 :4;
U08 b47 :4;
}sbit04;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ2 (hex) */
struct
{
U08 b0 :1;
U08 b14 :4;
U08 b57 :3;
}sbit14;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ3 (hex) */
struct
{
U08 b01 :2;
U08 b25 :4;
U08 b67 :2;
}sbit24;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ4 (hex) */
struct
{
U08 b02 :3;
U08 b36 :4;
U08 b7 :1;
}sbit34;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ1 (quinary) */
struct
{
U08 b04 :5;
U08 b57 :3;
}sbit05;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ2 (quinary) */
struct
{
U08 b0 :1;
U08 b15 :5;
U08 b67 :2;
}sbit15;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ3 (quinary) */
struct
{
U08 b01 :2;
U08 b26 :5;
U08 b7 :1;
}sbit25;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ4 (quinary) */
struct
{
U08 b02 :3;
U08 b37 :5;
}sbit35;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ1 (sextuplet) */
struct
{
U08 b05 :6;
U08 b67 :2;
}sbit06;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ2 (sextuplet) */
struct
{
U08 b0 :1;
U08 b16 :6;
U08 b7 :1;
}sbit16;
/* <20><>λ<EFBFBD><CEBB><EFBFBD>ʽṹ3 (sextuplet) */
struct
{
U08 b01 :2;
U08 b27 :6;
}sbit26;
/* <20><><EFBFBD>Ƿ<EFBFBD><C7B7>ʽṹ1 (heptad) */
struct
{
U08 b06 :7;
U08 b7 :1;
}sbit07;
/* <20><><EFBFBD>Ƿ<EFBFBD><C7B7>ʽṹ2 (heptad) */
struct
{
U08 b0 :1;
U08 b17 :7;
}sbit17;
}Un08;
/* 16λ<36><CEBB>ͬ<EFBFBD><CDAC> */
typedef union
{
U16 value;
/* <20><><EFBFBD>ֽڷ<D6BD><DAB7>ʽṹ */
struct
{
U08 bh;
U08 bl;
}sbyte;
/* λ<><CEBB><EFBFBD>ʽṹ */
struct
{
Un08 bh;
Un08 bl;
}sbit;
} Un16;
/* 32λ<32><CEBB>ͬ<EFBFBD><CDAC> */
typedef union
{
U32 value;
/* <20><><EFBFBD>ֽڷ<D6BD><DAB7>ʽṹ */
struct
{
U08 bhh;
U08 bhl;
U08 blh;
U08 bll;
}sbyte;
/* λ<><CEBB><EFBFBD>ʽṹ */
struct
{
Un08 bhh;
Un08 bhl;
Un08 blh;
Un08 bll;
}sbit;
}Un32;
typedef struct
{
Flt32 x, y, z, w;
} Vec4f;
typedef struct
{
Int32 x, y, z, w;
} Vec4i;
typedef struct
{
Flt32 x, y, z;
} Vec3f;
typedef struct
{
Int32 x, y, z;
} Vec3i;
typedef struct
{
Flt32 x, y;
} Vec2f;
typedef struct
{
Int32 x, y;
} Vec2i;
typedef struct
{
Int32 x;
Int32 y;
Int32 w;
Int32 h;
} Recti;
#define SetVec4(vec4, xx, yy, zz, ww) do{ \
(vec4).x = (xx); \
(vec4).y = (yy); \
(vec4).z = (zz); \
(vec4).w = (ww);}while(0)
#define SetVec4f(vec4f, xx, yy, zz, ww) SetVec4(vec4f, xx, yy, zz, ww)
#define SetVec4i(vec4i, xx, yy, zz, ww) SetVec4(vec4i, xx, yy, zz, ww)
#define SetVec3(vec3, xx, yy, zz) do{ \
(vec3).x = (xx); \
(vec3).y = (yy); \
(vec3).z = (zz);}while(0)
#define SetVec3f(vec3f, xx, yy, zz) SetVec3(vec3f, xx, yy, zz)
#define SetVec3i(vec3i, xx, yy, zz) SetVec3(vec3i, xx, yy, zz)
#define SetVec2(vec2, xx, yy) do{ \
(vec2).x = (xx); \
(vec2).y = (yy);}while(0)
#define SetVec2f(vec2f, xx, yy) SetVec2(vec2f, xx, yy)
#define SetVec2i(vec2i, xx, yy) SetVec2(vec2i, xx, yy)
#define SetRecti(recti, xx, yy, ww, hh) do{ \
(recti).x = (xx); \
(recti).y = (yy); \
(recti).w = (ww); \
(recti).h = (hh);}while(0)
#define MAX_MATRIX_STACK_DEPTH 10
//typedef struct
//{
// UInt08 idx;
// Flt32 mat4x4[MAX_MATRIX_STACK_DEPTH][4*4];
//} Mat4x4Stack;
typedef void* (*CommonFun) (void* argv);
#ifndef Bool
#define Bool Int08
#endif
#define INS_FALSE 0x0
#define INS_TRUE 0x1
#define WITHOUT_NORMALS_AND_TEXTCOORDS 0x0
#define WITH_NORMALS 0x1
#define WITH_TEXTCOORDS 0x2
enum
{
FILE_READ_ERR = 0x10,
FILE_WRITE_ERR,
FILE_UNKNOW_FORMAT,
SYSTEM_ERROR
};
#define INS_INVALID_RES_ID 0xffFFffFF
typedef struct
{
Int32 ltx;
Int32 lty;
Int32 w;
Int32 h;
UInt08 *dat;
UInt32 tex;
Int32 fmt;
} Image;
#define GetImageRect(rect, image) do{\
(rect).x = (image).ltx;\
(rect).y = (image).lty;\
(rect).w = (image).w;\
(rect).h = (image).h;\
}while(0)
typedef struct
{
UInt08 hdr;
UInt32 face_num;
Flt32 *vtxs;
Flt32 *txcs;
Flt32 *nors;
} Model3DVao, *HModel3DVao;
typedef struct
{
UInt08 hdr;
UInt08 idx_type;
UInt32 idx_num;
UInt32 face_num;
UInt32 buf[4];
Flt32 x_min, x_max;
Flt32 y_min, y_max;
Flt32 z_min, z_max;
Flt32 *vtxs;
Flt32 *txcs;
Flt32 *nors;
void *idx;
} Model3DVbo, *HModel3DVbo;
enum
{
FRM_COMPRESS_NONE = 0,
FRM_COMPRESS_1 = 1,
FRM_ENCRYPT_NONE = 0,
FRM_ENCRYPT_1 = 1,
FRM_TYPE_CTRL = 0,
FRM_TYPE_SINGLE = 1,
FRM_TYPE_FIRST = 2,
FRM_TYPE_NEXT = 3,
FRM_INF_HEART_BEAT = 0,
FRM_INF_HEART_BEAT_ACK = 1,
FRM_INF_START = 2,
FRM_INF_START_ACK = 3,
FRM_INF_START_NACK = 4,
FRM_INF_END = 5,
FRM_INF_END_ACK = 6,
FRM_INF_END_NACK = 7,
FRM_INF_DATA = 8,
FRM_INF_DATA_ACK = 9,
FRM_SRV_ICM_BLUETOOTH = 0x00,
FRM_SRV_ICM_ACCOUNT = 0x01,
FRM_SRV_ICM_CTRL = 0x02,
FRM_SRV_CDU_NAVIGATION = 0x40,
FRM_SRV_CDU_MUSIC = 0x41,
FRM_SRV_CDU_RADIO = 0x42,
FRM_SRV_CDU_BLUETOOTH = 0x43,
FRM_SRV_CDU_WEATHER = 0x44,
FRM_SRV_CDU_ACCOUNT = 0x45,
FRM_SRV_CDU_AID = 0x46,
FRM_SRV_CDU_NOTIFICATION = 0x47,
FRM_SRV_CDU_NETRADIO = 0x48,
FRM_SRV_CDU_UPGRADE = 0xF0,
RPC_TYPE_REQ = 0,
RPC_TYPE_RSP = 1,
RPC_TYPE_NTF = 2,
RPC_CDU_NAVIGATION = 0x00000001,
RPC_CDU_MUSIC = 0x00000002,
RPC_CDU_RADIO = 0x00000003,
RPC_CDU_BLUETOOTH = 0x00000004,
RPC_CDU_WEATHER = 0x00000005,
RPC_CDU_ACCOUNT = 0x00000006,
RPC_CDU_UPGRADE = 0x00000007,
RPC_CDU_NOTIFICATION = 0x00000008,
RPC_CDU_NETRADIO = 0x00000009,
RPC_CDU_SERVICE = 0xff000001,
RPC_CDU_HEART_BEAT = 0xff000002,
RPC_ICM_BLUETOOTH = 0x0000f001,
RPC_ICM_ACCOUNT = 0x0000f002,
RPC_ICM_CTRL = 0x0000f003,
FRM_SEQ_END = 0,
FRM_SEQ_SINGLE = 1,
FRM_SEQ_CTRL = 1,
};
typedef struct
{
UInt08 version; /*Э<><D0AD><EFBFBD>汾*/
UInt08 compress:4; /*ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
UInt08 encrypt:4; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
UInt08 frm_type; /*֡<><D6A1><EFBFBD><EFBFBD>*/
UInt08 srv_type; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
UInt08 frm_info; /*֡<><D6A1>Ϣ*/
UInt08 session_id; /*<2A>ỰID*/
UInt08 frm_id; /*֡<><D6A1>*/
UInt08 reserve8; /*Ԥ<><D4A4>*/
UInt32 data_size; /*<2A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>*/
UInt08 reserve13; /*Ԥ<><D4A4>*/
UInt08 reserve14; /*Ԥ<><D4A4>*/
UInt08 reserve15; /*Ԥ<><D4A4>*/
UInt08 reserve16; /*Ԥ<><D4A4>*/
} FrameHeader;
typedef union
{
Int08 buff[16];
Un08 unbuf[16];
FrameHeader header;
} UnFrameHeader;
typedef struct
{
UInt08 rpc_type; /*RPC<50><43><EFBFBD><EFBFBD>*/
UInt08 reserve1; /*Ԥ<><D4A4>*/
UInt08 reserve2; /*Ԥ<><D4A4>*/
UInt08 reserve3; /*Ԥ<><D4A4>*/
UInt32 rpc_name; /*RPC<50><43>*/
UInt32 rpc_msg_no; /*RPC<50><43>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>*/
UInt32 json_size; /*json<6F><6E><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>*/
} BpBinHeader;
typedef union
{
Int08 buff[16];
Un08 unbuf[16];
BpBinHeader header;
} UnBpBinHeader;
#endif // BASETYPES_H_INCLUDED