4#include "models/makoto.hpp"
25std::string gritBaseName(
const char* compiledFileName)
27 std::string name(compiledFileName);
28 static const std::string suffix =
".img.bin";
29 if (name.size() > suffix.size() && name.compare(name.size() - suffix.size(), suffix.size(), suffix) == 0)
31 name.erase(name.size() - suffix.size());
43 return reinterpret_cast<const unsigned int*
>(asset.
tiles);
49 const unsigned int* bitmapsMakoto[MODEL_MAKOTO_TEX_COUNT] = {
nullptr};
51 const std::string basePath =
fatBasePath +
"models/makoto/";
54 bitmapsMakoto[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_0] =
55 loadBitmap(basePath +
"makoto_texture_0", modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_0]);
56 bitmapsMakoto[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_1] =
57 loadBitmap(basePath +
"makoto_texture_1", modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_1]);
58 bitmapsMakoto[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_2] =
59 loadBitmap(basePath +
"makoto_texture_2", modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_2]);
60 bitmapsMakoto[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_3] =
61 loadBitmap(basePath +
"makoto_texture_3", modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_3]);
62 bitmapsMakoto[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_4] =
63 loadBitmap(basePath +
"makoto_texture_4", modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_4]);
65 makoto_loadTextures(*
animationCtrl, (
const unsigned int**)bitmapsMakoto);
68 graphics->unloadGraphic(modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_0]);
69 graphics->unloadGraphic(modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_1]);
70 graphics->unloadGraphic(modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_2]);
71 graphics->unloadGraphic(modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_3]);
72 graphics->unloadGraphic(modelTextures[MODEL_MAKOTO_TEX_MAKOTO_TEXTURE_4]);
81 std::array<const unsigned int*, MAX_ENVIRONMENT_TEXTURES> bitmapsEnv = {
nullptr};
85 for (
int i = 0; i <
dbEntry->textureCount; ++i)
87 bitmapsEnv[i] =
loadBitmap(basePath + gritBaseName(
dbEntry->textures[i].name), envTextures[i]);
97 for (
int i = 0; i <
dbEntry->textureCount; ++i)
99 graphics->unloadGraphic(envTextures[i]);
130 UISystem::getInstance().setSFXComponent(
sfxCmpt);
143 videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE);
144 videoSetModeSub(MODE_3_2D | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE);
147 vramSetBankA(VRAM_A_TEXTURE_SLOT0);
148 vramSetBankB(VRAM_B_TEXTURE_SLOT1);
150 vramSetBankC(VRAM_C_SUB_BG);
151 vramSetBankD(VRAM_D_SUB_SPRITE);
152 vramSetBankE(VRAM_E_MAIN_BG);
153 vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
154 vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);
155 bgExtPaletteEnableSub();
158 settings : GL_ANTIALIAS | GL_TEXTURE_2D | GL_FOG | GL_OUTLINE,
159 polyParams : POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FOG,
160 outlineColor : RGB15(0, 0, 0),
161 fogColor :
RGBA(22, 25, 28, 31),
163 render.initialize3DView(default3DConfig);
179 bgSharedSub1 = bgInitSub(0, BgType_Text4bpp, BgSize_T_256x256, 0, 1);
180 bgSharedSub2 = bgInitSub(2, BgType_Text4bpp, BgSize_T_256x256, 2, 2);
181 bgSharedSub3 = bgInitSub(1, BgType_Text4bpp, BgSize_T_256x256, 4, 3);
202 animationCtrl->loadModel((modelPath +
"makoto/makoto.bin").c_str());
206 int bgText = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
208 bgSetPriority(bgText, 0);
211 int bgTextSub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 4, 0);
213 bgSetPriority(bgTextSub, 0);
228 oamInit(&oamSub, SpriteMapping_1D_128,
true);
256 glMatrixMode(GL_MODELVIEW);
350 bool isActive =
dialogue->isActive();
391 camPos = CameraSystem::getInstance().getCameraPosition();
432 gluLookAtf32(
camPos.eye.x.raw_value(),
435 camPos.target.x.raw_value(),
436 camPos.target.y.raw_value(),
437 camPos.target.z.raw_value(),
444 glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FOG | POLY_ID(0));
452 glTranslatef32(charPos.
x.raw_value(), charPos.
y.raw_value(), charPos.
z.raw_value());
453 glRotateYi(MathManager::getInstance().degreesToCyclicAngle(charPos.
facingAngle));
454 glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FOG | POLY_ID(1));
462 if (
frame % 60 == 30)
464 textSub->clearArea(1, 120, 128, 72);
466 std::string debugText =
"";
467 std::sprintf(buf,
"Touch x = %04X, %04X\n",
touch.rawx,
touch.px);
469 std::sprintf(buf,
"Touch y = %04X, %04X\n",
touch.rawy,
touch.py);
472 "tile(x,z): %d, %d\n",
473 (
int)(MathManager::getInstance().div(charPos.
x +
dbEntry->worldOffsetX,
tileSize)),
474 (
int)(MathManager::getInstance().div(charPos.
z +
dbEntry->worldOffsetZ,
tileSize)));
476 std::sprintf(buf,
"translate(x,z): %d, %d\n", (
int)(charPos.
x * 100), (
int)(charPos.
z * 100));
479 "angle(w,c): %d, %d\n",
480 (
int)(CameraSystem::getInstance().getAngle() * 100),
System for managing battle logic & states.
constexpr int MAX_ENVIRONMENT_TEXTURES
virtual const EnvironmentDbEntry * getEnvironmentDbEntry()=0
virtual ViewState onTileCheck(TileType tile, uint32_t pressed)=0
std::array< int, 2 > bgMain
TextComponent * textSubAlt
TextComponent * textSubOptions
void setupEnvironment()
Loads and uploads a room's environment geometry and textures, driven entirely by dbEntry.
virtual void cleanupHook()
virtual void setupText()=0
MenuHUDScreen * menuHUDScreen
MusicComponent * musicCmpt
const EnvironmentDbEntry * dbEntry
AnimationController * animationCtrl
MovementComponent * movement
Event::CameraPosition camPos
Event::ConfigureCamera camConfig
Dialogue * dialogueFirstLine
uint16_t * textVideoBuffer
std::array< int, 3 > bgSub
virtual void setupMusic()=0
ViewState update() override
Per-frame update for this room's view.
void init() override
One-time setup for a room.
const ae::q20_12_t tileSize
GraphicsComponent * graphics
virtual void setupDialogue()
const unsigned int * loadBitmap(const std::string &path, GraphicAsset &asset)
Loads a single .grit asset and returns its raw tile pointer.
void cleanup() override
Tears down everything a room's view had set up.
void setupPauseMenu()
Sets up the pause menu.
virtual ae::q20_12_t getCameraYOffset() const
uint16_t * textVideoBufferSub
DialogueScreen * dialogueScreen
PauseMenu * pauseMenuCmpt
virtual void setupMovement()=0
bool prevEnvironmentState
virtual void setupCamera()
void setupMenuHUD(const std::string &location)
Sets up the menu HUD.
BattleMenu * battleMenuCmpt
virtual void startBattle()
PauseMenuScreen * pauseMenuScreen
DialogueComponent * dialogue
std::string optionsFontName
static bool enableDebugPrint
static bool enableBillboards
Holds global variables used game-wide.
volatile u32 systemKeysDown
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Util to handle error logging.
Event to trigger hiding all UIScreens.
Event to show specified screen.
Activates the CameraSystem update loop.
Deactivates the CameraSystem update loop.
Holds loaded graphics data.
Data structure to store RGBA values as 8-bit signed integers.
A struct that holds initial config values for the TextComponent.
Data structure to store 3D view configuration parameters.