📄 util.h
字号:
#ifndef __UTIL_H
#define __UTIL_H
#include "types.h"
#include "regmap.h"
#ifndef __GNUC__
#define __attribute__(x) /**/
#endif
#define MSF(mm,ss,ff) (((UINT32)(mm) << 16) | ((UINT32)(ss) << 8) | (BYTE)(ff))
#define MSF2l(mm,ss,ff) (((mm) * 60 + (ss)) * 75 + (ff) - 150)
#define MSFC(cna,mm,ss,ff) (((UINT32)(cna) << 24) | \
((UINT32)(mm) << 16) | \
((UINT32)(ss) << 8) | \
(BYTE)(ff))
#define msf_mm(msf) (((msf) >> 16) & 0xff)
#define msf_ss(msf) (((msf) >> 8) & 0xff)
#define msf_ff(msf) (((msf) >> 0) & 0xff)
#define M2I(msf) (msf_mm(msf) * 60 + msf_ss(msf))
extern int bin2bcd(BYTE x) __attribute__ ((const));
extern int bcd2bin(BYTE x) __attribute__ ((const));
extern UINT32 l2msf(UINT32);
extern UINT32 msf2l(UINT32);
extern UINT32 addmsf(UINT32, int) __attribute__ ((const));
extern UINT32 addmsf_ss(UINT32, int) __attribute__ ((const));
extern UINT32 endian_swap_32(UINT32);
extern UINT16 endian_swap_16(UINT16);
extern BYTE *strcpylen(BYTE *, const BYTE *, UINT16);
extern BYTE *strcpychn(BYTE *, const BYTE *, UINT16);
extern BYTE *strncat(BYTE *, const BYTE *);
extern BYTE *strchr(BYTE *, BYTE);
extern BYTE *strstr(BYTE *, BYTE *);
extern void memcopy(BYTE *, const BYTE *, UINT16);
extern void memload(BYTE *, UINT32, UINT16);
extern UINT32 DecStrToHex(BYTE *, BYTE);
extern void HexToDecStr(UINT32, BYTE *, BYTE);
extern UINT32 DiffrentTwoVar(UINT32, UINT32);
extern const BYTE Hex2Asc[];
extern void Hex2Str(BYTE *, BYTE);
extern void Dec2Str(BYTE *, BYTE);
extern UINT32 Str2Hex(BYTE *);
extern UINT32 Str2Dec(BYTE *);
extern void Str2Unc(BYTE *, BYTE *);
extern BYTE Str4Dig(BYTE *, BYTE);
extern void Txt2Pdu(BYTE *, BYTE *);
extern void Pdu2Txt(BYTE *, BYTE *);
extern BYTE Pdu2Asc(BYTE *, BYTE *);
extern BYTE IsAlpha(BYTE);
extern BYTE IsDigit(BYTE);
extern BYTE IsPrint(BYTE);
extern UINT16 GBKToUnicode(UINT16);
extern UINT16 UnicodeToGBK(UINT16);
extern void StrToPDUPhone(BYTE *, BYTE *);
extern void StrToPDUText(BYTE *, BYTE *);
extern void PDUTextToStr(BYTE *, BYTE *);
#if !defined(SUPPORT_SDRAM_FONT) || (ROM_SIZE == 40)
extern const UINT16 UnicodeTable[][2];
#endif
#define SwapTwoVar(a, b) {SwapVar = a; a = b; b = SwapVar;}
#ifdef gcc
static inline int min(int x, int y)
{
return (x) > (y) ? (y) : (x);
}
static inline int max(int x, int y)
{
return (x) > (y) ? (x) : (y);
}
#else
#define min(x, y) ((x) > (y) ? (y) : (x))
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
/*
* Multiplication
* 1.15 * 1.15 => 2.30
*/
static __inline int mul16(int x, int y)
{
int product;
asm("mult %0, %1, %2": "=r"(product):"r"(x), "r"(y));
return product;
}
static __inline unsigned int mul_u16(unsigned int x, unsigned int y)
{
unsigned int product;
asm("multu %0, %1, %2": "=r"(product):"r"(x), "r"(y));
return product;
}
#endif __UTIL_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -