Skip to content

Commit

Permalink
Add some useful increment and decrement macros
Browse files Browse the repository at this point in the history
Which we'd really like to have for the highscore entering screen.
  • Loading branch information
nmlgc committed Mar 1, 2015
1 parent d058666 commit 37fc899
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
35 changes: 31 additions & 4 deletions pc98.h → ReC98.h
@@ -1,10 +1,37 @@
/* ReC98
* -----
* Some useful PC-98 hardware constants
* Some useful random constants and macros
*/

// VRAM planes
// -----------
// Macros
// ------
#define CLAMP_INC(val, max) \
(val)++; \
if((val) > (max)) { \
(val) = (max); \
}

#define CLAMP_DEC(val, min) \
(val)--; \
if((val) < (min)) { \
(val) = (min); \
}

#define RING_INC(val, ring_end) \
(val)++; \
if((val) > (ring_end)) { \
(val) = 0; \
}

#define RING_DEC(val, ring_end) \
(val)--; \
if((val) < 0) { \
(val) = ring_end; \
}
// ------

// PC-98 VRAM planes
// -----------------
typedef enum {
PL_B, PL_R, PL_G, PL_E, PL_COUNT
} vram_plane_t;
Expand All @@ -26,4 +53,4 @@ extern char *VRAM_PLANE_E;
}

#define VRAM_OFFSET(x, y) ((x) >> 3) + (y << 6) + (y << 4)
// -----------
// -----------------
2 changes: 1 addition & 1 deletion th01/th01.h
Expand Up @@ -3,7 +3,7 @@
* Include file for TH01
*/

#include "pc98.h"
#include "ReC98.h"

// Hardware
void graph_accesspage_func(int page);
26 changes: 10 additions & 16 deletions th02/op_05.c
Expand Up @@ -39,22 +39,22 @@ void copy_pic_back(int sel, int highlight)
int x, y;
if(!highlight) {
switch(sel) {
case 0: x = 16; y = 128; break;
case 1: x = 224; y = 224; break;
case 0: x = 16; y = 128; break;
case 1: x = 224; y = 224; break;
case 2: x = 432; y = 128; break;
}
graph_copy_region_from_1_to_0(x, y, 16, 144);
graph_copy_region_from_1_to_0(x, y, 192, 10);
} else {
switch(sel) {
case 0: x = 208; y = 136; break;
case 1: x = 416; y = 232; break;
case 0: x = 208; y = 136; break;
case 1: x = 416; y = 232; break;
case 2: x = 624; y = 136; break;
}
graph_copy_region_from_1_to_0(x, y, 16, 144);
switch(sel) {
case 0: x = 24; y = 272; break;
case 1: x = 232; y = 368; break;
case 0: x = 24; y = 272; break;
case 1: x = 232; y = 368; break;
case 2: x = 440; y = 272; break;
}
graph_copy_region_from_1_to_0(x, y, 192, 8);
Expand All @@ -81,8 +81,8 @@ void draw_shottype_desc(int sel, int color)
{
int x, y;
switch(sel) {
case 0: x = 16; y = 296; break;
case 1: x = 224; y = 136; break;
case 0: x = 16; y = 296; break;
case 1: x = 224; y = 136; break;
case 2: x = 432; y = 296; break;
}
grcg_setcolor(GC_RMW, color);
Expand Down Expand Up @@ -176,10 +176,7 @@ void pascal shottype_menu(void)
frame_delay(1);
darken_pic_at(pic_x[sel] + 8, pic_y[sel] + 8);

sel--;
if(sel < 0) {
sel = SHOTTYPE_COUNT - 1;
}
RING_DEC(sel, SHOTTYPE_COUNT - 1);
DRAW_NEW_SEL();
}
if(input & INPUT_RIGHT) {
Expand All @@ -191,10 +188,7 @@ void pascal shottype_menu(void)
frame_delay(1);
darken_pic_at(pic_x[sel] + 8, pic_y[sel] + 8);

sel++;
if(sel > SHOTTYPE_COUNT - 1) {
sel = 0;
}
RING_INC(sel, SHOTTYPE_COUNT - 1);
DRAW_NEW_SEL();
}
if(input & INPUT_SHOT || input & INPUT_OK) {
Expand Down
2 changes: 1 addition & 1 deletion th02/th02.h
Expand Up @@ -3,7 +3,7 @@
* Include file for TH02
*/

#include "pc98.h"
#include "ReC98.h"

// Formats
#define PI_SLOTS 6
Expand Down

0 comments on commit 37fc899

Please sign in to comment.