-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.cpp
77 lines (57 loc) · 1.62 KB
/
main.cpp
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
#include <libndls.h>
#include <unistd.h>
#include "gl.h"
#include "terrain.h"
#include "worldtask.h"
#include "textures/loading.h"
int main(int argc, char *argv[])
{
#ifdef _TINSPIRE
//Sometimes there's a clock on screen, switch that off
__asm__ volatile("mrs r0, cpsr;"
"orr r0, r0, #0x80;"
"msr cpsr_c, r0;" ::: "r0");
#endif
nglInit();
if(lcd_type() == SCR_320x240_4)
greyscaleTexture(loading);
nglSetBuffer(loading.bitmap);
nglDisplay();
//Early exit #1
//(Task::keyPressed can only be used after initializeGlobals)
if(isKeyPressed(KEY_NSPIRE_ESC))
{
nglUninit();
return 0;
}
terrainInit("/documents/ndless/crafti.ppm.tns");
glBindTexture(terrain_current);
glLoadIdentity();
//Early exit #2
if(isKeyPressed(KEY_NSPIRE_ESC))
{
terrainUninit();
nglUninit();
return 0;
}
//If crafti has been started by the file extension association, use the first argument as savefile path
Task::initializeGlobals(argc > 1 ? argv[1] : "/documents/ndless/crafti.map.tns");
if(Task::load())
world_task.setMessage("World loaded.");
else
world_task.setMessage("World failed to load.");
//Start with WorldTask as current task
world_task.makeCurrent();
while(Task::running)
{
//Reset "loading" message
drawLoadingtext(-1);
Task::current_task->render();
nglDisplay();
Task::current_task->logic();
}
Task::deinitializeGlobals();
nglUninit();
terrainUninit();
return 0;
}