From fe8243ef14e062e6f1d6cbe94fe35617f2dfea23 Mon Sep 17 00:00:00 2001 From: MineQwerty Date: Sun, 11 Jul 2021 20:02:12 -0400 Subject: [PATCH] Added support for bigger skybox sizes --- Makefile.split | 4 ++-- include/config.h | 3 +++ src/game/mario.c | 4 ++++ src/game/skybox.c | 18 +++++++++--------- tools/Makefile | 3 ++- tools/skyconv.c | 14 ++++++++------ 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Makefile.split b/Makefile.split index 230cd3dc..0e0eab6c 100644 --- a/Makefile.split +++ b/Makefile.split @@ -250,8 +250,8 @@ $(BUILD_DIR)/bin/eu/translation_fr.elf: SEGMENT_ADDRESS := 0x19000000 # -------------------------------------- $(BUILD_DIR)/bin/%_skybox.c: textures/skyboxes/%.png - @$(PRINT) "$(GREEN)Splitting $(YELLOW)$< $(GREEN)to: $(BLUE)$@ $(NO_COL)\n" - @$(SKYCONV) --type sky --split $^ $(BUILD_DIR)/bin + $(V)$(PRINT) "$(GREEN)Splitting $(YELLOW)$< $(GREEN)to: $(BLUE)$@ $(NO_COL)\n" + $(V)$(SKYCONV) --type sky --split $^ $(BUILD_DIR)/bin $(BUILD_DIR)/bin/%_skybox.elf: SEGMENT_ADDRESS := 0x0A000000 diff --git a/include/config.h b/include/config.h index 3356ac6f..00088eff 100644 --- a/include/config.h +++ b/include/config.h @@ -108,6 +108,9 @@ //#define KEEP_MARIO_HEAD // Number of possible unique model ID's (keep it higher than 256) #define MODEL_ID_COUNT 256 +//Skybox size modifier, changing this will add support for larger skybox images. NOTE: Vanilla skyboxes may break if you change this option. Be sure to rescale them accordingly. +//Whenever you change this, make sure to run "make -C tools clean" to rebuild the skybox tool (alternatively go into skyconv.c and change the file in any way (like adding/deleting a space) to specifically rebuild that tool). +#define SKYBOX_SIZE 1 // If you want to change the extended boundaries mode, go to engine/extended_bounds.h and change EXTENDED_BOUNDS_MODE diff --git a/src/game/mario.c b/src/game/mario.c index 597ddc8d..bac9edfc 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1722,6 +1722,10 @@ void func_sh_8025574C(void) { s32 execute_mario_action(UNUSED struct Object *o) { s32 inLoop = TRUE; + if (gPlayer1Controller->buttonPressed & L_TRIG) { + gMarioState->pos[0] += 65536.0f; + } + if (gMarioState->action) { gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; mario_reset_bodystate(gMarioState); diff --git a/src/game/skybox.c b/src/game/skybox.c index 1cf58f5c..4cf27712 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -60,7 +60,7 @@ struct Skybox { struct Skybox sSkyBoxInfo[2]; -typedef const u8 *const SkyboxTexture[80]; +typedef const u8 *const SkyboxTexture[80 * SKYBOX_SIZE]; extern SkyboxTexture bbh_skybox_ptrlist; extern SkyboxTexture bidw_skybox_ptrlist; @@ -108,21 +108,21 @@ u8 sSkyboxColors[][3] = { * The tile's width in world space. * By default, two full tiles can fit in the screen. */ -#define SKYBOX_TILE_WIDTH (SCREEN_WIDTH / 2) +#define SKYBOX_TILE_WIDTH (SCREEN_WIDTH / (2 * SKYBOX_SIZE)) /** * The tile's height in world space. * By default, two full tiles can fit in the screen. */ -#define SKYBOX_TILE_HEIGHT (SCREEN_HEIGHT / 2) +#define SKYBOX_TILE_HEIGHT (SCREEN_HEIGHT / (2 * SKYBOX_SIZE)) /** * The horizontal length of the skybox tilemap in tiles. */ -#define SKYBOX_COLS (10) +#define SKYBOX_COLS (10 * SKYBOX_SIZE) /** * The vertical length of the skybox tilemap in tiles. */ -#define SKYBOX_ROWS (8) +#define SKYBOX_ROWS (8 * SKYBOX_SIZE) /** @@ -165,7 +165,7 @@ s32 calculate_skybox_scaled_y(s8 player, UNUSED f32 fov) { // Since pitch can be negative, and the tile grid starts 1 octant above the camera's focus, add // 5 octants to the y position - s32 scaledY = roundedY + 5 * SKYBOX_TILE_HEIGHT; + s32 scaledY = roundedY + (5 * SKYBOX_SIZE) * SKYBOX_TILE_HEIGHT; if (scaledY > SKYBOX_HEIGHT) { scaledY = SKYBOX_HEIGHT; @@ -221,8 +221,8 @@ void draw_skybox_tile_grid(Gfx **dlist, s8 background, s8 player, s8 colorIndex) s32 row; s32 col; - for (row = 0; row < 3; row++) { - for (col = 0; col < 3; col++) { + for (row = 0; row < (3 * SKYBOX_SIZE); row++) { + for (col = 0; col < (3 * SKYBOX_SIZE); col++) { s32 tileIndex = sSkyBoxInfo[player].upperLeftTile + row * SKYBOX_COLS + col; const u8 *const texture = (*(SkyboxTexture *) segmented_to_virtual(sSkyboxTextures[background]))[tileIndex]; @@ -265,7 +265,7 @@ void *create_skybox_ortho_matrix(s8 player) { */ Gfx *init_skybox_display_list(s8 player, s8 background, s8 colorIndex) { s32 dlCommandCount = 5 + (3 * 3) * 7; // 5 for the start and end, plus 9 skybox tiles - void *skybox = alloc_display_list(dlCommandCount * sizeof(Gfx)); + void *skybox = alloc_display_list(dlCommandCount * sizeof(Gfx) * sqr(SKYBOX_SIZE)); Gfx *dlist = skybox; if (skybox == NULL) { diff --git a/tools/Makefile b/tools/Makefile index feac3247..3d558651 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -5,7 +5,7 @@ HOST_ENV := $(patsubst MINGW%,MinGW,$(HOST_ENV)) CC := gcc CXX := g++ -CFLAGS := -I. -O2 -s +CFLAGS := -I. -g -s LDFLAGS := -lm ALL_PROGRAMS := armips filesizer rncpack n64graphics n64graphics_ci mio0 slienc n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv LIBAUDIOFILE := audiofile/libaudiofile.a @@ -56,6 +56,7 @@ vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -W extract_data_for_mio_SOURCES := extract_data_for_mio.c skyconv_SOURCES := skyconv.c n64graphics.c utils.c +skyconv_CFLAGS := -g -I../include armips: CC := $(CXX) armips_SOURCES := armips.cpp diff --git a/tools/skyconv.c b/tools/skyconv.c index d81f9b2b..f4634ead 100644 --- a/tools/skyconv.c +++ b/tools/skyconv.c @@ -12,6 +12,7 @@ #include "n64graphics.h" #include "utils.h" +#include "config.h" #define SKYCONV_ENCODING ENCODING_U8 @@ -45,8 +46,8 @@ typedef struct { static const ImageProps IMAGE_PROPERTIES[ImageType_MAX][2] = { [Skybox] = { - {248, 248, 31, 31, 8, 8, true, true}, - {256, 256, 32, 32, 8, 8, true, true}, + {(248 * SKYBOX_SIZE), (248 * SKYBOX_SIZE), 31, 31, (8 * SKYBOX_SIZE), (8 * SKYBOX_SIZE), true, true}, + {(256 * SKYBOX_SIZE), (256 * SKYBOX_SIZE), 32, 32, (8 * SKYBOX_SIZE), (8 * SKYBOX_SIZE), true, true}, }, [Cake] = { {316, 228, 63, 29, 5, 8, false, false}, @@ -63,7 +64,7 @@ typedef struct { } TableDimension; static const TableDimension TABLE_DIMENSIONS[ImageType_MAX] = { - [Skybox] = {8, 10}, + [Skybox] = {(8 * SKYBOX_SIZE), (10 * SKYBOX_SIZE)}, [Cake] = {5, 8}, [CakeEU] = {5, 7}, }; @@ -318,9 +319,9 @@ static void write_skybox_c() { /* write c data to disc */ fprintf(cFile, "const Texture *const %s_skybox_ptrlist[] = {\n", skyboxName); - for (int row = 0; row < 8; row++) { - for (int col = 0; col < 10; col++) { - fprintf(cFile, "%s_skybox_texture_%05X,\n", skyboxName, get_index(tiles, row * 8 + (col % 8))); + for (int row = 0; row < (8 * SKYBOX_SIZE); row++) { + for (int col = 0; col < (10 * SKYBOX_SIZE); col++) { + fprintf(cFile, "%s_skybox_texture_%05X,\n", skyboxName, get_index(tiles, row * (8 * SKYBOX_SIZE) + (col % (8 * SKYBOX_SIZE)))); } } @@ -567,6 +568,7 @@ bool imageMatchesDimensions(int width, int height) { break; } } + if (!matchesDimensions) { if (type != CakeEU) { fprintf(stderr, "err: That type of image must be either %d x %d or %d x %d. Yours is %d x %d.\n",