-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZGBMain.c
39 lines (31 loc) · 806 Bytes
/
ZGBMain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "ZGBMain.h"
#include "Math.h"
const UINT8 EMPTY_HEART_TILE = 12;
const UINT8 HEART_TILE_HALF = 13;
const UINT8 HEART_TILE_FULL = 14;
UINT8 next_state = StateTitle;
void SetHealth(UINT8 curr, UINT8 max);
UINT8 GetTileReplacement(UINT8* tile_ptr, UINT8* tile) {
if(current_state == StateGame) {
if(U_LESS_THAN(255 - (UINT16)*tile_ptr, N_SPRITE_TYPES)) {
*tile = 0;
return 255 - (UINT16)*tile_ptr;
}
*tile = *tile_ptr;
}
return 255u;
}
void SetHealth(UINT8 curr, UINT8 max)
{
UINT8 i;
for(i = 0; i < curr/2; ++i) {
set_win_tiles(6 + i, 0, 1, 1, &HEART_TILE_FULL);
}
for(i = (curr+1)/2; i != max/2; ++i) {
set_win_tiles(6 + i, 0, 1, 1, &EMPTY_HEART_TILE);
}
if (curr % 2 == 1)
{
set_win_tiles(6 + (curr-1)/2, 0, 1, 1, &HEART_TILE_HALF);
}
}