2015-02-24 15:17:50 +00:00
|
|
|
/* ReC98
|
|
|
|
* -----
|
2015-03-03 05:47:23 +00:00
|
|
|
* Main include file
|
2015-02-24 15:17:50 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-13 00:42:40 +00:00
|
|
|
#ifndef REC98_H
|
|
|
|
#define REC98_H
|
|
|
|
|
2015-03-16 21:35:52 +00:00
|
|
|
#include <stddef.h>
|
2019-12-11 20:42:27 +00:00
|
|
|
#include "platform.h"
|
2019-11-08 20:03:03 +00:00
|
|
|
#include "pc98.h"
|
2020-06-10 20:54:22 +00:00
|
|
|
#include "planar.h"
|
2015-03-16 21:35:52 +00:00
|
|
|
|
2015-03-01 21:52:25 +00:00
|
|
|
// Macros
|
|
|
|
// ------
|
|
|
|
#define CLAMP_INC(val, max) \
|
|
|
|
(val)++; \
|
|
|
|
if((val) > (max)) { \
|
|
|
|
(val) = (max); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CLAMP_DEC(val, min) \
|
|
|
|
(val)--; \
|
|
|
|
if((val) < (min)) { \
|
|
|
|
(val) = (min); \
|
|
|
|
}
|
|
|
|
|
2020-08-05 17:14:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
// This is, in fact, the only way to circumvent 16-bit promotion inside
|
|
|
|
// comparisons between two 8-bit values in C++. I kid you not.
|
|
|
|
static inline char ring_min() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ring_min() 0
|
|
|
|
#endif
|
|
|
|
|
2015-03-01 21:52:25 +00:00
|
|
|
#define RING_INC(val, ring_end) \
|
|
|
|
(val)++; \
|
|
|
|
if((val) > (ring_end)) { \
|
|
|
|
(val) = 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RING_DEC(val, ring_end) \
|
|
|
|
(val)--; \
|
2020-08-05 17:14:38 +00:00
|
|
|
if(val < ring_min()) { \
|
2015-03-01 21:52:25 +00:00
|
|
|
(val) = ring_end; \
|
|
|
|
}
|
|
|
|
// ------
|
|
|
|
|
2020-03-13 00:42:40 +00:00
|
|
|
#endif /* REC98_H */
|