Made a lot of progress on new game menu

This commit is contained in:
James Lambert 2023-04-22 17:32:28 -06:00
parent 0c8bc76732
commit 8621a04d3c
23 changed files with 631 additions and 19 deletions

View file

@ -144,6 +144,10 @@ build/assets/materials/ui.h build/assets/materials/ui_mat.c: assets/materials/ui
@mkdir -p $(@D)
$(SKELATOOL64) --name ui --default-material default_ui -m $< --material-output -o build/assets/materials/ui.h
build/assets/materials/images.h build/assets/materials/images_mat.c: assets/materials/images.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
@mkdir -p $(@D)
$(SKELATOOL64) --name images --default-material default_ui -m $< --material-output -o build/assets/materials/images.h
build/assets/materials/hud.h build/assets/materials/hud_mat.c: assets/materials/hud.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
@mkdir -p $(@D)
$(SKELATOOL64) --name hud -m $< --material-output -o build/assets/materials/hud.h
@ -237,7 +241,7 @@ build/src/scene/ball_catcher.o: build/assets/models/props/combine_ball_catcher.h
build/src/scene/door.o: build/assets/models/props/door_01.h build/assets/models/props/door_02.h
build/src/menu/main_menu.o: build/assets/materials/ui.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h
build/src/menu/main_menu.o: build/assets/materials/ui.h build/assets/materials/images.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h
build/assets/models/player/chell.h: assets/materials/chell.skm.yaml
@ -365,6 +369,8 @@ CODEOBJECTS = $(patsubst %.c, build/%.o, $(CODEFILES)) $(MODEL_OBJECTS) build/as
CODEOBJECTS_NO_DEBUG = $(CODEOBJECTS)
DATA_OBJECTS = build/assets/materials/images_mat.o
ifeq ($(PORTAL64_WITH_DEBUGGER),1)
CODEOBJECTS_NO_DEBUG += build/debugger/debugger_stub.o build/debugger/serial.o
endif
@ -376,7 +382,7 @@ $(CODESEGMENT)_no_debug.o: $(CODEOBJECTS_NO_DEBUG)
$(CP_LD_SCRIPT)_no_debug.ld: $(LD_SCRIPT) build/levels.ld build/anims.ld
cpp -P -Wno-trigraphs $(LCDEFS) -DCODE_SEGMENT=$(CODESEGMENT)_no_debug.o -o $@ $<
$(BASE_TARGET_NAME).z64: $(CODESEGMENT)_no_debug.o $(OBJECTS) $(CP_LD_SCRIPT)_no_debug.ld
$(BASE_TARGET_NAME).z64: $(CODESEGMENT)_no_debug.o $(OBJECTS) $(DATA_OBJECTS) $(CP_LD_SCRIPT)_no_debug.ld
$(LD) -L. -T $(CP_LD_SCRIPT)_no_debug.ld -Map $(BASE_TARGET_NAME)_no_debug.map -o $(BASE_TARGET_NAME).elf
$(OBJCOPY) --pad-to=0x100000 --gap-fill=0xFF $(BASE_TARGET_NAME).elf $(BASE_TARGET_NAME).z64 -O binary
makemask $(BASE_TARGET_NAME).z64
@ -394,7 +400,7 @@ $(CODESEGMENT)_debug.o: $(CODEOBJECTS_DEBUG)
$(CP_LD_SCRIPT)_debug.ld: $(LD_SCRIPT) build/levels.ld build/anims.ld
cpp -P -Wno-trigraphs $(LCDEFS) -DCODE_SEGMENT=$(CODESEGMENT)_debug.o -o $@ $<
$(BASE_TARGET_NAME)_debug.z64: $(CODESEGMENT)_debug.o $(OBJECTS) $(CP_LD_SCRIPT)_debug.ld
$(BASE_TARGET_NAME)_debug.z64: $(CODESEGMENT)_debug.o $(OBJECTS) $(DATA_OBJECTS) $(CP_LD_SCRIPT)_debug.ld
$(LD) -L. -T $(CP_LD_SCRIPT)_debug.ld -Map $(BASE_TARGET_NAME)_debug.map -o $(BASE_TARGET_NAME)_debug.elf
$(OBJCOPY) --pad-to=0x100000 --gap-fill=0xFF $(BASE_TARGET_NAME)_debug.elf $(BASE_TARGET_NAME)_debug.z64 -O binary
makemask $(BASE_TARGET_NAME)_debug.z64

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

View file

@ -0,0 +1 @@
-alpha extract -resize 128x47!

View file

@ -0,0 +1,35 @@
materials:
chapter1:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter1.png"
chapter2:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter2.png"
chapter3:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter3.png"
chapter4:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter4.png"
chapter5:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter5.png"
chapter6:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter6.png"
chapter7:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter7.png"
chapter8:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter8.png"
chapter9:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter9.png"
chapter10:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter10.png"
chapter11:
gDPSetTile:
filename: "../../portal_pak_modified/materials/vgui/chapters/chapter11.png"

View file

@ -22,4 +22,57 @@ materials:
r: 255
g: 255
b: 255
a: 255
a: 255
portal_logo:
gDPSetTile:
filename: "../../portal_pak_modified/materials/gamepadui/portal_logo.png"
siz: G_IM_SIZ_4b
fmt: G_IM_FMT_I
gDPSetCombineMode:
color: ["0", "0", "0", ENVIRONMENT]
alpha: [TEXEL0, "0", ENVIRONMENT, "0"]
gDPSetRenderMode: G_RM_XLU_SURF
gDPSetEnvColor:
r: 255
g: 255
b: 255
a: 255
rounded_corners:
gDPSetTile:
filename: "../../assets/images/rounded_corners.png"
siz: G_IM_SIZ_8b
fmt: G_IM_FMT_I
gDPSetCombineMode:
color: ["0", "0", "0", ENVIRONMENT]
alpha: [TEXEL0, "0", ENVIRONMENT, "0"]
gDPSetRenderMode: G_RM_XLU_SURF
gDPSetEnvColor:
r: 164
g: 164
b: 164
a: 128
solid_env:
gDPSetCombineMode:
color: ["0", "0", "0", ENVIRONMENT]
alpha: ["0", "0", "0", ENVIRONMENT]
gDPSetRenderMode: G_RM_OPA_SURF
gDPSetEnvColor:
r: 0
g: 0
b: 0
a: 255
solid_transparent_overlay:
gDPSetCombineMode:
color: ["0", "0", "0", ENVIRONMENT]
alpha: ["0", "0", "0", ENVIRONMENT]
gDPSetRenderMode: G_RM_XLU_SURF
gDPSetEnvColor:
r: 0
g: 0
b: 0
a: 85

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -0,0 +1 @@
-crop 152x86+0+0 -resize 84x48

View file

@ -70,6 +70,13 @@ SECTIONS
}
END_SEG(sound_data)
BEGIN_SEG(images, __romPos)
{
build/assets/materials/images_mat.o(.data);
build/assets/materials/images_mat.o(.bss);
}
END_SEG(images)
#include "build/levels.ld"
#include "build/anims.ld"

96
src/graphics/image.c Normal file
View file

@ -0,0 +1,96 @@
#include "image.h"
#include "graphics.h"
#define MAX_TILE_X 64
#define MAX_TILE_Y 32
void graphicsCopyImage(struct RenderState* state, void* source, int iw, int ih, int sx, int sy, int dx, int dy, int width, int height, struct Coloru8 color) {
gDPPipeSync(state->dl++);
gDPSetCycleType(state->dl++, G_CYC_1CYCLE);
gDPSetRenderMode(state->dl++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
gDPSetCombineLERP(state->dl++, TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0);
gDPSetTextureLUT(state->dl++, G_TT_NONE);
gDPSetTexturePersp(state->dl++, G_TP_NONE);
gDPSetEnvColor(state->dl++, color.r, color.g, color.b, color.a);
if (dy < 0) {
height += dy;
sy -= dy;
dy = 0;
}
if (height <= 0) {
return;
}
int tileXCount = (width + MAX_TILE_X-1) / MAX_TILE_X;
int tileYCount = (height + MAX_TILE_Y-1) / MAX_TILE_Y;
int tileX, tileY;
for (tileX = 0; tileX < tileXCount; ++tileX) {
int currX = tileX * MAX_TILE_X;
int tileWidth = width - currX;
if (tileWidth > MAX_TILE_X) {
tileWidth = MAX_TILE_X;
}
int currDx = dx + currX;
if (currDx >= SCREEN_WD) {
break;
}
if (currDx + tileWidth < 0) {
continue;
}
if (currDx < 0) {
tileWidth += currDx;
currDx = 0;
}
if (currDx + tileWidth >= SCREEN_WD) {
tileWidth = SCREEN_WD - currDx;
}
int scaledY = 0;
for (tileY = 0; tileY < tileYCount; ++tileY) {
int currY = tileY * MAX_TILE_Y;
int tileHeight = height - currY;
if (tileHeight > MAX_TILE_Y) {
tileHeight = MAX_TILE_Y;
}
int scaledTileHeight = tileHeight;//SCALE_FOR_PAL(tileHeight);
gDPLoadTextureTile(
state->dl++,
K0_TO_PHYS((char*)source + ((sx + currX) + (sy + currY) * iw) * 2),
G_IM_FMT_RGBA, G_IM_SIZ_16b,
iw, ih,
0, 0,
tileWidth-1, tileHeight-1,
0,
G_TX_CLAMP, G_TX_CLAMP,
G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD
);
gSPTextureRectangle(
state->dl++,
(currDx) << 2, (dy+scaledY) << 2,
(currDx+tileWidth) << 2, (dy+scaledY+scaledTileHeight) << 2,
G_TX_RENDERTILE,
0, 0, 1 << 10, (tileHeight << 10) / scaledTileHeight
);
scaledY += scaledTileHeight;
}
}
gDPPipeSync(state->dl++);
}

9
src/graphics/image.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef _GRAPHICS_IMAGE_H
#define _GRAPHICS_IMAGE_H
#include "renderstate.h"
#include "../graphics/color.h"
void graphicsCopyImage(struct RenderState* state, void* source, int iw, int ih, int sx, int sy, int dx, int dy, int width, int height, struct Coloru8 color);
#endif

View file

@ -2,23 +2,226 @@
#include "../font/font.h"
#include "../font/dejavusans.h"
#include "../graphics/image.h"
#include "../util/memory.h"
#include "../util/rom.h"
#include "menu.h"
#include <string.h>
#include "../build/assets/materials/ui.h"
#include "../build/assets/materials/images.h"
#include "../scene/render_plan.h"
#include "../levels/levels.h"
#include "../build/assets/test_chambers/test_chamber_00/test_chamber_00.h"
Gfx* menuBuildText(struct Font* font, char* message, int x, int y) {
Gfx* result = malloc(sizeof(Gfx) * (fontCountGfx(font, message) + 1));
Gfx* dl = result;
#define PORTAL_LOGO_X 30
#define PORTAL_LOGO_Y 74
dl = fontRender(font, message, x, y, dl);
#define PORTAL_LOGO_WIDTH 128
#define PORTAL_LOGO_P_WIDTH 15
#define PORTAL_LOGO_O_WIDTH 30
#define PORTAL_LOGO_HEIGHT 47
struct Chapter gChapters[] = {
{"CHAPTER 1", "Testchamber 00", images_chapter1_rgba_16b},
{"CHAPTER 2", "Testchamber 04", images_chapter2_rgba_16b},
{"CHAPTER 3", "Testchamber 08", images_chapter3_rgba_16b},
{"CHAPTER 4", "Testchamber 10", images_chapter4_rgba_16b},
{"CHAPTER 5", "Testchamber 13", images_chapter5_rgba_16b},
{"CHAPTER 6", "Testchamber 14", images_chapter6_rgba_16b},
{"CHAPTER 7", "Testchamber 15", images_chapter7_rgba_16b},
{"CHAPTER 8", "Testchamber 16", images_chapter8_rgba_16b},
{"CHAPTER 9", "Testchamber 17", images_chapter9_rgba_16b},
{"CHAPTER 10", "Testchamber 18", images_chapter10_rgba_16b},
{"CHAPTER 11", "Testchamber 19", images_chapter11_rgba_16b},
};
Gfx portal_logo_gfx[] = {
gsSPTextureRectangle(
PORTAL_LOGO_X << 2,
PORTAL_LOGO_Y << 2,
(PORTAL_LOGO_X + PORTAL_LOGO_P_WIDTH) << 2,
(PORTAL_LOGO_Y + PORTAL_LOGO_HEIGHT) << 2,
G_TX_RENDERTILE,
0, 0,
0x400, 0x400
),
gsDPPipeSync(),
gsDPSetEnvColor(60, 189, 236, 255),
gsSPTextureRectangle(
(PORTAL_LOGO_X + PORTAL_LOGO_P_WIDTH) << 2,
PORTAL_LOGO_Y << 2,
(PORTAL_LOGO_X + PORTAL_LOGO_P_WIDTH + PORTAL_LOGO_O_WIDTH) << 2,
(PORTAL_LOGO_Y + PORTAL_LOGO_HEIGHT) << 2,
G_TX_RENDERTILE,
PORTAL_LOGO_P_WIDTH << 5, 0,
0x400, 0x400
),
gsDPPipeSync(),
gsDPSetEnvColor(255, 255, 255, 255),
gsSPTextureRectangle(
(PORTAL_LOGO_X + PORTAL_LOGO_P_WIDTH + PORTAL_LOGO_O_WIDTH) << 2,
PORTAL_LOGO_Y << 2,
(PORTAL_LOGO_X + PORTAL_LOGO_WIDTH) << 2,
(PORTAL_LOGO_Y + PORTAL_LOGO_HEIGHT) << 2,
G_TX_RENDERTILE,
(PORTAL_LOGO_P_WIDTH + PORTAL_LOGO_O_WIDTH) << 5, 0,
0x400, 0x400
),
gsSPEndDisplayList(),
};
void landingMenuInit(struct LandingMenu* landingMenu) {
landingMenu->newGameText = menuBuildText(&gDejaVuSansFont, "NEW GAME", 30, 132);
landingMenu->loadGameText = menuBuildText(&gDejaVuSansFont, "LOAD GAME", 30, 148);
landingMenu->optionsText = menuBuildText(&gDejaVuSansFont, "OPTIONS", 30, 164);
}
void landingMenuRender(struct LandingMenu* landingMenu, struct RenderState* renderState, struct GraphicsTask* task) {
gSPDisplayList(renderState->dl++, ui_material_list[DEFAULT_UI_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[PORTAL_LOGO_INDEX]);
gSPDisplayList(renderState->dl++, portal_logo_gfx);
gSPDisplayList(renderState->dl++, ui_material_revert_list[PORTAL_LOGO_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
gSPDisplayList(renderState->dl++, landingMenu->newGameText);
gSPDisplayList(renderState->dl++, landingMenu->loadGameText);
gSPDisplayList(renderState->dl++, landingMenu->optionsText);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
#define CHAPTER_IMAGE_SIZE (76 * 44 * 2)
void chapterMenuInit(struct ChapterMenu* chapterMenu, int x, int y) {
chapterMenu->chapterText = malloc(sizeof(Gfx) * 3 * 10 + 1);
chapterMenu->testChamberText = malloc(sizeof(Gfx) * 3 * 14 + 1);
chapterMenu->border = menuBuildSolidBorder(
x, y + 27,
92, 58,
x + 5, y + 32,
84, 48
);
chapterMenu->imageBuffer = malloc(CHAPTER_IMAGE_SIZE);
zeroMemory(chapterMenu->imageBuffer, CHAPTER_IMAGE_SIZE);
Gfx* dl = chapterMenu->chapterText;
gSPEndDisplayList(dl++);
return result;
dl = chapterMenu->testChamberText;
gSPEndDisplayList(dl++);
chapterMenu->chapter = NULL;
chapterMenu->x = x;
chapterMenu->y = y;
}
void chapterMenuSetChapter(struct ChapterMenu* chapterMenu, struct Chapter* chapter) {
Gfx* dl = fontRender(
&gDejaVuSansFont,
chapter->chapter,
chapterMenu->x,
chapterMenu->y,
chapterMenu->chapterText
);
gSPEndDisplayList(dl++);
dl = fontRender(
&gDejaVuSansFont,
chapter->testChamber,
chapterMenu->x,
chapterMenu->y + 14,
chapterMenu->testChamberText
);
gSPEndDisplayList(dl++);
romCopy(chapter->imageData, chapterMenu->imageBuffer, CHAPTER_IMAGE_SIZE);
}
#define NEW_GAME_LEFT 40
#define NEW_GAME_TOP 45
void newGameInit(struct NewGameMenu* newGameMenu) {
newGameMenu->menuOutline = menuBuildBorder(NEW_GAME_LEFT, NEW_GAME_TOP, SCREEN_WD - NEW_GAME_LEFT * 2, SCREEN_HT - NEW_GAME_TOP * 2);
newGameMenu->newGameText = menuBuildText(&gDejaVuSansFont, "NEW GAME", 48, 48);
newGameMenu->topLine = menuBuildHorizontalLine(52, 64, 214);
newGameMenu->bottomLine = menuBuildHorizontalLine(52, 158, 220);
newGameMenu->cancelButton = menuBuildButton(&gDejaVuSansFont, "Cancel", 222, 169, 46, 16);
chapterMenuInit(&newGameMenu->chapter0, 55, 71);
chapterMenuInit(&newGameMenu->chapter1, 163, 71);
chapterMenuSetChapter(&newGameMenu->chapter0, &gChapters[0]);
chapterMenuSetChapter(&newGameMenu->chapter1, &gChapters[1]);
}
void newGameRender(struct NewGameMenu* newGameMenu, struct RenderState* renderState, struct GraphicsTask* task) {
gSPDisplayList(renderState->dl++, ui_material_list[DEFAULT_UI_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[SOLID_TRANSPARENT_OVERLAY_INDEX]);
gDPFillRectangle(renderState->dl++, 0, 0, SCREEN_WD, SCREEN_HT);
gSPDisplayList(renderState->dl++, ui_material_revert_list[SOLID_TRANSPARENT_OVERLAY_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[ROUNDED_CORNERS_INDEX]);
gSPDisplayList(renderState->dl++, newGameMenu->menuOutline);
gSPDisplayList(renderState->dl++, ui_material_revert_list[ROUNDED_CORNERS_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[SOLID_ENV_INDEX]);
gSPDisplayList(renderState->dl++, newGameMenu->topLine);
gSPDisplayList(renderState->dl++, newGameMenu->bottomLine);
gSPDisplayList(renderState->dl++, newGameMenu->cancelButton.outline);
gDPPipeSync(renderState->dl++);
gDPSetEnvColor(renderState->dl++, 0, 0, 0, 255);
gSPDisplayList(renderState->dl++, newGameMenu->chapter0.border);
gDPPipeSync(renderState->dl++);
gDPSetEnvColor(renderState->dl++, 0, 0, 0, 255);
gSPDisplayList(renderState->dl++, newGameMenu->chapter1.border);
gSPDisplayList(renderState->dl++, ui_material_revert_list[SOLID_ENV_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
gSPDisplayList(renderState->dl++, newGameMenu->newGameText);
gSPDisplayList(renderState->dl++, newGameMenu->cancelButton.text);
gDPPipeSync(renderState->dl++);
gDPSetEnvColor(renderState->dl++, 255, 255, 255, 255);
gSPDisplayList(renderState->dl++, newGameMenu->chapter0.chapterText);
gSPDisplayList(renderState->dl++, newGameMenu->chapter0.testChamberText);
gDPPipeSync(renderState->dl++);
gDPSetEnvColor(renderState->dl++, 255, 255, 255, 255);
gSPDisplayList(renderState->dl++, newGameMenu->chapter1.chapterText);
gSPDisplayList(renderState->dl++, newGameMenu->chapter1.testChamberText);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
graphicsCopyImage(
renderState, newGameMenu->chapter0.imageBuffer,
84, 48,
0, 0,
newGameMenu->chapter0.x + 5,
newGameMenu->chapter0.y + 28,
84, 48,
gColorWhite
);
graphicsCopyImage(
renderState, newGameMenu->chapter1.imageBuffer,
84, 48,
0, 0,
newGameMenu->chapter1.x + 5,
newGameMenu->chapter1.y + 28,
84, 48,
gColorWhite
);
}
void mainMenuReadCamera(struct MainMenu* mainMenu) {
@ -30,9 +233,8 @@ void mainMenuReadCamera(struct MainMenu* mainMenu) {
void mainMenuInit(struct MainMenu* mainMenu) {
sceneInit(&gScene);
mainMenu->newGameText = menuBuildText(&gDejaVuSansFont, "NEW GAME", 30, 135);
mainMenu->loadGameText = menuBuildText(&gDejaVuSansFont, "LOAD GAME", 30, 147);
mainMenu->optionsText = menuBuildText(&gDejaVuSansFont, "OPTIONS", 30, 159);
landingMenuInit(&mainMenu->landingMenu);
newGameInit(&mainMenu->newGameMenu);
mainMenuReadCamera(mainMenu);
@ -77,10 +279,6 @@ void mainMenuRender(struct MainMenu* mainMenu, struct RenderState* renderState,
renderPlanBuild(&renderPlan, &gScene, renderState);
renderPlanExecute(&renderPlan, &gScene, staticMatrices, renderState);
gSPDisplayList(renderState->dl++, ui_material_list[DEFAULT_UI_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
gSPDisplayList(renderState->dl++, mainMenu->newGameText);
gSPDisplayList(renderState->dl++, mainMenu->loadGameText);
gSPDisplayList(renderState->dl++, mainMenu->optionsText);
// landingMenuRender(&mainMenu->landingMenu, renderState, task);
newGameRender(&mainMenu->newGameMenu, renderState, task);
}

View file

@ -2,13 +2,56 @@
#define __MENU_MAIN_MENU_H___
#include "../graphics/graphics.h"
#include "./menu.h"
struct MainMenu {
struct LandingMenu {
Gfx* newGameText;
Gfx* loadGameText;
Gfx* optionsText;
};
void landingMenuInit(struct LandingMenu* landingMenu);
void landingMenuRender(struct LandingMenu* landingMenu, struct RenderState* renderState, struct GraphicsTask* task);
struct Chapter {
char* chapter;
char* testChamber;
void* imageData;
};
struct ChapterMenu {
Gfx* chapterText;
Gfx* testChamberText;
Gfx* border;
void* imageBuffer;
struct Chapter* chapter;
int x;
int y;
};
void chapterMenuInit(struct ChapterMenu* chapterMenu, int x, int y);
void chapterMenuSetChapter(struct ChapterMenu* chapterMenu, struct Chapter* chapter);
struct NewGameMenu {
Gfx* menuOutline;
Gfx* newGameText;
Gfx* topLine;
Gfx* bottomLine;
struct MenuButton cancelButton;
struct ChapterMenu chapter0;
struct ChapterMenu chapter1;
};
void newGameInit(struct NewGameMenu* newGameMenu);
void newGameRender(struct NewGameMenu* newGameMenu, struct RenderState* renderState, struct GraphicsTask* task);
struct MainMenu {
struct LandingMenu landingMenu;
struct NewGameMenu newGameMenu;
};
void mainMenuInit(struct MainMenu* mainMenu);
void mainMenuUpdate(struct MainMenu* mainMenu);
void mainMenuRender(struct MainMenu* mainMenu, struct RenderState* renderState, struct GraphicsTask* task);

134
src/menu/menu.c Normal file
View file

@ -0,0 +1,134 @@
#include "menu.h"
#include "../util/memory.h"
Gfx* menuBuildText(struct Font* font, char* message, int x, int y) {
Gfx* result = malloc(sizeof(Gfx) * (fontCountGfx(font, message) + 1));
Gfx* dl = result;
dl = fontRender(font, message, x, y, dl);
gSPEndDisplayList(dl++);
return result;
}
Gfx* menuBuildBorder(int x, int y, int width, int height) {
Gfx* result = malloc(sizeof(Gfx) * 7 * 3 + 1);
Gfx* dl = result;
gSPTextureRectangle(
dl++,
x << 2, y << 2,
(x + 4) << 2, (y + 4) << 2,
G_TX_RENDERTILE,
0 << 5, 0 << 5,
0x400, 0x400
);
gSPTextureRectangle(
dl++,
(x + 4) << 2, y << 2,
(x + width - 4) << 2, (y + 4) << 2,
G_TX_RENDERTILE,
4 << 5, 4 << 5,
0, 0
);
gSPTextureRectangle(
dl++,
(x + width - 4) << 2, y << 2,
(x + width) << 2, (y + 4) << 2,
G_TX_RENDERTILE,
4 << 5, 0 << 5,
0x400, 0x400
);
gSPTextureRectangle(
dl++,
x << 2, (y + 4) << 2,
(x + width) << 2, (y + height - 4) << 2,
G_TX_RENDERTILE,
4 << 5, 4 << 5,
0, 0
);
gSPTextureRectangle(
dl++,
x << 2, (y + height - 4) << 2,
(x + 4) << 2, (y + height) << 2,
G_TX_RENDERTILE,
0 << 5, 4 << 5,
0x400, 0x400
);
gSPTextureRectangle(
dl++,
(x + 4) << 2, (y + height - 4) << 2,
(x + width - 4) << 2, (y + height) << 2,
G_TX_RENDERTILE,
4 << 5, 4 << 5,
0, 0
);
gSPTextureRectangle(
dl++,
(x + width - 4) << 2, (y + height - 4) << 2,
(x + width) << 2, (y + height) << 2,
G_TX_RENDERTILE,
4 << 5, 4 << 5,
0x400, 0x400
);
gSPEndDisplayList(dl++);
return result;
}
Gfx* menuBuildHorizontalLine(int x, int y, int width) {
Gfx* result = malloc(sizeof(Gfx) * 7);
Gfx* dl = result;
gDPPipeSync(dl++);
gDPSetEnvColor(dl++, 86, 86, 86, 128);
gDPFillRectangle(dl++, x, y, x + width, y + 1);
gDPPipeSync(dl++);
gDPSetEnvColor(dl++, 193, 193, 193, 128);
gDPFillRectangle(dl++, x, y + 1, x + width, y + 2);
gSPEndDisplayList(dl++);
return result;
}
Gfx* menuBuildSolidBorder(int x, int y, int w, int h, int nx, int ny, int nw, int nh) {
Gfx* result = malloc(sizeof(Gfx) * 5);
Gfx* dl = result;
gDPFillRectangle(dl++, x, y, x + w, ny);
gDPFillRectangle(dl++, x, ny, nx, ny + nh);
gDPFillRectangle(dl++, nx + nw, ny, x + w, ny + nh);
gDPFillRectangle(dl++, x, ny + nh, x + w, y + h);
gSPEndDisplayList(dl++);
return result;
}
struct MenuButton menuBuildButton(struct Font* font, char* message, int x, int y, int width, int height) {
struct MenuButton result;
result.text = menuBuildText(font, message, x + 4, y + 2);
result.outline = malloc(sizeof(Gfx) * 9);
Gfx* dl = result.outline;
gDPPipeSync(dl++);
gDPSetEnvColor(dl++, 188, 188, 188, 255);
gDPFillRectangle(dl++, x, y, x + width - 1, y + 1);
gDPFillRectangle(dl++, x, y, x + 1, y + height);
gDPPipeSync(dl++);
gDPSetEnvColor(dl++, 76, 76, 76, 255);
gDPFillRectangle(dl++, x, y + height - 1, x + width, y + height);
gDPFillRectangle(dl++, x + width - 1, y, x + width, y + height - 1);
gSPEndDisplayList(dl++);
return result;
}

19
src/menu/menu.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef __MENU_MENU_H__
#define __MENU_MENU_H__
#include <ultra64.h>
#include "../font/font.h"
struct MenuButton {
Gfx* outline;
Gfx* text;
};
Gfx* menuBuildText(struct Font* font, char* message, int x, int y);
Gfx* menuBuildBorder(int x, int y, int width, int height);
Gfx* menuBuildHorizontalLine(int x, int y, int width);
Gfx* menuBuildSolidBorder(int x, int y, int w, int h, int nx, int ny, int nw, int nh);
struct MenuButton menuBuildButton(struct Font* font, char* message, int x, int y, int width, int height);
#endif