Merge branch 'master' into puppycamera2

This commit is contained in:
Fazana authored and GitHub committed 2021-08-19 18:53:39 +01:00
commit 129a29cbb2
34 files changed
+660 -5612

No files matched your search

+3
View File
@@ -3509,6 +3509,9 @@ void init_camera(struct Camera *c) {
gLakituState.nextYaw = gLakituState.yaw;
c->yaw = gLakituState.yaw;
c->nextYaw = gLakituState.yaw;
#ifdef CAMERA_FIX
set_camera_mode(c, CAMERA_MODE_8_DIRECTIONS, 0);
#endif
#ifdef PUPPYCAM
puppycam_init();
#endif
+1 -1
View File
@@ -9,7 +9,7 @@
#include "types.h"
#include "memory.h"
#define GFX_POOL_SIZE 6400 // Size of how large the master display list (gDisplayListHead) can be
#define GFX_POOL_SIZE 10000 // Size of how large the master display list (gDisplayListHead) can be
struct GfxPool {
Gfx buffer[GFX_POOL_SIZE];
+78 -14
View File
@@ -8,6 +8,7 @@
#include "dialog_ids.h"
#include "engine/math_util.h"
#include "eu_translation.h"
#include "segment_symbols.h"
#include "game_init.h"
#include "gfx_dimensions.h"
#include "ingame_menu.h"
@@ -32,13 +33,31 @@ u16 gDialogTextAlpha;
s16 gCutsceneMsgXOffset;
s16 gCutsceneMsgYOffset;
s8 gRedCoinsCollected;
#ifdef WIDE
#if defined(WIDE) && !defined(PUPPYCAM)
u8 textCurrRatio43[] = { TEXT_HUD_CURRENT_RATIO_43 };
u8 textCurrRatio169[] = { TEXT_HUD_CURRENT_RATIO_169 };
u8 textPressL[] = { TEXT_HUD_PRESS_L };
u8 textWideInfo[] = { TEXT_HUD_WIDE_INFO };
#endif
#if MULTILANG
#define seg2_course_name_table course_name_table_eu_en
#define seg2_act_name_table act_name_table_eu_en
#define seg2_dialog_table dialog_table_eu_en
#endif
s16 gInGameLanguage = 0;
s16 gLoadedLanguage = 0;
void *languageTable[][3] =
{
{&seg2_dialog_table, &seg2_course_name_table, &seg2_act_name_table}, //In EU, this is just mirroring English.
#if MULTILANG
{&dialog_table_eu_en, &course_name_table_eu_en, &act_name_table_eu_en},
{&dialog_table_eu_fr, &course_name_table_eu_fr, &act_name_table_eu_fr},
{&dialog_table_eu_de, &course_name_table_eu_de, &act_name_table_eu_de},
#endif
};
extern u8 gLastCompletedCourseNum;
extern u8 gLastCompletedStarNum;
@@ -65,6 +84,7 @@ enum DialogMark { DIALOG_MARK_NONE = 0, DIALOG_MARK_DAKUTEN = 1, DIALOG_MARK_HAN
#define DEFAULT_DIALOG_BOX_ANGLE 90.0f
#define DEFAULT_DIALOG_BOX_SCALE 19.0f
#if defined(VERSION_US) || defined(VERSION_EU)
u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 6, 6, 5, 8, 8, 6, 6, 6, 6, 6, 5, 6, 6,
@@ -72,17 +92,30 @@ u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
7, 5, 5, 5, 6, 5, 5, 5, 5, 5, 7, 7, 5, 5, 4, 4,
8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8, 8, 8, 8, 7, 7, 6, 7, 7, 0, 0, 0, 0, 0, 0, 0,
#ifdef VERSION_EU
6, 6, 6, 0, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 4,
5, 5, 5, 5, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0,
5, 5, 5, 0, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 5, 5, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 5, 6,
0, 4, 4, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#else
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#ifdef VERSION_EU
7, 5, 10, 5, 9, 8, 4, 0, 0, 0, 0, 5, 5, 6, 5, 0,
#else
7, 5, 10, 5, 9, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
0, 0, 5, 7, 7, 6, 6, 8, 0, 8, 10, 6, 4, 10, 0, 0
};
#endif
s8 gDialogBoxState = DIALOG_STATE_OPENING;
f32 gDialogBoxOpenTimer = DEFAULT_DIALOG_BOX_ANGLE;
@@ -217,15 +250,50 @@ static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) {
return out;
}
u8 *alloc_ia4_tex_from_i1(u8 *in, s16 width, s16 height) {
u32 size = (u32) width * (u32) height;
u8 *out;
s32 inPos;
s16 outPos;
u8 bitMask;
outPos = 0;
out = (u8 *) alloc_display_list(size);
if (out == NULL) {
return NULL;
}
for (inPos = 0; inPos < (width * height) / 4; inPos++) {
bitMask = 0x80;
while (bitMask != 0) {
out[outPos] = (in[inPos] & bitMask) ? 0xF0 : 0x00;
bitMask /= 2;
out[outPos] = (in[inPos] & bitMask) ? out[outPos] + 0x0F : out[outPos];
bitMask /= 2;
outPos++;
}
}
return out;
}
void render_generic_char(u8 c) {
void **fontLUT;
void *packedTexture;
void *unpackedTexture;
fontLUT = segmented_to_virtual(main_font_lut);
packedTexture = segmented_to_virtual(fontLUT[c]);
#ifdef VERSION_EU
unpackedTexture = alloc_ia4_tex_from_i1(packedTexture, 8, 8);
gDPPipeSync(gDisplayListHead++);
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, VIRTUAL_TO_PHYSICAL(unpackedTexture));
#else
gDPPipeSync(gDisplayListHead++);
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, VIRTUAL_TO_PHYSICAL(packedTexture));
#endif
gSPDisplayList(gDisplayListHead++, dl_ia_text_tex_settings);
}
@@ -1106,7 +1174,7 @@ void render_dialog_entries(void) {
void **dialogTable;
struct DialogEntry *dialog;
s8 lowerBound = 0;
dialogTable = segmented_to_virtual(seg2_dialog_table);
dialogTable = segmented_to_virtual(languageTable[gInGameLanguage][0]);
dialog = segmented_to_virtual(dialogTable[gDialogID]);
// if the dialog entry is invalid, set the ID to -1.
@@ -1354,7 +1422,7 @@ void print_peach_letter_message(void) {
void **dialogTable;
struct DialogEntry *dialog;
u8 *str;
dialogTable = segmented_to_virtual(seg2_dialog_table);
dialogTable = segmented_to_virtual(languageTable[gInGameLanguage][0]);
dialog = segmented_to_virtual(dialogTable[gDialogID]);
str = segmented_to_virtual(dialog->str);
@@ -1506,7 +1574,6 @@ void render_widescreen_setting(void) {
else {
print_generic_string(10, 20, textCurrRatio169);
print_generic_string(10, 7, textPressL);
print_generic_string(10, 220, textWideInfo);
}
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
if (gPlayer1Controller->buttonPressed & L_TRIG){
@@ -1536,8 +1603,8 @@ void render_pause_my_score_coins(void) {
u8 courseIndex;
u8 starFlags;
courseNameTbl = segmented_to_virtual(seg2_course_name_table);
actNameTbl = segmented_to_virtual(seg2_act_name_table);
courseNameTbl = segmented_to_virtual(languageTable[gInGameLanguage][1]);
actNameTbl = segmented_to_virtual(languageTable[gInGameLanguage][2]);
courseIndex = gCurrCourseNum - 1;
starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1);
@@ -1738,7 +1805,7 @@ void render_pause_castle_course_stars(s16 x, s16 y, s16 fileNum, s16 courseNum)
}
void render_pause_castle_main_strings(s16 x, s16 y) {
void **courseNameTbl = segmented_to_virtual(seg2_course_name_table);
void **courseNameTbl = segmented_to_virtual(languageTable[gInGameLanguage][1]);
u8 textCoin[] = { TEXT_COIN_X };
@@ -1981,8 +2048,8 @@ void render_course_complete_lvl_info_and_hud_str(void) {
u8 strCourseNum[4];
actNameTbl = segmented_to_virtual(seg2_act_name_table);
courseNameTbl = segmented_to_virtual(seg2_course_name_table);
actNameTbl = segmented_to_virtual(languageTable[gInGameLanguage][2]);
courseNameTbl = segmented_to_virtual(languageTable[gInGameLanguage][1]);
if (gLastCompletedCourseNum <= COURSE_STAGES_MAX) {
print_hud_course_complete_coins(118, 103);
@@ -2068,9 +2135,6 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e)
s16 render_course_complete_screen(void) {
s16 index;
#ifdef VERSION_EU
gInGameLanguage = eu_get_language();
#endif
switch (gDialogBoxState) {
case DIALOG_STATE_OPENING:
+1
View File
@@ -37,6 +37,7 @@ enum MenuMode {
extern s8 gDialogCourseActNum;
extern s8 gHudFlash;
extern s16 gInGameLanguage;
struct DialogEntry
{
+29 -11
View File
@@ -20,7 +20,7 @@
#include "obj_behaviors.h"
#include "save_file.h"
#include "debug_course.h"
#ifdef VERSION_EU
#if MULTILANG
#include "memory.h"
#include "eu_translation.h"
#include "segment_symbols.h"
@@ -28,6 +28,7 @@
#include "level_table.h"
#include "course_table.h"
#include "rumble_init.h"
#include "puppycam2.h"
#include "config.h"
@@ -640,6 +641,18 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) {
sWarpDest.areaIdx = destArea;
sWarpDest.nodeId = destWarpNode;
sWarpDest.arg = arg3;
#ifdef PUPPYCAM
s32 i = 0;
if (sWarpDest.type != WARP_TYPE_SAME_AREA)
{
for (i = 0; i < gPuppyVolumeCount; i++)
{
mem_pool_free(gPuppyMemoryPool, sPuppyVolumeStack[i]);
}
gPuppyVolumeCount = 0;
}
#endif
}
// From Surface 0xD3 to 0xFC
@@ -1268,23 +1281,28 @@ s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused) {
return result;
}
s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) {
#ifdef VERSION_EU
s16 var = eu_get_language();
switch (var) {
#if MULTILANG
void load_language_text(void)
{
switch (gInGameLanguage-1)
{
case LANGUAGE_ENGLISH:
load_segment_decompress(0x19, _translation_en_yay0SegmentRomStart,
_translation_en_yay0SegmentRomEnd);
load_segment_decompress(0x19, _translation_en_yay0SegmentRomStart, _translation_en_yay0SegmentRomEnd);
break;
case LANGUAGE_FRENCH:
load_segment_decompress(0x19, _translation_fr_yay0SegmentRomStart,
_translation_fr_yay0SegmentRomEnd);
load_segment_decompress(0x19, _translation_fr_yay0SegmentRomStart, _translation_fr_yay0SegmentRomEnd);
break;
case LANGUAGE_GERMAN:
load_segment_decompress(0x19, _translation_de_yay0SegmentRomStart,
_translation_de_yay0SegmentRomEnd);
load_segment_decompress(0x19, _translation_de_yay0SegmentRomStart, _translation_de_yay0SegmentRomEnd);
break;
}
}
#endif
s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) {
#if MULTILANG
gInGameLanguage = eu_get_language()+1;
load_language_text();
#endif
sWarpDest.type = WARP_TYPE_NOT_WARPING;
sDelayedWarpOp = WARP_OP_NONE;
+1
View File
@@ -70,6 +70,7 @@ extern u16 D_80339ECA;
extern s16 sTransitionTimer;
extern void (*sTransitionUpdate)(s16 *);
extern u8 unused3[4];
extern void load_language_text(void);
struct WarpDest {
u8 type;
+147 -130
View File
@@ -22,11 +22,12 @@
#include "behavior_data.h"
#include "save_file.h"
#include "mario.h"
#include "puppyprint.h"
#ifdef PUPPYCAM
#define OFFSET 30.0f
#define STEPS 1
#define STEPS 4
#define DECELERATION 0.66f
#define DEADZONE 20
#define SCRIPT_MEMORY_POOL 0x1000
@@ -44,25 +45,23 @@ struct MemoryPool *gPuppyMemoryPool;
s32 gPuppyError = 0;
#if defined(VERSION_EU)
static u8 gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_CAMY_FR}, {NC_INVERTX_FR}, {NC_INVERTY_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR},};
static u8 gPCOptionStringsDE[][64] = {{NC_ANALOGUE_DE}, {NC_CAMX_DE}, {NC_CAMY_DE}, {NC_INVERTX_DE}, {NC_INVERTY_DE}, {NC_CAMC_DE}, {NC_SCHEME_DE}, {NC_WIDE_DE},};
static u8 gPCFlagStringsFR[][64] = {{OPTION_DISABLED_FR}, {OPTION_ENABLED_FR}, {OPTION_SCHEME1_FR}, {OPTION_SCHEME2_FR}, {OPTION_SCHEME3_FR}};
static u8 gPCFlagStringsDE[][64] = {{OPTION_DISABLED_DE}, {OPTION_ENABLED_DE}, {OPTION_SCHEME1_DE}, {OPTION_SCHEME2_DE}, {OPTION_SCHEME3_DE}};
static u8 gPCToggleStringsFR[][64] = {{NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}};
static u8 gPCToggleStringsDE[][64] = {{NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}, {NC_ANALOGUE_EN}};
//static u8 gPCToggleStringsFR[][64] = {{NC_BUTTON_FR}, {NC_BUTTON2_FR}, {NC_OPTION_FR}, {NC_HIGHLIGHT_L_FR}, {NC_HIGHLIGHT_R_FR}};
//static u8 gPCToggleStringsDE[][64] = {{NC_BUTTON_DE}, {NC_BUTTON2_DE}, {NC_OPTION_DE}, {NC_HIGHLIGHT_L_DE}, {NC_HIGHLIGHT_R_DE}};
static unsigned char gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_CAMY_FR}, {NC_INVERTX_FR}, {NC_INVERTY_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR}, {OPTION_LANGUAGE_FR}};
static unsigned char gPCOptionStringsDE[][64] = {{NC_ANALOGUE_DE}, {NC_CAMX_DE}, {NC_CAMY_DE}, {NC_INVERTX_DE}, {NC_INVERTY_DE}, {NC_CAMC_DE}, {NC_SCHEME_DE}, {NC_WIDE_DE}, {OPTION_LANGUAGE_DE}};
static unsigned char gPCFlagStringsFR[][64] = {{OPTION_DISABLED_FR}, {OPTION_ENABLED_FR}, {OPTION_SCHEME1_FR}, {OPTION_SCHEME2_FR}, {OPTION_SCHEME3_FR}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
static unsigned char gPCFlagStringsDE[][64] = {{OPTION_DISABLED_DE}, {OPTION_ENABLED_DE}, {OPTION_SCHEME1_DE}, {OPTION_SCHEME2_DE}, {OPTION_SCHEME3_DE}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
static unsigned char gPCToggleStringsFR[][64] = {{NC_BUTTON_FR}, {NC_BUTTON2_FR}, {NC_OPTION_FR}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
static unsigned char gPCToggleStringsDE[][64] = {{NC_BUTTON_DE}, {NC_BUTTON2_DE}, {NC_OPTION_DE}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
#endif
static u8 gPCOptionStringsEN[][64] = {{NC_ANALOGUE_EN}, {NC_CAMX_EN}, {NC_CAMY_EN}, {NC_INVERTX_EN}, {NC_INVERTY_EN}, {NC_CAMC_EN}, {NC_SCHEME_EN}, {NC_WIDE_EN},};
static u8 gPCFlagStringsEN[][64] = {{OPTION_DISABLED_EN}, {OPTION_ENABLED_EN}, {OPTION_SCHEME1_EN}, {OPTION_SCHEME2_EN}, {OPTION_SCHEME3_EN}};
static u8 gPCToggleStringsEN[][64] = {{NC_BUTTON_EN}, {NC_BUTTON2_EN}, {NC_OPTION_EN}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R}};
static unsigned char gPCOptionStringsEN[][64] = {{NC_ANALOGUE_EN}, {NC_CAMX_EN}, {NC_CAMY_EN}, {NC_INVERTX_EN}, {NC_INVERTY_EN}, {NC_CAMC_EN}, {NC_SCHEME_EN}, {NC_WIDE_EN}, {OPTION_LANGUAGE_EN}};
static unsigned char gPCFlagStringsEN[][64] = {{OPTION_DISABLED_EN}, {OPTION_ENABLED_EN}, {OPTION_SCHEME1_EN}, {OPTION_SCHEME2_EN}, {OPTION_SCHEME3_EN}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
static unsigned char gPCToggleStringsEN[][64] = {{NC_BUTTON_EN}, {NC_BUTTON2_EN}, {NC_OPTION_EN}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
#define OPT 32 //Just a temp thing
static u8 (*gPCOptionStringsPtr)[OPT][64] = &gPCOptionStringsEN;
static u8 (*gPCFlagStringsPtr)[OPT][64] = &gPCFlagStringsEN;
static u8 (*gPCToggleStringsPtr)[OPT][64] = &gPCToggleStringsEN;
static unsigned char (*gPCOptionStringsPtr)[OPT][64] = &gPCOptionStringsEN;
static unsigned char (*gPCFlagStringsPtr)[OPT][64] = &gPCFlagStringsEN;
static unsigned char (*gPCToggleStringsPtr)[OPT][64] = &gPCToggleStringsEN;
static const struct gPCOptionStruct
@@ -76,7 +75,12 @@ static const struct gPCOptionStruct
static const struct gPCOptionStruct gPCOptions[]=
{ //If the min and max are 0 and 1, then the value text is used, otherwise it's ignored.
#ifdef WIDE
{/*Option Name*/ 7, /*Option Variable*/ &gWidescreen, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
#endif
#if MULTILANG
{/*Option Name*/ 8, /*Option Variable*/ &gInGameLanguage, /*Option Value Text Start*/ 4, /*Option Minimum*/ 1, /*Option Maximum*/ 3},
#endif
{/*Option Name*/ 0, /*Option Variable*/ &gPuppyCam.options.analogue, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
{/*Option Name*/ 6, /*Option Variable*/ &gPuppyCam.options.inputType, /*Option Value Text Start*/ 2, /*Option Minimum*/ 0, /*Option Maximum*/ 2},
{/*Option Name*/ 1, /*Option Variable*/ &gPuppyCam.options.sensitivityX, /*Option Value Text Start*/ 255, /*Option Minimum*/ 10, /*Option Maximum*/ 500},
@@ -161,10 +165,10 @@ void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ)
gPuppyCam.floorY[1] += displacementY;
}
#if defined(VERSION_EU)
#if MULTILANG
static void newcam_set_language(void)
{
switch (eu_get_language())
switch (gInGameLanguage-1)
{
case 0:
gPCOptionStringsPtr = &gPCOptionStringsEN;
@@ -213,7 +217,7 @@ static void newcam_process_cutscene(void)
#define BLANK 0, 0, 0, ENVIRONMENT, 0, 0, 0, ENVIRONMENT
static void puppycam_display_box(s16 x1, s16 y1, s16 x2, s16 y2, u8 r, u8 g, u8 b, u8 a)
static void puppycam_display_box(s32 x1, s32 y1, s32 x2, s32 y2, u8 r, u8 g, u8 b, u8 a)
{
gDPSetCombineMode(gDisplayListHead++, BLANK, BLANK);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
@@ -249,11 +253,15 @@ void puppycam_change_setting(s8 toggle)
*gPCOptions[gPCOptionSelected].gPCOptionVar += toggle;
//Forgive me father, for I have sinned. I guess if you wanted a selling point for a 21:9 monitor though, "I can view this line in puppycam's code without scrolling!" can be added to it.
*gPCOptions[gPCOptionSelected].gPCOptionVar = CLAMP(*gPCOptions[gPCOptionSelected].gPCOptionVar, gPCOptions[gPCOptionSelected].gPCOptionMin, gPCOptions[gPCOptionSelected].gPCOptionMax);
#if defined(VERSION_EU)
newcam_set_language();
#endif
}
void puppycam_print_text(s16 x, s16 y, u8 str[], u8 col)
void puppycam_print_text(s32 x, s32 y, unsigned char *str, s32 col)
{
u8 textX;
s32 textX;
textX = get_str_x_pos_from_center(x,str,10.0f);
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255);
print_generic_string(textX+1,y-1,str);
@@ -271,14 +279,14 @@ void puppycam_print_text(s16 x, s16 y, u8 str[], u8 col)
//Options menu
void puppycam_display_options()
{
u8 i = 0;
u8 newstring[32];
s16 scroll;
s16 scrollpos;
s16 var = gPCOptions;
s16 vr;
u16 maxvar;
u16 minvar;
s32 i = 0;
unsigned char newstring[32];
s32 scroll;
s32 scrollpos;
s16 var;
s32 vr;
s32 maxvar;
s32 minvar;
f32 newcam_sinpos;
puppycam_display_box(47,83,281,84,0x0,0x0,0x0, 0xFF);
@@ -290,7 +298,7 @@ void puppycam_display_options()
puppycam_display_box(48,84,272,218,0x0,0x0,0x0, 0x50);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
print_hud_lut_string(HUD_LUT_GLOBAL, 64, 40, (*gPCToggleStringsPtr)[2]);
print_hud_lut_string(HUD_LUT_GLOBAL, 112, 40, (*gPCToggleStringsPtr)[2]);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end);
if (gPCOptionCap>4)
@@ -353,14 +361,17 @@ void puppycam_check_pause_buttons()
if (gPCOptionOpen == 0)
{
gPCOptionOpen = 1;
#if defined(VERSION_EU)
#if MULTILANG
newcam_set_language();
eu_set_language(gInGameLanguage-1);
#endif
}
else
{
gPCOptionOpen = 0;
#if MULTILANG
load_language_text();
#endif
puppycam_set_save();
}
}
@@ -430,13 +441,12 @@ void puppycam_check_pause_buttons()
//Just a function that sets a bunch of camera values to 0. It's a function because it's got shared functionality.
void puppycam_reset_values(void)
{
gPuppyCam.posHeight[0] = 0;
gPuppyCam.posHeight[1] = 0;
gPuppyCam.swimPitch = 0;
gPuppyCam.edgePitch = 0;
gPuppyCam.moveZoom = 0;
gPuppyCam.floorY[0] = 0;
gPuppyCam.floorY[1] = 0;
gPuppyCam.terrainPitch = 0;
}
//Set up values. Runs on level load.
@@ -484,8 +494,6 @@ void puppycam_init(void)
void puppycam_input_pitch(void)
{
f32 ivY = ((gPuppyCam.options.invertY*2)-1)*(gPuppyCam.options.sensitivityY/100.f);
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION)
{
//Handles vertical inputs.
@@ -495,7 +503,7 @@ void puppycam_input_pitch(void)
if (gPlayer1Controller->buttonDown & D_CBUTTONS || gPuppyCam.stick2[1] != 0)
gPuppyCam.pitchAcceleration += 50*(gPuppyCam.options.sensitivityY/100.f);
else
gPuppyCam.pitchAcceleration = approach_f32_asymptotic(gPuppyCam.pitchAcceleration, 0, DECELERATION);
gPuppyCam.pitchAcceleration = 0;
gPuppyCam.pitchAcceleration = CLAMP(gPuppyCam.pitchAcceleration, -100, 100);
@@ -523,7 +531,7 @@ void puppycam_input_zoom(void)
void puppycam_input_centre(void)
{
s32 inputDefault = L_TRIG;
if (gPuppyCam.options.inputType == 3)
if (gPuppyCam.options.inputType == 2)
inputDefault = R_TRIG;
//Handles L button centering.
if (gPlayer1Controller->buttonPressed & inputDefault && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION &&
@@ -551,17 +559,17 @@ static void puppycam_input_hold_preset1(f32 ivX)
if ((gPlayer1Controller->buttonDown & L_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0)
{
gPuppyCam.yawAcceleration -= 50*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.yawAcceleration -= 75*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.framesSinceC[0] = 0;
}
else
if ((gPlayer1Controller->buttonDown & R_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0)
{
gPuppyCam.yawAcceleration += 50*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.framesSinceC[1] = 0;
}
else
gPuppyCam.yawAcceleration = approach_f32_asymptotic(gPuppyCam.yawAcceleration, 0, DECELERATION);
gPuppyCam.yawAcceleration = 0;
}
//An alternative control scheme, hold the button down to turn the camera, or press it once to turn it quickly.
@@ -596,15 +604,15 @@ static void puppycam_input_hold_preset2(f32 ivX)
//Handles continuous movement as normal, as long as the button's held.
if (gPlayer1Controller->buttonDown & L_CBUTTONS)
{
gPuppyCam.yawAcceleration -= 10*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.yawAcceleration -= 75*(gPuppyCam.options.sensitivityX/100.f);
}
else
if (gPlayer1Controller->buttonDown & R_CBUTTONS)
{
gPuppyCam.yawAcceleration += 10*(gPuppyCam.options.sensitivityX/100.f);
gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX/100.f);
}
else
gPuppyCam.yawAcceleration = approach_f32_asymptotic(gPuppyCam.yawAcceleration, 0, DECELERATION);
gPuppyCam.yawAcceleration = 0;
}
//Another alternative control scheme. This one aims to mimic the parallel camera scheme down to the last bit from the original game.
@@ -621,7 +629,6 @@ static void puppycam_input_hold_preset3(f32 ivX)
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN)
{
gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_COLLISION;
f32 ivY = ((gPuppyCam.options.invertY*2)-1)*(gPuppyCam.options.sensitivityY/100.f);
//Handles continuous movement as normal, as long as the button's held.
if (ABS(gPlayer1Controller->rawStickX) > DEADZONE)
@@ -629,7 +636,7 @@ static void puppycam_input_hold_preset3(f32 ivX)
gPuppyCam.yawAcceleration -= (gPuppyCam.options.sensitivityX/100.f)*stickMag[0];
}
else
gPuppyCam.yawAcceleration = approach_f32_asymptotic(gPuppyCam.yawAcceleration, 0, DECELERATION);
gPuppyCam.yawAcceleration = 0;
if (ABS(gPlayer1Controller->rawStickY) > DEADZONE)
{
@@ -800,18 +807,20 @@ static void puppycam_view_panning(void)
f32 panFloor, panMulti;
s32 expectedPanX, expectedPanZ;
s32 height = gPuppyCam.targetObj->oPosY;
s32 panEx = (gPuppyCam.zoomTarget >= 1000) * 250; //Removes the basic panning when idling if the zoom level is at the closest.
s32 panEx = (gPuppyCam.zoomTarget >= 1000) * 160; //Removes the basic panning when idling if the zoom level is at the closest.
f32 slideSpeed = 1;
panMulti = CLAMP(gPuppyCam.zoom/(f32)gPuppyCam.zoomPoints[2], 0.f, 1.f);
if (gPuppyCam.options.inputType == 2)
panMulti /= 2;
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT && gMarioState->action != ACT_HOLDING_BOWSER && gMarioState->action != ACT_SLEEPING && gMarioState->action != ACT_START_SLEEPING)
{
if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE)
slideSpeed = 10;
expectedPanX = LENSIN(panEx+(200*(gMarioState->forwardVel/32.f)), gMarioState->faceAngle[1])*panMulti;
expectedPanZ = LENCOS(panEx+(200*(gMarioState->forwardVel/32.f)), gMarioState->faceAngle[1])*panMulti;
expectedPanX = LENSIN(panEx+(200*(gMarioState->forwardVel/320.f)), gMarioState->faceAngle[1])*panMulti;
expectedPanZ = LENCOS(panEx+(200*(gMarioState->forwardVel/320.f)), gMarioState->faceAngle[1])*panMulti;
gPuppyCam.pan[0] = approach_f32_asymptotic(gPuppyCam.pan[0], expectedPanX, 0.02f*slideSpeed);
gPuppyCam.pan[2] = approach_f32_asymptotic(gPuppyCam.pan[2], expectedPanZ, 0.02f*slideSpeed);
@@ -819,21 +828,21 @@ static void puppycam_view_panning(void)
{
panFloor = CLAMP(find_floor_height((s16)(gPuppyCam.targetObj->oPosX+expectedPanX),(s16)(gPuppyCam.targetObj->oPosY + 200),
(s16)(gPuppyCam.targetObj->oPosZ+expectedPanZ)),gPuppyCam.targetObj->oPosY-50,gPuppyCam.targetObj->oPosY+50);
//If the floor is lower than 50 units below Mario, then ignore the Y value and tilt the camera instead.
if (panFloor <= gPuppyCam.targetObj->oPosY-50)
//If the floor is lower than 150 units below Mario, then ignore the Y value and tilt the camera instead.
if (panFloor <= gPuppyCam.targetObj->oPosY-150)
{
panFloor = gPuppyCam.targetObj->oPosY;
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, -0x500, 0x80, 0x80);
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, -0x2000, 0x80, 0x80);
}
else
{
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, 0, 0x80, 0x80);
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, 0, 0x100, 0x100);
}
gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], panFloor-height, 0.25f);
gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], panFloor-height, 0.025f);
}
else
gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], 0, 0.5f);
gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], 0, 0.05f);
}
else
{
@@ -843,37 +852,52 @@ static void puppycam_view_panning(void)
}
}
//Sets the
static void puppycam_view_height_offset(void)
void puppycam_terrain_angle(void)
{
s16 floorTemp;
s16 tempDist = sqrtf((gPuppyCam.pos[0] - gPuppyCam.focus[0]) * (gPuppyCam.pos[0] - gPuppyCam.focus[0]) + (gPuppyCam.pos[1] - gPuppyCam.focus[1]) *
(gPuppyCam.pos[1] - gPuppyCam.focus[1]) + (gPuppyCam.pos[2] - gPuppyCam.focus[2]) * (gPuppyCam.pos[2] - gPuppyCam.focus[2]));
f32 adjustSpeed;
s32 floor2 = find_floor_height(gPuppyCam.pos[0], gPuppyCam.pos[1]+100, gPuppyCam.pos[2]);
s32 ceil = 20000;//find_ceil(gPuppyCam.pos[0], gPuppyCam.pos[1]+100, gPuppyCam.pos[2]);
s32 farFromSurface;
s16 floorPitch;
s32 gotTheOkay = FALSE;
floorTemp = find_floor_height(gPuppyCam.targetObj->oPosX, gPuppyCam.targetObj->oPosY+50, gPuppyCam.targetObj->oPosZ);
if (floorTemp > gPuppyCam.targetObj->oPosY - 50 && !(gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING))
if (gMarioState->action & ACT_FLAG_SWIMMING || !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER))
{
gPuppyCam.posHeight[0] = approach_f32_asymptotic(gPuppyCam.posHeight[0],floorTemp-gPuppyCam.targetFloorHeight,0.05f);
//if (gPuppyCam.posHeight[0]-gPuppyCam.shake[1] - gPuppyCam.floorY[1] < floorTemp)
// gPuppyCam.posHeight[0] = floorTemp-gPuppyCam.shake[1]+gPuppyCam.povHeight - gPuppyCam.floorY[1];
gPuppyCam.intendedTerrainPitch = 0;
adjustSpeed = 0.25f;
farFromSurface = TRUE;
}
else
{
gPuppyCam.posHeight[0] = approach_f32_asymptotic(gPuppyCam.posHeight[0],0,0.1f);
f32 x, z, floorHeight;
adjustSpeed = CLAMP(MAX(gMarioState->forwardVel/480.0f, gPuppyCam.yawAcceleration/100.0f), 0.05f, 1.0f);
x = gPuppyCam.targetObj->oPosX - (10 * sins(gPuppyCam.yaw));
z = gPuppyCam.targetObj->oPosZ - (10 * coss(gPuppyCam.yaw));
floorHeight = find_floor_height(x, gPuppyCam.targetObj->oPosY+100, z);
if (ABS(gMarioState->floorHeight - floorHeight) > 350)
{
gPuppyCam.intendedTerrainPitch = 0;
}
else
{
floorPitch = -atan2s(30.0f, gMarioState->floorHeight - floorHeight);
gPuppyCam.intendedTerrainPitch = approach_f32_asymptotic(gPuppyCam.intendedTerrainPitch, floorPitch, adjustSpeed);
gotTheOkay = TRUE;
}
//Ensures that the camera is below and above floors and ceilings. It ignores this rule for each if the camera's headed upwards anyway.
farFromSurface = ((gPuppyCam.pos[1] > floor2 + 50 || gPuppyCam.intendedTerrainPitch < gPuppyCam.terrainPitch) && (gPuppyCam.pos[1] < ceil - 50 || gPuppyCam.intendedTerrainPitch > gPuppyCam.terrainPitch));
//If the camera is too close to a vertical obstruction, it'll make the intended pitch much further away, making it swivel faster.
if (!farFromSurface && gotTheOkay)
gPuppyCam.intendedTerrainPitch = approach_f32_asymptotic(gPuppyCam.intendedTerrainPitch, floorPitch, adjustSpeed*3);
}
floorTemp = find_floor_height(gPuppyCam.targetObj->oPosX + LENSIN(tempDist,gPuppyCam.yaw), gPuppyCam.targetObj->oPosY+50, gPuppyCam.targetObj->oPosZ + LENCOS(tempDist,gPuppyCam.yaw));
if (floorTemp > gPuppyCam.targetObj->oPosY - 50 && !(gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING) && gPuppyCam.collisionDistance != gPuppyCam.zoomTarget)
{
gPuppyCam.posHeight[1] = approach_f32_asymptotic(gPuppyCam.posHeight[1],floorTemp-gPuppyCam.targetFloorHeight,0.05f);
//if (gPuppyCam.posHeight[1]-gPuppyCam.shake[1] - gPuppyCam.floorY[0] < floorTemp)
// gPuppyCam.posHeight[1] = floorTemp-gPuppyCam.shake[1]+gPuppyCam.povHeight - gPuppyCam.floorY[0];
}
else
{
gPuppyCam.posHeight[1] = approach_f32_asymptotic(gPuppyCam.posHeight[1],0,0.1f);
}
if (farFromSurface)
gPuppyCam.terrainPitch = approach_f32_asymptotic(gPuppyCam.terrainPitch, gPuppyCam.intendedTerrainPitch, adjustSpeed);
}
/// Multiply vector 'dest' by a
@@ -972,6 +996,9 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f
f32 length;
Vec3f chk_hit_pos;
f32 top, bottom;
#ifdef PUPPYPRINT
OSTime first = osGetTime();
#endif
// Get upper and lower bounds of ray
if (dir[1] >= 0.0f)
@@ -1003,39 +1030,49 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f
}
}
}
#ifdef PUPPYPRINT
collisionTime[perfIteration] += osGetTime()-first;
#endif
}
void find_surface_on_ray_cell(s16 cellX, s16 cellZ, Vec3f orig, Vec3f normalized_dir, f32 dir_length, struct Surface **hit_surface, Vec3f hit_pos, f32 *max_length)
void find_surface_on_ray_cell(s16 cellX, s16 cellZ, Vec3f orig, Vec3f normalized_dir, f32 dir_length, struct Surface **hit_surface, Vec3f hit_pos, f32 *max_length, s32 flags)
{
// Skip if OOB
if (cellX >= 0 && cellX <= (NUM_CELLS - 1) && cellZ >= 0 && cellZ <= (NUM_CELLS - 1))
{
// Iterate through each surface in this partition
if (normalized_dir[1] > -0.99999f)
if (normalized_dir[1] > -0.99999f && flags & RAYCAST_FIND_CEIL)
{
find_surface_on_ray_list(gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
if (normalized_dir[1] < 0.99999f)
if (normalized_dir[1] < 0.99999f && flags & RAYCAST_FIND_FLOOR)
{
find_surface_on_ray_list(gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
find_surface_on_ray_list(gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
if (flags & RAYCAST_FIND_WALL)
{
find_surface_on_ray_list(gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
if (flags & RAYCAST_FIND_WATER)
{
find_surface_on_ray_list(gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
}
}
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos)
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags)
{
f32 max_length;
s16 cellZ, cellX, cellPrevX, cellPrevZ;
s32 cellZ, cellX, cellPrevX, cellPrevZ;
f32 fCellZ, fCellX;
f32 dir_length;
Vec3f normalized_dir;
f32 step, dx, dz;
u32 i;
s32 i;
// Set that no surface has been hit
*hit_surface = NULL;
@@ -1050,13 +1087,15 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
// Get our cell coordinate
fCellX = (orig[0] + LEVEL_BOUNDARY_MAX) / CELL_SIZE;
fCellZ = (orig[2] + LEVEL_BOUNDARY_MAX) / CELL_SIZE;
cellX = (s16)fCellX;
cellZ = (s16)fCellZ;
cellX = fCellX;
cellZ = fCellZ;
cellPrevX = cellX;
cellPrevZ = cellZ;
// Don't do DDA if straight down
if (normalized_dir[1] >= 0.99999f || normalized_dir[1] <= -0.99999f)
{
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length);
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
return;
}
@@ -1071,20 +1110,20 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
for (i = 0; i < step && *hit_surface == NULL; i++)
{
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length);
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
// Move cell coordinate
fCellX += dx;
fCellZ += dz;
cellPrevX = cellX;
cellPrevZ = cellZ;
cellX = (s16)fCellX;
cellZ = (s16)fCellZ;
cellX = fCellX;
cellZ = fCellZ;
if ((cellPrevX != cellX) && (cellPrevZ != cellZ))
{
find_surface_on_ray_cell(cellX, cellPrevZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length);
find_surface_on_ray_cell(cellPrevX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length);
find_surface_on_ray_cell(cellX, cellPrevZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
find_surface_on_ray_cell(cellPrevX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
}
}
}
@@ -1093,9 +1132,9 @@ const struct sPuppyAngles puppyAnglesNull =
{
{PUPPY_NULL, PUPPY_NULL, PUPPY_NULL},
{PUPPY_NULL, PUPPY_NULL, PUPPY_NULL},
{PUPPY_NULL},
{PUPPY_NULL},
{PUPPY_NULL},
PUPPY_NULL,
PUPPY_NULL,
PUPPY_NULL,
};
//Checks the bounding box of a puppycam volume. If it's inside, then set the pointer to the current index.
@@ -1155,7 +1194,7 @@ void puppycam_projection_behaviours(void)
f32 turnRate = 1;
//This will only be executed if Mario's the target. If it's not, it'll reset the
if (gPuppyCam.targetObj = gMarioState->marioObj)
if (gPuppyCam.targetObj == gMarioState->marioObj)
{
if (gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) &&
gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2)
@@ -1216,12 +1255,6 @@ void puppycam_projection_behaviours(void)
if (gPuppyCam.pitchTarget < 0x2000)
gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x2000, 0.2f);
/*//Will tilt the camera just a wip thing though, doesn't work too well but will hopefully replace view_height_offset eventually.
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER && gMarioState->floor && gMarioState->action & ACT_FLAG_MOVING)
gPuppyCam.terrainPitch = approach_f32_asymptotic(gPuppyCam.terrainPitch, find_floor_slope(gMarioState, 0), (gMarioState->intendedMag/32)*0.2);
else
gPuppyCam.terrainPitch = approach_f32_asymptotic(gPuppyCam.terrainPitch, 0, 0.2);*/
}
//Applies a light outward zoom to the camera when moving. Sets it back to 0 when not moving.
@@ -1264,15 +1297,7 @@ void puppycam_projection_behaviours(void)
puppycam_view_panning();
//This sets a pseudo tilt offset based on the floor heights in front and behind mario.
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER)
{
puppycam_view_height_offset();
}
else
{
gPuppyCam.posHeight[0] = 0;
gPuppyCam.posHeight[1] = 0;
}
puppycam_terrain_angle();
}
else
{
@@ -1290,16 +1315,9 @@ void puppycam_shake(s16 x, s16 y, s16 z)
//The centrepiece behind the input side of PuppyCam. The C buttons branch off.
static void puppycam_input_core(void)
{
s32 stickMag = 0;
puppycam_analogue_stick();
gPuppyCam.moveFlagAdd = 0;
if (gPuppyCam.options.analogue)
stickMag = gPuppyCam.stick2[1]*1.25f;
else
stickMag = 100;
//Decide which input for left and right C buttons to use based on behaviour type.
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_NORMAL)
puppycam_input_hold();
@@ -1323,7 +1341,7 @@ static void puppycam_projection(void)
gPuppyCam.yaw = gPuppyCam.yawTarget - approach_f32_asymptotic((s16)(gPuppyCam.yawTarget - gPuppyCam.yaw), 0, 0.3335f);
gPuppyCam.pitch = gPuppyCam.pitchTarget - approach_f32_asymptotic((s16)(gPuppyCam.pitchTarget - gPuppyCam.pitch), 0, 0.3335f);
//This adds the pitch effect when underwater, which is capped so it doesn't get out of control. If you're not swimming, swimpitch is 0, so it's normal.
pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10)+gPuppyCam.edgePitch, 800, 0x7800);
pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10)+gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800);
if (gPuppyCam.targetObj)
{
@@ -1348,14 +1366,14 @@ static void puppycam_projection(void)
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT)
gPuppyCam.focus[0] = targetPos3[0] + gPuppyCam.shake[0] + (gPuppyCam.pan[0]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2])*panD;
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT)
gPuppyCam.focus[1] = targetPos3[1] + gPuppyCam.shake[1] + (gPuppyCam.pan[1]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2]) + gPuppyCam.povHeight - gPuppyCam.floorY[0] + gPuppyCam.posHeight[0] + (gPuppyCam.swimPitch/10);
gPuppyCam.focus[1] = targetPos3[1] + gPuppyCam.shake[1] + (gPuppyCam.pan[1]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2]) + gPuppyCam.povHeight - gPuppyCam.floorY[0] + (gPuppyCam.swimPitch/10);
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT)
gPuppyCam.focus[2] = targetPos3[2] + gPuppyCam.shake[2] + (gPuppyCam.pan[2]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2])*panD;
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT)
gPuppyCam.pos[0] = gPuppyCam.targetObj->oPosX + LENSIN(LENSIN(gPuppyCam.targetDist[1],pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0];
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT)
gPuppyCam.pos[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight + LENCOS(gPuppyCam.targetDist[1],pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1] + gPuppyCam.posHeight[1];
gPuppyCam.pos[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight + LENCOS(gPuppyCam.targetDist[1],pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1];
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT)
gPuppyCam.pos[2] = gPuppyCam.targetObj->oPosZ + LENCOS(LENSIN(gPuppyCam.targetDist[1],pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2];
}
@@ -1449,7 +1467,7 @@ static void puppycam_collision(void)
Vec3f camdir[2];
Vec3f hitpos[2];
Vec3f target[2];
s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10), 800, 0x7800);
s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10) + gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800);
s32 dist[2];
if (gPuppyCam.targetObj == NULL)
@@ -1465,21 +1483,20 @@ static void puppycam_collision(void)
target[1][2] = gPuppyCam.targetObj->oPosZ;
camdir[0][0] = LENSIN(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0];
camdir[0][1] = LENCOS(gPuppyCam.zoomTarget,pitchTotal) + gPuppyCam.shake[1];// + gPuppyCam.posHeight[1];
camdir[0][1] = LENCOS(gPuppyCam.zoomTarget,pitchTotal) + gPuppyCam.shake[1];
camdir[0][2] = LENCOS(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2];
camdir[1][0] = camdir[0][0];
camdir[1][1] = camdir[0][1];
camdir[1][2] = camdir[0][2];
find_surface_on_ray(target[0], camdir[0], &surf[0], hitpos[0]);
find_surface_on_ray(target[1], camdir[1], &surf[1], hitpos[1]);
resolve_and_return_wall_collisions(hitpos[0], 0.0f, 50.0f);
resolve_and_return_wall_collisions(hitpos[1], 0.0f, 50.0f);
find_surface_on_ray(target[0], camdir[0], &surf[0], hitpos[0], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
find_surface_on_ray(target[1], camdir[1], &surf[1], hitpos[1], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
resolve_and_return_wall_collisions(hitpos[0], 0.0f, 25.0f);
resolve_and_return_wall_collisions(hitpos[1], 0.0f, 25.0f);
dist[0] = ((target[0][0] - hitpos[0][0]) * (target[0][0] - hitpos[0][0]) + (target[0][1] - hitpos[0][1]) * (target[0][1] - hitpos[0][1]) + (target[0][2] - hitpos[0][2]) * (target[0][2] - hitpos[0][2]));
dist[1] = ((target[1][0] - hitpos[1][0]) * (target[1][0] - hitpos[1][0]) + (target[1][1] - hitpos[1][1]) * (target[1][1] - hitpos[1][1]) + (target[1][2] - hitpos[1][2]) * (target[1][2] - hitpos[1][2]));
gPuppyCam.collisionDistance = gPuppyCam.zoomTarget;
if (surf[0] && surf[1])
+15 -4
View File
@@ -3,6 +3,9 @@
#ifdef PUPPYCAM
//How many times to store the terrain pitch. This stores it over 10 frames to help smooth over changes in curvature.
#define NUM_PITCH_ITERATIONS 10
#define PUPPYCAM_FLAGS_CUTSCENE 0x0001
#define PUPPYCAM_FLAGS_SMOOTH 0x0002
@@ -22,6 +25,13 @@
#define PUPPYCAM_MODE3_ZOOMED_OUT 0x4
#define PUPPYCAM_MODE3_ENTER_FIRST_PERSON 0x8
#define RAYCAST_FIND_FLOOR (0x1)
#define RAYCAST_FIND_WALL (0x2)
#define RAYCAST_FIND_CEIL (0x4)
#define RAYCAST_FIND_WATER (0x8)
#define RAYCAST_FIND_ALL (0xFFFFFFFF)
#include "include/command_macros_base.h"
#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape) \
@@ -56,7 +66,6 @@ struct gPuppyStruct
s16 pitch; //Vertical Direction the game reads as the active value.
s16 pitchTarget; //Vertical Direction that pitch tries to be.
f32 pitchAcceleration; //Vertical Direction that sets pitchTarget.
s16 posHeight[2]; //The first index is the ground offset of pos[1], the second index is the ground offset of focus[1].
s16 zoom; //How far the camera is currently zoomed out
u8 zoomSet; //The current setting of which zoompoint to set the target to.
s16 zoomTarget; //The value that zoom tries to be.
@@ -80,13 +89,15 @@ struct gPuppyStruct
u8 opacity; //A value set by collision distance, to fade Mario out if you're too close.
s8 stick2[2];//The value that's set and read for analogue stick.
u8 stickN[2]; //This is set when the stick is neutral. It's to prevent rapidfire input.
u8 enabled; //A boolean that decides whether to use vanilla camera or puppy camera. Of course, anybody with this enabled is obligated to a death sentence :)
u8 enabled; //A boolean that decides whether to use vanilla camera or puppy camera.
s16 swimPitch; //Pitch adjustment that's applied when swimming. All pitch adjustment is clamped.
s16 edgePitch; //Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped.
s16 moveZoom; //A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed.
u8 mode3Flags; //A flagset for classic mode.
u8 moveFlagAdd; //A bit that multiplies movement rate of axes when moving, to centre them faster.
s16 targetDist[2];
s16 targetDist[2]; //Used with secondary view targets to smooth out the between status.
s16 intendedTerrainPitch; //The pitch that the game wants the game to tilt towards, following the terrain.
s16 terrainPitch; //The pitch the game tilts towards, when following terrain inclines.
u8 cutscene; //A boolean that decides whether a cutscene is active
s32 (*sceneFunc)();
@@ -162,7 +173,7 @@ extern void puppycam_boot(void);
extern void puppycam_init(void);
extern void puppycam_loop(void);
extern void puppycam_shake(s16 x, s16 y, s16 z);
extern void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos);
extern void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
extern f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);
extern void puppycam_default_config(void);
extern s16 LENCOS(s16 length, s16 direction);
+9 -2
View File
@@ -226,7 +226,7 @@ static void save_main_menu_data(void) {
add_save_block_signature(&gSaveBuffer.menuData[0], sizeof(gSaveBuffer.menuData[0]), MENU_DATA_MAGIC);
// Back up data
bcopy(&gSaveBuffer.menuData[0], &gSaveBuffer.menuData[1], sizeof(gSaveBuffer.menuData[1]));
//bcopy(&gSaveBuffer.menuData[0], &gSaveBuffer.menuData[1], sizeof(gSaveBuffer.menuData[1]));
// Write to EEPROM
write_eeprom_data(gSaveBuffer.menuData, sizeof(gSaveBuffer.menuData));
@@ -360,7 +360,7 @@ void save_file_load_all(void) {
// Verify the main menu data and create a backup copy if only one of the slots is valid.
validSlots = verify_save_block_signature(&gSaveBuffer.menuData[0], sizeof(gSaveBuffer.menuData[0]), MENU_DATA_MAGIC);
validSlots |= verify_save_block_signature(&gSaveBuffer.menuData[1], sizeof(gSaveBuffer.menuData[1]),MENU_DATA_MAGIC) << 1;
//validSlots |= verify_save_block_signature(&gSaveBuffer.menuData[1], sizeof(gSaveBuffer.menuData[1]),MENU_DATA_MAGIC) << 1;
switch (validSlots) {
case 0: // Neither copy is correct
wipe_main_menu_data();
@@ -407,6 +407,9 @@ void puppycam_get_save(void)
gPuppyCam.options = gSaveBuffer.menuData[0].saveOptions;
gSaveBuffer.menuData[0].firstBoot = gSaveBuffer.menuData[0].firstBoot;
#ifdef WIDE
gWidescreen = save_file_get_widescreen_mode();
#endif
puppycam_check_save();
}
@@ -417,6 +420,10 @@ void puppycam_set_save(void)
gSaveBuffer.menuData[0].firstBoot = 4;
#ifdef WIDE
save_file_set_widescreen_mode(gWidescreen);
#endif
gMainMenuDataModified = TRUE;
save_main_menu_data();
}