summaryrefslogtreecommitdiff
path: root/src/newer.cpp
blob: 0b53fa6bb16dafb30e0b8e7f0b3b62f3605c2ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <newer.h>
#include <game.h>


int getStarCoinCount() {
	SaveBlock *save = GetSaveFile()->GetBlock(-1);
	int coinsSpent = save->credits_hiscore;
	int coinsEarned = 0;

	for (int w = 0; w < 10; w++) {
		for (int l = 0; l < 10; l++) {
			u32 conds = save->GetLevelCondition(w, l);

			if (conds & COND_COIN1) { coinsEarned++; }
			if (conds & COND_COIN2) { coinsEarned++; }
			if (conds & COND_COIN3) { coinsEarned++; }
		}
	}

	int coinsLeft = coinsEarned - coinsSpent;
	return coinsLeft;
}