-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstructionState.cpp
162 lines (119 loc) · 4.63 KB
/
InstructionState.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include "InstructionState.h"
InstructionState::InstructionState()
{
glClearColor(1, 1, 1, 1);
textureMan::clearTextures();
modelMan::clearModels();
textureMan::loadTexture("rom:/c_up.sprite");
textureMan::loadTexture("rom:/c_left.sprite");
textureMan::loadTexture("rom:/c_right.sprite");
textureMan::loadTexture("rom:/c_down.sprite");
textureMan::loadTexture("rom:/a.sprite");
textureMan::loadTexture("rom:/b.sprite");
textureMan::loadTexture("rom:/start.sprite");
textureMan::loadTexture("rom:/stick.sprite");
textureMan::loadTexture("rom:/dpad.sprite");
textureMan::loadTexture("rom:/skybox.sprite");
textureMan::loadTexture("rom:/z.sprite");
modelMan::loadModel("rom:/skybox.model64");
skybox.setModel("skybox");
skybox.setTexture("skybox");
skybox.setScale({100.0f, 100.0f, 100.0f});
}
InstructionState::~InstructionState()
{
}
void InstructionState::execute()
{
}
void InstructionState::renderGl()
{
skybox.draw();
}
// DID NOT WRITE THIS CODE had issues with calling it normally
static void sprite_upload_palette(sprite_t *sprite, int palidx)
{
// Check if the sprite has a palette
tex_format_t fmt = sprite_get_format(sprite);
rdpq_tlut_t tlut_mode = rdpq_tlut_from_format(fmt);
// Configure the TLUT render mode
rdpq_mode_tlut(tlut_mode);
if (tlut_mode != TLUT_NONE) {
// Load the palette (if any). We account for sprites being CI4
// but without embedded palette: mksprite doesn't create sprites like
// this today, but it could in the future (eg: sharing a palette across
// multiple sprites).
uint16_t *pal = sprite_get_palette(sprite);
if (pal) rdpq_tex_upload_tlut(pal, palidx*16, fmt == FMT_CI4 ? 16 : 256);
}
}
// DID NOT WRITE THIS CODE had issues with calling it normally
void rdpq_sprite_blit(sprite_t *sprite, float x0, float y0, const rdpq_blitparms_t *parms)
{
// Upload the palette and configure the render mode
sprite_upload_palette(sprite, 0);
// Get the sprite surface
surface_t surf = sprite_get_pixels(sprite);
rdpq_tex_blit(&surf, x0, y0, parms);
}
void InstructionState::renderRdpq()
{
//avert ye eyes mateys
rdpq_set_mode_standard();
rdpq_mode_filter(FILTER_BILINEAR);
rdpq_mode_alphacompare(1);
rdpq_blitparms_t params = {TILE0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
params.cx = 16;
params.cy = 32;
int baseX = 320/10;
int baseY = 240/6 - 7;
int xOffset = 10;
sprite = textureMan::getSprite("c_up");
rdpq_sprite_blit(sprite, baseX, baseY, ¶ms);
sprite = textureMan::getSprite("c_down");
rdpq_sprite_blit(sprite, baseX * 2 + xOffset, baseY, ¶ms);
sprite = textureMan::getSprite("c_left");
rdpq_sprite_blit(sprite, baseX, baseY * 2, ¶ms);
sprite = textureMan::getSprite("c_right");
rdpq_sprite_blit(sprite, baseX * 2 +xOffset, baseY * 2, ¶ms);
sprite = textureMan::getSprite("a");
rdpq_sprite_blit(sprite, baseX + 22, baseY * 3, ¶ms);
sprite = textureMan::getSprite("b");
rdpq_sprite_blit(sprite, baseX + 22, baseY * 4, ¶ms);
sprite = textureMan::getSprite("start");
rdpq_sprite_blit(sprite, baseX + 22, baseY * 5, ¶ms);
sprite = textureMan::getSprite("dpad");
rdpq_sprite_blit(sprite, baseX, baseY * 6, ¶ms);
sprite = textureMan::getSprite("stick");
rdpq_sprite_blit(sprite, baseX * 2 + xOffset, baseY * 6, ¶ms);
sprite = textureMan::getSprite("z");
rdpq_sprite_blit(sprite, baseX + 22, baseY * 7, ¶ms);
sprite = nullptr;
int fontX = 100;
int fontY = 22;
int fontyOffset = 33;
rdpq_font_begin(RGBA16(0, 0, 0, 255));
rdpq_font_scale(0.5f, 0.5f);
rdpq_font_position(fontX, fontY);
rdpq_font_printf(m_font, "Move the Camera up/down");
rdpq_font_position(fontX, fontY + fontyOffset);
rdpq_font_printf(m_font, " Rotate the camera");
rdpq_font_position(fontX, fontY + fontyOffset * 2);
rdpq_font_printf(m_font, " Place a block");
rdpq_font_position(fontX, fontY + fontyOffset * 3);
rdpq_font_printf(m_font, " Delete a block");
rdpq_font_position(fontX, fontY + fontyOffset * 4);
rdpq_font_printf(m_font, " Pause the game");
rdpq_font_position(fontX, fontY + fontyOffset * 5);
rdpq_font_printf(m_font, " Move the cursor");
rdpq_font_position(fontX, fontY + fontyOffset * 6);
rdpq_font_printf(m_font, " Toggle overhead view");
rdpq_font_end();
controller_scan();
struct controller_data down = get_keys_down();
if(down.c[0].B)
{
debugf("\nB pressed\n");
nextState = new MainMenuState();
}
}