Document SelStage.cpp a little

This commit is contained in:
Clownacy 2020-09-03 21:52:05 +01:00
parent aa396092b5
commit 9c63e5994b
3 changed files with 15 additions and 10 deletions

View file

@ -4,7 +4,7 @@
// Limits for the amount of weapons and items
#define ARMS_MAX 8
#define ITEM_MAX 0x20
#define ITEM_MAX 32
// "Arms" is a synonym of "weapon" here
// "Code" means "ID" here

View file

@ -12,7 +12,7 @@
#include "Sound.h"
#include "TextScr.h"
PERMIT_STAGE gPermitStage[8];
PERMIT_STAGE gPermitStage[STAGE_MAX];
int gSelectedStage;
int gStageSelectTitleY;
@ -26,7 +26,7 @@ BOOL AddPermitStage(int index, int event)
{
int i = 0;
while (i < 8)
while (i < STAGE_MAX)
{
if (gPermitStage[i].index == index)
break;
@ -37,7 +37,7 @@ BOOL AddPermitStage(int index, int event)
++i;
}
if (i == 8)
if (i == STAGE_MAX)
return FALSE;
gPermitStage[i].index = index;
@ -50,18 +50,18 @@ BOOL SubPermitStage(int index)
{
int i;
for (i = 0; i < 8; ++i)
for (i = 0; i < STAGE_MAX; ++i)
if (gPermitStage[i].index == index)
break;
#ifdef FIX_BUGS
if (i == 8)
if (i == STAGE_MAX)
#else
if (i == 32)
if (i == 32) // Same value as 'ITEM_MAX'
#endif
return FALSE;
for (++i; i < 8; ++i)
for (++i; i < STAGE_MAX; ++i)
gPermitStage[i - 1] = gPermitStage[i];
gPermitStage[i - 1].index = 0;
@ -139,11 +139,14 @@ void PutStageSelectObject(void)
PutBitmap3(&rcView, stage_x + (gSelectedStage * 40), (WINDOW_HEIGHT / 2) - 56, &rcCur[flash / 2 % 2], SURFACE_ID_TEXT_BOX);
for (i = 0; i < 8; ++i)
for (i = 0; i < STAGE_MAX; ++i)
{
if (gPermitStage[i].index == 0)
break;
// Interestingly, there's code for reading multiple rows of icons
// from the 'StageImage.pbm' file when there are more than 8 stages,
// despite only 6 icons ever being used.
rcStage.left = (gPermitStage[i].index % 8) * 32;
rcStage.right = rcStage.left + 32;
rcStage.top = (gPermitStage[i].index / 8) * 16;

View file

@ -2,13 +2,15 @@
#include "WindowsWrapper.h"
#define STAGE_MAX 8 // Note that Cave Story only has 5 stages
typedef struct PERMIT_STAGE
{
int index;
int event;
} PERMIT_STAGE;
extern PERMIT_STAGE gPermitStage[8];
extern PERMIT_STAGE gPermitStage[STAGE_MAX];
extern int gSelectedStage;
extern int gStageSelectTitleY;