Skip to content

Commit 87a316b

Browse files
committed
Basic minimap functionality
1 parent eb2ee86 commit 87a316b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+798
-74
lines changed

Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,8 @@ ifeq ($(COMPILER),gcc)
416416
CC := $(CROSS)gcc
417417
endif
418418

419-
ifeq ($(TARGET_N64),1)
420-
TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64 -D_LANGUAGE_C
421-
CC_CFLAGS := -fno-builtin
422-
endif
423-
419+
TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64 -D_LANGUAGE_C
420+
CC_CFLAGS := -fno-builtin
424421
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
425422

426423
# Check code syntax with host compiler
@@ -495,8 +492,8 @@ ifeq ($(TARGET_WEB),1)
495492
PLATFORM_LDFLAGS := -lm -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
496493
endif
497494
ifeq ($(TARGET_N3DS),1)
498-
CTRULIB := $(DEVKITPRO)/libctru
499-
LIBDIRS := $(CTRULIB)
495+
CTRULIB := $(DEVKITPRO)/libctru
496+
LIBDIRS := $(CTRULIB)
500497
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
501498
PLATFORM_CFLAGS := -mtp=soft -DTARGET_N3DS -DARM11 -DosGetTime=n64_osGetTime -D_3DS -march=armv6k -mtune=mpcore -mfloat-abi=hard -mword-relocations -fomit-frame-pointer -ffast-math $(foreach dir,$(LIBDIRS),-I$(dir)/include)
502499
PLATFORM_LDFLAGS := $(LIBPATHS) -lcitro3d -lctru -lm -specs=3dsx.specs -g -marm -mthumb-interwork -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
@@ -891,8 +888,8 @@ SMDH_DESCRIPTION ?= Super Mario 64 3DS Port
891888
SMDH_AUTHOR ?= mkst
892889
SMDH_ICON := icon.smdh
893890

894-
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/src/pc/gfx/shader.shbin.o $(SMDH_ICON)
895-
$(LD) -L $(BUILD_DIR) -o $@.elf $(O_FILES) $(BUILD_DIR)/src/pc/gfx/shader.shbin.o $(MINIMAP_T3X_O) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
891+
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/src/pc/gfx/shader.shbin.o $(MINIMAP_O) $(SMDH_ICON)
892+
$(LD) -L $(BUILD_DIR) -o $@.elf $(O_FILES) $(BUILD_DIR)/src/pc/gfx/shader.shbin.o $(MINIMAP_O) $(MINIMAP_T3X_O) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
896893
3dsxtool $@.elf $@ --smdh=$(BUILD_DIR)/$(SMDH_ICON)
897894

898895
# stolen from /opt/devkitpro/devkitARM/base_tools
@@ -901,9 +898,11 @@ define bin2o
901898
endef
902899

903900
# TODO: simplify dependency chain
904-
$(BUILD_DIR)/src/pc/gfx/gfx_citro3d.o: $(BUILD_DIR)/src/pc/gfx/gfx_3ds.o
905-
$(BUILD_DIR)/src/pc/gfx/gfx_3ds.o: $(BUILD_DIR)/src/pc/gfx/gfx_3ds_menu.o
901+
$(BUILD_DIR)/src/pc/gfx/gfx_citro3d.o: $(MINIMAP_O)
902+
$(BUILD_DIR)/src/pc/gfx/gfx_3ds.o: $(MINIMAP_O)
903+
$(BUILD_DIR)/src/pc/gfx/gfx_3ds_minimap.o: $(MINIMAP_O)
906904
$(BUILD_DIR)/src/pc/gfx/gfx_3ds_menu.o: $(MINIMAP_T3X_HEADERS)
905+
$(MINIMAP_O): $(MINIMAP_T3X_HEADERS)
907906

908907
%.t3x.o $(BUILD_DIR)/%_t3x.h: %.t3x
909908
$(bin2o)
@@ -914,7 +913,6 @@ $(BUILD_DIR)/src/pc/gfx/gfx_3ds_menu.o: $(MINIMAP_T3X_HEADERS)
914913
%.t3s: %.png
915914
@printf -- "-f rgba -z auto\n../../../../../$(<)\n" > $(BUILD_DIR)/$@
916915

917-
918916
%.smdh: %.png
919917
smdhtool --create "$(SMDH_TITLE)" "$(SMDH_DESCRIPTION)" "$(SMDH_AUTHOR)" $< $(BUILD_DIR)/$@
920918

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A prior copy of the game is required to extract the assets.
1616
- Experimental Stereo 3D support; add build flag `ENABLE_N3DS_3D_MODE=1` to try it out
1717
- Support injection of [SMDH](https://www.3dbrew.org/wiki/SMDH) file into the .3dsx
1818
- Change the `icon.png` in the base of this repository before building.
19+
- Experimental Mini-Map; bottom screen displays an overview of the current level
1920

2021
## Building
2122

enhancements/60fps.patch

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,10 @@ index 7a83b53..3b21da5 100644
607607

608608
extern s8 gEnvFxMode;
609609
diff --git a/src/game/hud.c b/src/game/hud.c
610-
index 5d78cfc..70649c9 100644
610+
index 9dc514e..5d864a5 100644
611611
--- a/src/game/hud.c
612612
+++ b/src/game/hud.c
613-
@@ -57,6 +57,20 @@ static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 };
613+
@@ -61,6 +61,20 @@ static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 };
614614

615615
static struct CameraHUD sCameraHUD = { CAM_STATUS_NONE };
616616

@@ -631,15 +631,15 @@ index 5d78cfc..70649c9 100644
631631
/**
632632
* Renders a rgba16 16x16 glyph texture from a table list.
633633
*/
634-
@@ -109,6 +123,7 @@ void render_power_meter_health_segment(s16 numHealthWedges) {
634+
@@ -113,6 +127,7 @@ void render_power_meter_health_segment(s16 numHealthWedges) {
635635
*/
636636
void render_dl_power_meter(s16 numHealthWedges) {
637637
Mtx *mtx;
638638
+ f32 interpolatedY;
639639

640640
mtx = alloc_display_list(sizeof(Mtx));
641641

642-
@@ -116,7 +131,15 @@ void render_dl_power_meter(s16 numHealthWedges) {
642+
@@ -120,7 +135,15 @@ void render_dl_power_meter(s16 numHealthWedges) {
643643
return;
644644
}
645645

@@ -657,7 +657,7 @@ index 5d78cfc..70649c9 100644
657657
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx++),
658658
G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH);
659659
diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c
660-
index 04047a1..4712035 100644
660+
index b9a43df..281e0f3 100644
661661
--- a/src/game/ingame_menu.c
662662
+++ b/src/game/ingame_menu.c
663663
@@ -111,6 +111,41 @@ u8 gMenuHoldKeyIndex = 0;
@@ -1857,18 +1857,15 @@ index 2d49d06..31cb72f 100644
18571857
gSPDisplayList(displayListIter++, &intro_seg7_dl_0700B3A0);
18581858
gSPPopMatrix(displayListIter++, G_MTX_MODELVIEW);
18591859
diff --git a/src/pc/gfx/gfx_citro3d.c b/src/pc/gfx/gfx_citro3d.c
1860-
index 3e17666..a4143fc 100644
1860+
index 805623c..b12d1bc 100644
18611861
--- a/src/pc/gfx/gfx_citro3d.c
18621862
+++ b/src/pc/gfx/gfx_citro3d.c
1863-
@@ -823,14 +823,10 @@ static void gfx_citro3d_on_resize(void)
1863+
@@ -849,11 +849,7 @@ static void gfx_citro3d_on_resize(void)
18641864

18651865
static void gfx_citro3d_end_frame(void)
18661866
{
18671867
- float target_fps = 30.0f;
18681868
-
1869-
// TOOD: draw the minimap here
1870-
gfx_3ds_menu_draw(sVboBuffer, sBufIdx, gShowConfigMenu);
1871-
18721869
C3D_FrameEnd(0);
18731870
- if (C3D_GetProcessingTime() < 1000.0f / target_fps)
18741871
- gspWaitForVBlank();

enhancements/puppycam.patch

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Makefile b/Makefile
2-
index db5b620..52177e0 100644
2+
index 7014d66..eb86fba 100644
33
--- a/Makefile
44
+++ b/Makefile
55
@@ -264,7 +264,7 @@ else
@@ -11,7 +11,7 @@ index db5b620..52177e0 100644
1111
endif
1212
endif
1313

14-
@@ -648,6 +648,8 @@ $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
14+
@@ -665,6 +665,8 @@ $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
1515
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h
1616
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h
1717
$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h
@@ -92,7 +92,7 @@ index 0000000..dc4481e
9292
+#endif // TARGET_N64
9393
diff --git a/enhancements/puppycam.inc.c b/enhancements/puppycam.inc.c
9494
new file mode 100644
95-
index 0000000..eedb206
95+
index 0000000..f75b329
9696
--- /dev/null
9797
+++ b/enhancements/puppycam.inc.c
9898
@@ -0,0 +1,1058 @@
@@ -1813,7 +1813,7 @@ index f56ed02..36bb6d9 100644
18131813
extern struct Object *gCutsceneFocus;
18141814
extern struct Object *gSecondCameraFocus;
18151815
diff --git a/src/game/game_init.c b/src/game/game_init.c
1816-
index 3ce5f2d..856388b 100644
1816+
index 3ce5f2d..b12b8df 100644
18171817
--- a/src/game/game_init.c
18181818
+++ b/src/game/game_init.c
18191819
@@ -20,6 +20,8 @@
@@ -1834,7 +1834,7 @@ index 3ce5f2d..856388b 100644
18341834
#ifdef TARGET_N64
18351835
rendering_init();
18361836
diff --git a/src/game/hud.c b/src/game/hud.c
1837-
index 5d78cfc..2a9b874 100644
1837+
index 9dc514e..1355475 100644
18381838
--- a/src/game/hud.c
18391839
+++ b/src/game/hud.c
18401840
@@ -13,6 +13,7 @@
@@ -1845,18 +1845,18 @@ index 5d78cfc..2a9b874 100644
18451845

18461846
/* @file hud.c
18471847
* This file implements HUD rendering and power meter animations.
1848-
@@ -472,7 +473,8 @@ void render_hud(void) {
1849-
1850-
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) {
1851-
render_hud_power_meter();
1848+
@@ -502,7 +503,8 @@ void render_hud(void) {
1849+
gDPSetHud(gDisplayListHead++, 1);
1850+
gDPSet2d(gDisplayListHead++, 0);
1851+
#endif
18521852
- render_hud_camera_status();
18531853
+ if (!newcam_active)
18541854
+ render_hud_camera_status();
18551855
}
18561856

18571857
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER) {
18581858
diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c
1859-
index 04047a1..dee4fb9 100644
1859+
index b9a43df..f6f2d7f 100644
18601860
--- a/src/game/ingame_menu.c
18611861
+++ b/src/game/ingame_menu.c
18621862
@@ -22,6 +22,7 @@
@@ -2258,4 +2258,3 @@ index 00f3fae..038216d 100644
22582258
+extern s16 rightstick[2];
22592259

22602260
#endif
2261-

include/PR/gbi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,6 +4809,13 @@ typedef union {
48094809
\
48104810
_g->words.w0 = _SHIFTL(G_SPECIAL_2, 24, 8); \
48114811
}
4812+
#define gDPSetHud(pkt, mode) \
4813+
{ \
4814+
Gfx *_g = (Gfx *)(pkt); \
4815+
\
4816+
_g->words.w0 = _SHIFTL(G_SPECIAL_3, 24, 8); \
4817+
_g->words.w1 = (unsigned int)(mode); \
4818+
}
48124819

48134820
#endif
48144821

src/game/area.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void render_game(void) {
367367

368368
#ifdef ENABLE_N3DS_3D_MODE
369369
gDPForceFlush(gDisplayListHead++); // flush 3D scene
370-
gDPSet2d(gDisplayListHead++, 1); // HUD is 2D
370+
gDPSetHud(gDisplayListHead++, 1); // set hud mode
371371
#endif
372372
gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));
373373

@@ -379,7 +379,7 @@ void render_game(void) {
379379
render_text_labels();
380380
#ifdef ENABLE_N3DS_3D_MODE
381381
gDPForceFlush(gDisplayListHead++); // flush hud
382-
gDPSet2d(gDisplayListHead++, 0); // reset 2D mode
382+
gDPSetHud(gDisplayListHead++, 0); // reset hud mode
383383
#endif
384384
do_cutscene_handler();
385385
print_displaying_credits_entry();

src/game/hud.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ static s16 sPowerMeterStoredHealth;
4343

4444
static struct PowerMeterHUD sPowerMeterHUD = {
4545
POWER_METER_HIDDEN,
46+
#if ENABLE_N3DS_3D_MODE
47+
160,
48+
#else
4649
140,
50+
#endif
4751
166,
4852
1.0,
4953
};
@@ -259,16 +263,26 @@ void render_hud_power_meter(void) {
259263
#ifdef VERSION_JP
260264
#define HUD_TOP_Y 210
261265
#else
266+
#ifdef ENABLE_N3DS_3D_MODE
267+
#define HUD_TOP_Y 220
268+
#else
262269
#define HUD_TOP_Y 209
263270
#endif
271+
#endif
264272

265273
/**
266274
* Renders the amount of lives Mario has.
267275
*/
268276
void render_hud_mario_lives(void) {
277+
#ifdef ENABLE_N3DS_3D_MODE
278+
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(42), HUD_TOP_Y, ","); // 'Mario Head' glyph
279+
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(58), HUD_TOP_Y, "*"); // 'X' glyph
280+
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(74), HUD_TOP_Y, "%d", gHudDisplay.lives);
281+
#else
269282
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(22), HUD_TOP_Y, ","); // 'Mario Head' glyph
270283
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(38), HUD_TOP_Y, "*"); // 'X' glyph
271284
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(54), HUD_TOP_Y, "%d", gHudDisplay.lives);
285+
#endif
272286
}
273287

274288
/**
@@ -283,8 +297,12 @@ void render_hud_coins(void) {
283297
#ifdef VERSION_JP
284298
#define HUD_STARS_X 73
285299
#else
300+
#ifdef ENABLE_N3DS_3D_MODE
301+
#define HUD_STARS_X 98
302+
#else
286303
#define HUD_STARS_X 78
287304
#endif
305+
#endif
288306

289307
/**
290308
* Renders the amount of stars collected.
@@ -380,9 +398,14 @@ void render_hud_camera_status(void) {
380398
s32 y;
381399

382400
cameraLUT = segmented_to_virtual(&main_hud_camera_lut);
401+
402+
#ifdef ENABLE_N3DS_3D_MODE
403+
x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(74);
404+
y = 215;
405+
#else
383406
x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54);
384407
y = 205;
385-
408+
#endif
386409
if (sCameraHUD.status == CAM_STATUS_NONE) {
387410
return;
388411
}
@@ -468,7 +491,17 @@ void render_hud(void) {
468491
}
469492

470493
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) {
494+
#ifdef ENABLE_N3DS_3D_MODE
495+
gDPForceFlush(gDisplayListHead++);
496+
gDPSetHud(gDisplayListHead++, 0);
497+
gDPSet2d(gDisplayListHead++, 1);
498+
#endif
471499
render_hud_power_meter();
500+
#ifdef ENABLE_N3DS_3D_MODE
501+
gDPForceFlush(gDisplayListHead++);
502+
gDPSetHud(gDisplayListHead++, 1);
503+
gDPSet2d(gDisplayListHead++, 0);
504+
#endif
472505
render_hud_camera_status();
473506
}
474507

0 commit comments

Comments
 (0)