diff --git a/pc98.h b/ReC98.h similarity index 52% rename from pc98.h rename to ReC98.h index 125dd9fe..f3eec688 100644 --- a/pc98.h +++ b/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; @@ -26,4 +53,4 @@ extern char *VRAM_PLANE_E; } #define VRAM_OFFSET(x, y) ((x) >> 3) + (y << 6) + (y << 4) -// ----------- +// ----------------- diff --git a/th01/th01.h b/th01/th01.h index f45183df..fe401866 100644 --- a/th01/th01.h +++ b/th01/th01.h @@ -3,7 +3,7 @@ * Include file for TH01 */ -#include "pc98.h" +#include "ReC98.h" // Hardware void graph_accesspage_func(int page); diff --git a/th02/op_05.c b/th02/op_05.c index c26807e0..d8d21769 100644 --- a/th02/op_05.c +++ b/th02/op_05.c @@ -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); @@ -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); @@ -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) { @@ -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) { diff --git a/th02/th02.h b/th02/th02.h index 5fb0d116..6f45707f 100644 --- a/th02/th02.h +++ b/th02/th02.h @@ -3,7 +3,7 @@ * Include file for TH02 */ -#include "pc98.h" +#include "ReC98.h" // Formats #define PI_SLOTS 6