mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Move the ring increment/decrement macros to clamp.hpp
That means we can finally… Part of P0186, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
parent
1c468eef21
commit
f4a73bba3f
25
ReC98.h
25
ReC98.h
|
@ -11,29 +11,4 @@
|
|||
#include "pc98.h"
|
||||
#include "planar.h"
|
||||
|
||||
// Macros
|
||||
// ------
|
||||
#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
|
||||
|
||||
#define RING_INC(val, ring_end) \
|
||||
(val)++; \
|
||||
if((val) > (ring_end)) { \
|
||||
(val) = 0; \
|
||||
}
|
||||
|
||||
#define RING_DEC(val, ring_end) \
|
||||
(val)--; \
|
||||
if(val < ring_min()) { \
|
||||
(val) = ring_end; \
|
||||
}
|
||||
// ------
|
||||
|
||||
#endif /* REC98_H */
|
||||
|
|
|
@ -18,3 +18,25 @@
|
|||
if((v) < (min)) { \
|
||||
(v) = (min); \
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
#define ring_inc(val, ring_end) \
|
||||
(val)++; \
|
||||
if((val) > (ring_end)) { \
|
||||
(val) = 0; \
|
||||
}
|
||||
|
||||
#define ring_dec(val, ring_end) \
|
||||
(val)--; \
|
||||
if(val < ring_min()) { \
|
||||
(val) = ring_end; \
|
||||
}
|
||||
|
|
|
@ -193,16 +193,16 @@ void pascal score_enter(void)
|
|||
input_sense();
|
||||
if(!input_locked) {
|
||||
if(key_det & INPUT_UP) {
|
||||
alphabet_cursor_move(row, ALPHABET_ROWS, RING_DEC, col, row);
|
||||
alphabet_cursor_move(row, ALPHABET_ROWS, ring_dec, col, row);
|
||||
}
|
||||
if(key_det & INPUT_DOWN) {
|
||||
alphabet_cursor_move(row, ALPHABET_ROWS, RING_INC, col, row);
|
||||
alphabet_cursor_move(row, ALPHABET_ROWS, ring_inc, col, row);
|
||||
}
|
||||
if(key_det & INPUT_LEFT) {
|
||||
alphabet_cursor_move(col, ALPHABET_COLS, RING_DEC, col, row);
|
||||
alphabet_cursor_move(col, ALPHABET_COLS, ring_dec, col, row);
|
||||
}
|
||||
if(key_det & INPUT_RIGHT) {
|
||||
alphabet_cursor_move(col, ALPHABET_COLS, RING_INC, col, row);
|
||||
alphabet_cursor_move(col, ALPHABET_COLS, ring_inc, col, row);
|
||||
}
|
||||
if(key_det & INPUT_SHOT || key_det & INPUT_OK) {
|
||||
/* Yeah, it sucks that ZUN checks against the indices into the
|
||||
|
|
|
@ -10,6 +10,7 @@ extern "C" {
|
|||
#include "th02/resident.hpp"
|
||||
#include "master.hpp"
|
||||
#include "libs/kaja/kaja.h"
|
||||
#include "th01/math/clamp.hpp"
|
||||
#include "th02/hardware/frmdelay.h"
|
||||
#include "th02/hardware/grp_rect.h"
|
||||
#include "th02/hardware/input.hpp"
|
||||
|
@ -585,10 +586,10 @@ void option_update_and_render(void)
|
|||
menu_sel_move(6, 1);
|
||||
}
|
||||
if(key_det & INPUT_RIGHT) {
|
||||
option_change(RING_INC);
|
||||
option_change(ring_inc);
|
||||
}
|
||||
if(key_det & INPUT_LEFT) {
|
||||
option_change(RING_DEC);
|
||||
option_change(ring_dec);
|
||||
}
|
||||
if(key_det & INPUT_SHOT || key_det & INPUT_OK) {
|
||||
switch(menu_sel) {
|
||||
|
|
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
#include "th02/th02.h"
|
||||
#include "x86real.h"
|
||||
#include "master.hpp"
|
||||
#include "th01/math/clamp.hpp"
|
||||
#include "th02/resident.hpp"
|
||||
#include "th02/hardware/frmdelay.h"
|
||||
#include "th02/hardware/grp_rect.h"
|
||||
|
@ -188,7 +189,7 @@ void pascal shottype_menu(void)
|
|||
frame_delay(1);
|
||||
darken_pic_at(pic_x[sel] + 8, pic_y[sel] + 8);
|
||||
|
||||
RING_DEC(sel, sel_ring_end());
|
||||
ring_dec(sel, sel_ring_end());
|
||||
draw_new_sel(pic_x, pic_y);
|
||||
}
|
||||
if(key_det & INPUT_RIGHT) {
|
||||
|
@ -200,7 +201,7 @@ void pascal shottype_menu(void)
|
|||
frame_delay(1);
|
||||
darken_pic_at(pic_x[sel] + 8, pic_y[sel] + 8);
|
||||
|
||||
RING_INC(sel, sel_ring_end());
|
||||
ring_inc(sel, sel_ring_end());
|
||||
draw_new_sel(pic_x, pic_y);
|
||||
}
|
||||
if(key_det & INPUT_SHOT || key_det & INPUT_OK) {
|
||||
|
|
Loading…
Reference in New Issue