/*************************************************************************** * Copyright (c) 2003-2006, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #ifndef BAPP_UTIL_H__ #define BAPP_UTIL_H__ #ifdef LINUX #include "bgfx_types.h" #include "bsettop_types.h" #else #include "bsettop_gfx.h" #include "bdispatch.h" #endif #include "fstore.h" #ifdef BCM_DEBUG #define BAPP_ASSERT(expr) { \ if (!expr) \ printf("%s failed at %s:%d\n",#expr, __FILE__, __LINE__); \ } #else #define BAPP_ASSERT(expr) if (!(expr)) ; #endif /* * Utility data structure to use for pseudo IO */ typedef struct bin_read_t { unsigned char *data; unsigned int size; unsigned int cnt; }bin_read_t; #define RAND_MAX 1000 #define RAND_INT(x) (((x) * rand())/RAND_MAX) unsigned int rand(void); /* Summary: Sleep for the specified number of milliseconds. */ void bapp_sleep(unsigned int ms); /* Summary: Construct a UNI string in the buffer provided from the cstring. */ unsigned int c_to_uni_str( unsigned char *str_p, /* Null terminated c-string */ unsigned int *p_uni_str, /* buffer to use for contructing UNI string */ unsigned int max_size /* maximum buffer size in words */ ); /* Summary: Construct a UNI string in the buffer provided from the null terminated UTF-16 string. */ unsigned int utf16_to_uni_str( unsigned short *str_p, /* NULL terminated (0x0000) UTF - 16 string */ unsigned int *p_uni_str, /* buffer to use for contructing UNI string */ unsigned int max_size /* maximum buffer size in words */ ); /* Summary: Utility IO function. Description: Utility IO function to be used for pseudo IO. */ int bin_read( void *buffer, int size, int count, void *fp ); int bin_set(void *fp, int offset, int whence ); unsigned int bin_tell(void *fp ); /* Summary: finds a break in the string (space). Description: finds a break in the string (space). */ unsigned int find_break_uni( unsigned int* str, /* UNI string */ unsigned int max /* Number of characters in UNI string */ ); #ifdef OLD_TEXTBOX /* Summary: Draw text at x,y and within the specified w,h. Description: Draw text at x,y and within the specified w,h. */ int text_box(bgfx_surf_t *p_surf, /* bgfx surface */ bgfx_font_t *font, /* bgfx font */ uint16_t x, /* x location in pixels */ uint16_t y, /* y location in pixels */ uint16_t width, /* width in pixels */ uint16_t height, /* height in pixels */ unsigned int *msg, /* UNI string */ unsigned int msg_len, /* Number of characters in the msg */ bgfx_pixel c, /* palette index */ int line_spacing /* number of vertical pixels between lines */ ); #else #define text_box(surf,font,x,y,w,h,msg,len,c,lspace) \ bgfx_draw_text_box(surf,x,y,w,h,(const unsigned long*)msg,len,font,c,lspace) #endif /* Summary: Same as text box but with shadow. Description: Same as text box but with shadow. */ int text_box_shadow(bgfx_surf_t *p_surf, /* bgfx surface */ bgfx_font_t *font, /* bgfx font */ uint16_t x, /* x location in pixels */ uint16_t y, /* y location in pixels */ uint16_t width, /* width in pixels */ uint16_t height, /* height in pixels */ unsigned int *msg, /* UNI string */ unsigned int msg_len, /* Number of characters in the msg */ bgfx_pixel c_f, /* palette index for forground text*/ bgfx_pixel c_b, /* palette index for background text */ int shadow_offset, /* offset from xy to place shaddow (can be negative) */ int line_spacing /* number of vertical pixels between lines */ ); /* Summary: Draw a button. Description: Draw a button. */ void draw_button(bgfx_surf_t *p_surf, /* bgfx surface */ bgfx_font_t *font, /* bgfx font */ uint16_t x, /* x location in pixels */ uint16_t y, /* y location in pixels */ uint16_t width, /* width in pixels */ uint16_t height, /* height in pixels */ unsigned int *msg, /* UNI string */ unsigned int msg_len, /* Number of characters in the msg */ int state, /* button state, 1 - on, 0 - off */ int type /* button type, 1 - check box, 0 - menu */ ); int tsid_to_utc_offset(unsigned short tsid, int *p_offset, char *p_dst); int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y); #endif /* BAPP_UTIL_H__ */