summaryrefslogtreecommitdiff
path: root/include/assert.h
blob: 5a134d7c9156c525b4a344963d4f0e98a44f0930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef GUARD_GBASDKASSERT_H
#define GUARD_GBASDKASSERT_H

// this header is based on the
// GBA SDK IsAgbAssert.h.

#ifdef NOAGBPRN
    #define AGBPrintInit()
    #define AGBPutc(pBuf)
    #define AGBPrint(pBuf)
    #define AGBPrintf(...)
    #define AGBPrintFlush1Block()
    #define AGBPrintFlush()
    #define AGBAssert(pFile, nLine, pExpression, nStopProgram)
#else
    // without NOAGBPRN defined, this enables asserts for usage
    // on a standard GBA debugger unit or in emulators that
    // support it.

// no$gba support, due to the different method no$gba uses to print debug strings.
// currently cannot use IsNoGba due to no$gba doing a gloriously fuck up of a job and
// breaking the version identifier.
#define AGBPrint(pBuf) \
{ \
    NOGBAPrint(pBuf); \
    AGBPrint(pBuf); \
}

    void AGBPrintInit(void);
    void AGBPutc(const char pBuf);
    void AGBPrint(const char *pBuf);
    void AGBPrintf(const char *pBuf, ...);
    void AGBPrintFlush1Block(void);
    void AGBPrintFlush(void);
    void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram);
    // NOGBA PROTOTYPE FOR LIBISAGBPRN.C
    void NOGBAPrint(const char *pBuf);
#endif

// when using AGB_WARNING, be sure to flush after as AGBAssert does not flush the string to console
// immediately after usage.
#ifdef NOAGBPRN
    #define AGB_ASSERT(expression)
#else
    #define AGB_ASSERT(expression)  (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 1);
#endif

#ifdef NOAGBPRN
    #define AGB_WARNING(expression)
#else
    #define AGB_WARNING(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 0);
#endif

#endif