2020-10-03 17:22:44 +02:00
|
|
|
#include "global.h"
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2022-06-23 14:34:26 -07:00
|
|
|
void Sample_HandleStateChange(SampleState* this) {
|
2020-10-03 17:22:44 +02:00
|
|
|
if (CHECK_BTN_ALL(this->state.input[0].press.button, BTN_START)) {
|
2022-05-21 14:23:43 -04:00
|
|
|
SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState);
|
2020-03-22 17:37:38 +01:00
|
|
|
this->state.running = false;
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2022-06-23 14:34:26 -07:00
|
|
|
void Sample_Draw(SampleState* this) {
|
2020-03-22 17:37:38 +01:00
|
|
|
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
|
|
|
View* view = &this->view;
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-08-30 01:00:17 +02:00
|
|
|
OPEN_DISPS(gfxCtx, "../z_sample.c", 62);
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-10-29 17:31:09 -04:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x00, NULL);
|
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment);
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2022-08-15 09:39:06 -04:00
|
|
|
Gfx_SetupFrame(gfxCtx, 0, 0, 0);
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2022-04-08 23:50:28 +01:00
|
|
|
view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE;
|
|
|
|
View_Apply(view, VIEW_ALL);
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2020-08-30 01:00:17 +02:00
|
|
|
{
|
2024-01-09 04:59:03 -08:00
|
|
|
Mtx* mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx));
|
2021-12-01 00:40:42 +01:00
|
|
|
|
2020-04-22 10:20:49 -07:00
|
|
|
guPosition(mtx, SREG(37), SREG(38), SREG(39), 1.0f, SREG(40), SREG(41), SREG(42));
|
2020-10-29 17:31:09 -04:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD);
|
2020-04-16 23:36:12 +02:00
|
|
|
}
|
2020-03-17 00:31:30 -04:00
|
|
|
|
2021-05-03 01:15:16 +02:00
|
|
|
POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, 255, 255, 255, 0, 0, 0);
|
2022-06-03 15:25:48 -07:00
|
|
|
Gfx_SetupDL_25Opa(gfxCtx);
|
2020-03-24 19:52:07 -04:00
|
|
|
|
2020-10-29 17:31:09 -04:00
|
|
|
gDPSetCycleType(POLY_OPA_DISP++, G_CYC_1CYCLE);
|
|
|
|
gDPSetRenderMode(POLY_OPA_DISP++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
|
|
|
|
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
|
|
|
|
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 0);
|
2020-03-22 17:37:38 +01:00
|
|
|
|
2020-08-30 01:00:17 +02:00
|
|
|
CLOSE_DISPS(gfxCtx, "../z_sample.c", 111);
|
2020-03-22 17:37:38 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 21:52:50 -04:00
|
|
|
void Sample_Main(GameState* thisx) {
|
2022-06-23 14:34:26 -07:00
|
|
|
SampleState* this = (SampleState*)thisx;
|
2020-10-11 21:52:50 -04:00
|
|
|
|
2020-03-22 17:37:38 +01:00
|
|
|
Sample_Draw(this);
|
2020-04-16 23:36:12 +02:00
|
|
|
Sample_HandleStateChange(this);
|
2020-03-22 17:37:38 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 21:52:50 -04:00
|
|
|
void Sample_Destroy(GameState* thisx) {
|
2020-03-22 17:37:38 +01:00
|
|
|
}
|
|
|
|
|
2022-06-23 14:34:26 -07:00
|
|
|
void Sample_SetupView(SampleState* this) {
|
2021-02-14 00:49:40 +00:00
|
|
|
View* view = &this->view;
|
|
|
|
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
2020-06-17 15:44:22 -04:00
|
|
|
|
2020-04-16 23:36:12 +02:00
|
|
|
View_Init(view, gfxCtx);
|
2020-06-13 22:59:58 -04:00
|
|
|
SET_FULLSCREEN_VIEWPORT(view);
|
2022-04-08 23:50:28 +01:00
|
|
|
View_SetPerspective(view, 60.0f, 10.0f, 12800.0f);
|
2020-03-22 17:37:38 +01:00
|
|
|
|
2020-06-13 22:59:58 -04:00
|
|
|
{
|
2021-05-03 01:15:16 +02:00
|
|
|
Vec3f eye;
|
|
|
|
Vec3f lookAt;
|
|
|
|
Vec3f up;
|
|
|
|
|
|
|
|
eye.x = 0.0f;
|
|
|
|
eye.y = 0.0f;
|
|
|
|
eye.z = 3000.0f;
|
|
|
|
lookAt.x = 0.0f;
|
|
|
|
lookAt.y = 0.0f;
|
|
|
|
lookAt.z = 0.0f;
|
|
|
|
up.x = 0.0f;
|
|
|
|
up.z = 0.0f;
|
|
|
|
up.y = 1.0f;
|
|
|
|
|
2022-04-08 23:50:28 +01:00
|
|
|
View_LookAt(view, &eye, &lookAt, &up);
|
2020-06-13 22:59:58 -04:00
|
|
|
}
|
2020-03-22 17:37:38 +01:00
|
|
|
}
|
|
|
|
|
2022-06-23 14:34:26 -07:00
|
|
|
void Sample_LoadTitleStatic(SampleState* this) {
|
2020-03-22 19:32:44 +01:00
|
|
|
u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart;
|
2020-03-22 22:19:43 +01:00
|
|
|
|
2024-01-09 04:59:03 -08:00
|
|
|
this->staticSegment = GAME_STATE_ALLOC(&this->state, size, "../z_sample.c", 163);
|
|
|
|
DMA_REQUEST_SYNC(this->staticSegment, (uintptr_t)_title_staticSegmentRomStart, size, "../z_sample.c", 164);
|
2020-03-22 17:37:38 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 21:52:50 -04:00
|
|
|
void Sample_Init(GameState* thisx) {
|
2022-06-23 14:34:26 -07:00
|
|
|
SampleState* this = (SampleState*)thisx;
|
2020-10-12 20:44:22 -04:00
|
|
|
|
2020-04-16 23:36:12 +02:00
|
|
|
this->state.main = Sample_Main;
|
2020-03-22 17:37:38 +01:00
|
|
|
this->state.destroy = Sample_Destroy;
|
|
|
|
R_UPDATE_RATE = 1;
|
|
|
|
Sample_SetupView(this);
|
|
|
|
Sample_LoadTitleStatic(this);
|
|
|
|
SREG(37) = 0;
|
|
|
|
SREG(38) = 0;
|
|
|
|
SREG(39) = 0;
|
|
|
|
SREG(40) = 0;
|
|
|
|
SREG(41) = 0;
|
|
|
|
SREG(42) = 0;
|
|
|
|
}
|