This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63605a4
commit d7585c3
Showing
9 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
void vblank_callback(u16 irqs) | ||
{ | ||
(void)irqs; | ||
|
||
BG_PALETTE[0] += 1; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef _LIBSEVEN_UTIL_ASSERT_H | ||
#define _LIBSEVEN_UTIL_ASSERT_H | ||
|
||
#include <seven/base.h> | ||
|
||
_LIBSEVEN_EXTERN_C | ||
|
||
#ifdef NDEBUG | ||
|
||
#define assertCheck(condition) ((void)0) | ||
#define assertCheckWithFilename(condition, filename) ((void)0) | ||
#define assertCheckWithLocation(condition, function, filename, line) ((void)0) | ||
|
||
#else | ||
|
||
#ifndef _LIBSEVEN_ASSERT_FUNC | ||
#ifdef __GNUC__ | ||
#define _LIBSEVEN_ASSERT_FUNC __PRETTY_FUNCTION__ | ||
#elif __STDC_VERSION >= 199901L | ||
#define _LIBSEVEN_ASSERT_FUNC __func__ | ||
#elif __GNUC__ >= 2 | ||
#define _LIBSEVEN_ASSERT_FUNC __FUNCTION__ | ||
#else | ||
#define _LIBSEVEN_ASSERT_FUNC ((char*)0) | ||
#endif | ||
#endif | ||
|
||
#ifndef _LIBSEVEN_ASSERT_FILE | ||
#ifdef __FILE_NAME__ | ||
#define _LIBSEVEN_ASSERT_FILE __FILE_NAME__ | ||
#else | ||
#define _LIBSEVEN_ASSERT_FILE __FILE__ | ||
#endif | ||
#endif | ||
|
||
#define assertCheck(condition) \ | ||
assertCheckWithFilename(condition, _LIBSEVEN_ASSERT_FILE) | ||
|
||
#define assertCheckWithFilename(condition, filename) \ | ||
assertCheckWithLocation(condition, _LIBSEVEN_ASSERT_FUNC, filename, __LINE__) | ||
|
||
#define assertCheckWithLocation(condition, function, filename, line) \ | ||
do { \ | ||
if (!(condition)) { \ | ||
assertRaise(#condition, function, filename, line); \ | ||
} \ | ||
} while(0) | ||
|
||
#endif /* !NDEBUG */ | ||
|
||
typedef void AssertHandlerFn(const char*, const char*, const char*, u32); | ||
|
||
extern AssertHandlerFn* assertSetHandler(AssertHandlerFn *handler); | ||
|
||
extern AssertHandlerFn* assertGetHandler(void); | ||
|
||
extern void NORETURN assertRaise( | ||
const char *message, | ||
const char *function, | ||
const char *file, | ||
u32 line); | ||
|
||
_LIBSEVEN_EXTERN_C_END | ||
|
||
#endif /* !_LIBSEVEN_UTIL_ASSERT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <stdlib.h> | ||
|
||
#include <seven/hw/irq.h> | ||
#include <seven/util/assert.h> | ||
|
||
static struct { | ||
AssertHandlerFn *handler; | ||
u32 panic; | ||
} ASSERT; | ||
|
||
extern AssertHandlerFn* assertSetHandler(AssertHandlerFn *handler) | ||
{ | ||
AssertHandlerFn *previous = ASSERT.handler; | ||
ASSERT.handler = handler; | ||
return previous; | ||
} | ||
|
||
extern AssertHandlerFn* assertGetHandler(void) | ||
{ | ||
return ASSERT.handler; | ||
} | ||
|
||
extern void NORETURN assertRaise( | ||
const char *message, | ||
const char *function, | ||
const char *file, | ||
u32 line) | ||
{ | ||
REG_IME = 0; | ||
|
||
AssertHandlerFn *h = ASSERT.handler; | ||
|
||
// Prevent a nested assert | ||
if (h && !ASSERT.panic) | ||
{ | ||
ASSERT.panic = 1; | ||
h(message, function, file, line); | ||
} | ||
|
||
_Exit(EXIT_FAILURE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters