SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1
20
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
54typedef int (*vsprintf_t)(char *buf, const char *fmt, va_list args);
56typedef int (*vsnprintf_t)(char *buf, int count, const char *fmt, va_list args);
57
58// *****************************************************************************
59//
60// Macros
61//
62// *****************************************************************************
63
65#define str(s) xstr(s)
67#define xstr(s) #s
68
80
81#if defined(ENABLE_ASSERT_CHECKS) && !defined(NDEBUG)
82#define assert(condition) \
83 if ( !(condition) ) \
84 { \
85 CON_reset(); \
86 CON_systemResetOnNextWrite(); \
87 CON_write(__FILE__":"str(__LINE__)": Assertion \'"str(condition)"\' failed."); \
88 while (TRUE); \
89 }
90#else
91#define assert(condition)
92#endif
93
100
101#define ASSERT(condition) assert(condition)
102
103// *****************************************************************************
104//
105// Function Declarations
106//
107// *****************************************************************************
108
109// -----------------------------------------------------------------------------
110// printf functions
111// -----------------------------------------------------------------------------
112
142
143int CON_sprintf(char* buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
144
178
179int CON_snprintf(char* buf, int count, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
180
197
198void CON_setVsprintf(vsprintf_t vsprintf_func);
199
216
217void CON_setVsnprintf(vsnprintf_t vsnprintf_func);
218
219// -----------------------------------------------------------------------------
220// Console setup
221// -----------------------------------------------------------------------------
222
239
240void CON_setConsoleSize(u16 left, u16 top, u16 width, u16 height);
241
263
264void CON_setLineBufferSize(u16 size);
265
284
285void CON_setTransferMethod(TransferMethod tm);
286
297
298void CON_reset();
299
313
314void CON_systemResetOnNextWrite();
315
316// -----------------------------------------------------------------------------
317// Console write functions
318// -----------------------------------------------------------------------------
319
328
329void CON_clear();
330
344
345void CON_setCursorPosition(u16 x, u16 y);
346
355
356V2u16 CON_getCursorPosition();
357
393
394int CON_write(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
395
396#endif // MODULE_CONSOLE
Basic SGDK library configuration file.
DMA support.
TransferMethod
VRAM transfer method.
Definition dma.h:52
Mathematical methods.
Vect2D_u16 V2u16
alias for Vect2D_u16
Definition maths.h:252
String manipulations.
Types definition.
unsigned short u16
Definition types.h:100