sgdk
console.h
Go to the documentation of this file.
00001 
00021 // *****************************************************************************
00022 //
00023 //  Includes
00024 //
00025 // *****************************************************************************
00026 
00027 #include "config.h"
00028 
00029 #if (MODULE_CONSOLE != 0)
00030 
00031 #include "types.h"
00032 #include "string.h"
00033 #include "maths.h"
00034 #include "dma.h"
00035 
00036 #pragma once
00037 
00038 // *****************************************************************************
00039 //
00040 //  Defines
00041 //
00042 // *****************************************************************************
00043 
00045 #define ENABLE_ASSERT_CHECKS
00046 
00047 // *****************************************************************************
00048 //
00049 //  Types
00050 //
00051 // *****************************************************************************
00052 
00054 typedef int (*vsprintf_t)(char *buf, const char *fmt, va_list args);
00056 typedef int (*vsnprintf_t)(char *buf, int count, const char *fmt, va_list args);
00057 
00058 // *****************************************************************************
00059 //
00060 //  Macros
00061 //
00062 // *****************************************************************************
00063 
00065 #define str(s) xstr(s)
00066 
00067 #define xstr(s) #s
00068 
00081 #if defined(ENABLE_ASSERT_CHECKS) && !defined(NDEBUG)
00082 #define assert(condition)                                                              \
00083     if ( !(condition) )                                                                \
00084     {                                                                                  \
00085         CON_reset();                                                                   \
00086         CON_systemResetOnNextWrite();                                                  \
00087         CON_write(__FILE__":"str(__LINE__)": Assertion \'"str(condition)"\' failed."); \
00088         while (TRUE);                                                                  \
00089     }
00090 #else
00091 #define assert(condition)
00092 #endif
00093 
00101 #define ASSERT(condition) assert(condition)
00102 
00103 // *****************************************************************************
00104 //
00105 //  Function Declarations
00106 //
00107 // *****************************************************************************
00108 
00109 // -----------------------------------------------------------------------------
00110 // printf functions
00111 // -----------------------------------------------------------------------------
00112 
00143 int CON_sprintf(char* buf, const char *fmt, ...)  __attribute__ ((format (printf, 2, 3)));
00144 
00179 int CON_snprintf(char* buf, int count, const char *fmt, ...)  __attribute__ ((format (printf, 3, 4)));
00180 
00198 void CON_setVsprintf(vsprintf_t vsprintf_func);
00199 
00217 void CON_setVsnprintf(vsnprintf_t vsnprintf_func);
00218 
00219 // -----------------------------------------------------------------------------
00220 // Console setup
00221 // -----------------------------------------------------------------------------
00222 
00240 void CON_setConsoleSize(u16 left, u16 top, u16 width, u16 height);
00241 
00264 void CON_setLineBufferSize(u16 size);
00265 
00285 void CON_setTransferMethod(TransferMethod tm);
00286 
00298 void CON_reset();
00299 
00314 void CON_systemResetOnNextWrite();
00315 
00316 // -----------------------------------------------------------------------------
00317 // Console write functions
00318 // -----------------------------------------------------------------------------
00319 
00329 void CON_clear();
00330 
00345 void CON_setCursorPosition(u16 x, u16 y);
00346 
00356 V2u16 CON_getCursorPosition();
00357 
00394 int CON_write(const char *fmt, ...)  __attribute__ ((format (printf, 1, 2)));
00395 
00396 #endif // MODULE_CONSOLE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines