aboutsummaryrefslogtreecommitdiff
path: root/src/PHL.c
blob: 8db7e326c0f376cfdf1766ea9fc6a852318663ee (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "PHL.h"
#include <stdio.h>
#include <string.h>
#include "qda.h"
#include "game.h"

void PHL_Init()
{	
	PHL_GraphicsInit();
	PHL_AudioInit();

	#ifdef _3DS
		Result rc = romfsInit();
		/*if (rc) {
			printf("romfsInit: %08lX\n", rc);
			//while(1){}
		}
		else
		{
			printf("\nromfs Init Successful!\n");
		}*/
	#endif

	WHITE = 0;
	RED = 1;
	YELLOW = 2;
}

void PHL_Deinit()
{
	PHL_AudioClose();
	PHL_GraphicsExit();
	
	#ifdef _3DS
		romfsExit();
	#endif
}

//Extracts bmps from the bmp.qda archive file
PHL_Surface PHL_LoadQDA(char* fname)
{	
	PHL_Surface surf;
	
	int numofsheets = 29;
	
	for (int i = 0; i < numofsheets; i++)
	{
		if (strcmp(fname, (char*)headers[i].fileName) == 0) { //Match found
			//printf("\nMatch Found: %s", fname);
			surf = PHL_LoadBMP(i);
			i = numofsheets; //End search
		}
	}
	
	return surf;
}

void PHL_DrawTextBold(char* txt, int dx, int dy, int col)
{
	int i, cx, cy;
	
	for (i = 0; i < strlen(txt); i++)
	{
		cx = (txt[i] - 32) * 16;
		cy = 32 * col;
		
		while (cx >= 512) {
			cx -= 512;
			cy += 16;
		}
		
		PHL_DrawSurfacePart(dx + (16 * i), dy, cx, cy, 16, 16, images[imgBoldFont]);
	}
}

void PHL_DrawTextBoldCentered(char* txt, int dx, int dy, int col)
{
	if (dy < 640 && dy > -16) {
		int stringW = strlen(txt) * 16;
		
		PHL_DrawTextBold(txt, dx - (stringW / 2), dy, col);
	}
}