sgdk
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1
21// *****************************************************************************
22//
23// Includes
24//
25// *****************************************************************************
26
27#include "config.h"
28
29#if (MODULE_CONSOLE != 0)
30
31#include "types.h"
32#include "string.h"
33#include "maths.h"
34#include "dma.h"
35
36#pragma once
37
38// *****************************************************************************
39//
40// Defines
41//
42// *****************************************************************************
43
45#define ENABLE_ASSERT_CHECKS
46
47// *****************************************************************************
48//
49// Types
50//
51// *****************************************************************************
52
53typedef u32 size_t;
54typedef u32 ptrdiff_t;
55
57typedef int (*vsprintf_t)(char *buf, const char *fmt, va_list args);
59typedef int (*vsnprintf_t)(char *buf, int count, const char *fmt, va_list args);
60
61// *****************************************************************************
62//
63// Macros
64//
65// *****************************************************************************
66
68#define str(s) xstr(s)
70#define xstr(s) #s
71
84#if defined(ENABLE_ASSERT_CHECKS) && !defined(NDEBUG)
85#define assert(condition) \
86 if ( !(condition) ) \
87 { \
88 CON_reset(); \
89 CON_systemResetOnNextWrite(); \
90 CON_write(__FILE__":"str(__LINE__)": Assertion \'"str(condition)"\' failed."); \
91 while (TRUE); \
92 }
93#else
94#define assert(condition)
95#endif
96
104#define ASSERT(condition) assert(condition)
105
106// *****************************************************************************
107//
108// Function Declarations
109//
110// *****************************************************************************
111
112// -----------------------------------------------------------------------------
113// printf functions
114// -----------------------------------------------------------------------------
115
146int CON_sprintf(char* buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
147
182int CON_snprintf(char* buf, int count, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
183
201void CON_setVsprintf(vsprintf_t vsprintf_func);
202
220void CON_setVsnprintf(vsnprintf_t vsnprintf_func);
221
222// -----------------------------------------------------------------------------
223// Console setup
224// -----------------------------------------------------------------------------
225
243void CON_setConsoleSize(u16 left, u16 top, u16 width, u16 height);
244
267void CON_setLineBufferSize(u16 size);
268
288void CON_setTransferMethod(TransferMethod tm);
289
301void CON_reset();
302
317void CON_systemResetOnNextWrite();
318
319// -----------------------------------------------------------------------------
320// Console write functions
321// -----------------------------------------------------------------------------
322
332void CON_clear();
333
348void CON_setCursorPosition(u16 x, u16 y);
349
359V2u16 CON_getCursorPosition();
360
397int CON_write(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
398
399#endif // MODULE_CONSOLE
Basic SGDK library configuration file.
DMA support.
TransferMethod
VRAM transfer method.
Definition dma.h:52
Mathematical methods.
String manipulations.
2D Vector structure - u16 type.
Definition maths.h:130
Types definition.
unsigned long u32
Definition types.h:105
unsigned short u16
Definition types.h:100