move bettercamera settings to config file; cleanup

This commit is contained in:
fgsfds 2020-05-10 21:39:04 +03:00
parent acc0fd59c2
commit a0ba46eaf6
8 changed files with 100 additions and 133 deletions

View File

@ -29,6 +29,7 @@ enum newcam_flagvalues
extern void newcam_display_options(void); extern void newcam_display_options(void);
extern void newcam_check_pause_buttons(void); extern void newcam_check_pause_buttons(void);
extern void newcam_init_settings(void); extern void newcam_init_settings(void);
extern void newcam_save_settings(void);
extern void newcam_render_option_text(void); extern void newcam_render_option_text(void);
extern void newcam_diagnostics(void); extern void newcam_diagnostics(void);

View File

@ -8,6 +8,7 @@
#include "bettercamera.h" #include "bettercamera.h"
#include "include/text_strings.h" #include "include/text_strings.h"
#include "engine/surface_collision.h" #include "engine/surface_collision.h"
#include "pc/configfile.h"
#include <stdio.h> #include <stdio.h>
@ -153,28 +154,28 @@ static f32 newcam_clamp(f32 value, f32 max, f32 min)
return value; return value;
} }
///These are the default settings for Puppycam. You may change them to change how they'll be set for first timers. ///These are the default settings for Puppycam. You may change them to change how they'll be set for first timers.
void newcam_init_settings() void newcam_init_settings(void)
{ {
if (save_check_firsttime()) newcam_sensitivityX = newcam_clamp(configCameraXSens, 10, 250);
{ newcam_sensitivityY = newcam_clamp(configCameraYSens, 10, 250);
save_file_get_setting(); newcam_aggression = newcam_clamp(configCameraAggr, 0, 100);
newcam_clamp(newcam_sensitivityX, 10, 250); newcam_panlevel = newcam_clamp(configCameraPan, 0, 100);
newcam_clamp(newcam_sensitivityY, 10, 250); newcam_invertX = (u8)configCameraInvertX;
newcam_clamp(newcam_aggression, 0, 100); newcam_invertY = (u8)configCameraInvertY;
newcam_clamp(newcam_panlevel, 0, 100); newcam_mouse = (u8)configCameraMouse;
newcam_clamp(newcam_invertX, 0, 1); newcam_analogue = (u8)configEnableCamera;
newcam_clamp(newcam_invertY, 0, 1); }
}
else void newcam_save_settings(void)
{ {
newcam_sensitivityX = 75; configCameraXSens = newcam_sensitivityX;
newcam_sensitivityY = 75; configCameraYSens = newcam_sensitivityY;
newcam_aggression = 0; configCameraAggr = newcam_aggression;
newcam_panlevel = 75; configCameraPan = newcam_panlevel;
newcam_invertX = 0; configCameraInvertX = newcam_invertX != 0;
newcam_invertY = 0; configCameraInvertY = newcam_invertY != 0;
save_set_firsttime(); configEnableCamera = newcam_analogue != 0;
} configCameraMouse = newcam_mouse != 0;
} }
/** Mathematic calculations. This stuffs so basic even *I* understand it lol /** Mathematic calculations. This stuffs so basic even *I* understand it lol
@ -423,7 +424,7 @@ static void newcam_zoom_button(void)
if (newcam_centering && newcam_modeflags & NC_FLAG_XTURN) if (newcam_centering && newcam_modeflags & NC_FLAG_XTURN)
{ {
newcam_yaw = approach_s16_symmetric(newcam_yaw,newcam_yaw_target,0x800); newcam_yaw = approach_s16_symmetric(newcam_yaw,newcam_yaw_target,0x800);
if (newcam_yaw = newcam_yaw_target) if (newcam_yaw == newcam_yaw_target)
newcam_centering = 0; newcam_centering = 0;
} }
else else
@ -505,7 +506,7 @@ static void newcam_collision(void)
find_surface_on_ray(newcam_pos_target, camdir, &surf, &hitpos); find_surface_on_ray(newcam_pos_target, camdir, &surf, hitpos);
if (surf) if (surf)
{ {
@ -834,7 +835,7 @@ void newcam_check_pause_buttons()
else else
{ {
newcam_option_open = 0; newcam_option_open = 0;
save_file_set_setting(); newcam_save_settings();
} }
} }

View File

@ -599,6 +599,11 @@ void init_controllers(void) {
gControllers[cont++].controllerData = &gControllerPads[port]; gControllers[cont++].controllerData = &gControllerPads[port];
} }
} }
#ifdef BETTERCAMERA
// load bettercam settings from the config file
newcam_init_settings();
#endif
} }
void setup_game_memory(void) { void setup_game_memory(void) {

View File

@ -11,9 +11,6 @@
#include "level_table.h" #include "level_table.h"
#include "course_table.h" #include "course_table.h"
#include "thread6.h" #include "thread6.h"
#ifdef BETTERCAMERA
#include "bettercamera.h"
#endif
#define MENU_DATA_MAGIC 0x4849 #define MENU_DATA_MAGIC 0x4849
#define SAVE_FILE_MAGIC 0x4441 #define SAVE_FILE_MAGIC 0x4441
@ -568,50 +565,6 @@ u16 save_file_get_sound_mode(void) {
return gSaveBuffer.menuData[0].soundMode; return gSaveBuffer.menuData[0].soundMode;
} }
#ifdef BETTERCAMERA
void save_file_set_setting(void) {
gSaveBuffer.menuData[0].camx = newcam_sensitivityX;
gSaveBuffer.menuData[0].camy = newcam_sensitivityY;
gSaveBuffer.menuData[0].invertx = newcam_invertX;
gSaveBuffer.menuData[0].inverty = newcam_invertY;
gSaveBuffer.menuData[0].camc = newcam_aggression;
gSaveBuffer.menuData[0].camp = newcam_panlevel;
gSaveBuffer.menuData[0].analogue = newcam_analogue;
gSaveBuffer.menuData[0].firsttime = 1;
gMainMenuDataModified = TRUE;
save_main_menu_data();
}
void save_file_get_setting(void) {
newcam_sensitivityX = gSaveBuffer.menuData[0].camx;
newcam_sensitivityY = gSaveBuffer.menuData[0].camy;
newcam_invertX = gSaveBuffer.menuData[0].invertx;
newcam_invertY = gSaveBuffer.menuData[0].inverty;
newcam_aggression = gSaveBuffer.menuData[0].camc;
newcam_panlevel = gSaveBuffer.menuData[0].camp;
newcam_analogue = gSaveBuffer.menuData[0].analogue;
}
u8 save_check_firsttime(void)
{
return gSaveBuffer.menuData[0].firsttime;
}
void save_set_firsttime(void)
{
gSaveBuffer.menuData[0].firsttime = 1;
gMainMenuDataModified = TRUE;
save_main_menu_data();
}
#endif
void save_file_move_cap_to_default_location(void) { void save_file_move_cap_to_default_location(void) {
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND) { if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND) {
switch (gSaveBuffer.files[gCurrSaveFileNum - 1][0].capLevel) { switch (gSaveBuffer.files[gCurrSaveFileNum - 1][0].capLevel) {

View File

@ -6,11 +6,7 @@
#include "course_table.h" #include "course_table.h"
#ifndef BETTERCAMERA
#define EEPROM_SIZE 0x200 #define EEPROM_SIZE 0x200
#else
#define EEPROM_SIZE 0x800
#endif
#define NUM_SAVE_FILES 4 #define NUM_SAVE_FILES 4
struct SaveBlockSignature struct SaveBlockSignature
@ -54,16 +50,7 @@ struct MainMenuSaveData
// on the high score screen. // on the high score screen.
u32 coinScoreAges[NUM_SAVE_FILES]; u32 coinScoreAges[NUM_SAVE_FILES];
u16 soundMode; u16 soundMode;
#ifdef BETTERCAMERA
u8 camx;
u8 camy;
u8 analogue;
u8 invertx;
u8 inverty;
u8 camc;
u8 camp;
u8 firsttime;
#endif
#ifdef VERSION_EU #ifdef VERSION_EU
u16 language; u16 language;
#define SUBTRAHEND 8 #define SUBTRAHEND 8
@ -71,11 +58,8 @@ struct MainMenuSaveData
#define SUBTRAHEND 6 #define SUBTRAHEND 6
#endif #endif
// Pad to match the EEPROM size of 0x200 (10 bytes on JP/US, 8 bytes on EU) // Pad to match the EEPROM size of 0x200 (10 bytes on JP/US, 8 bytes on EU)
#ifndef BETTERCAMERA
u8 filler[EEPROM_SIZE / 2 - SUBTRAHEND - NUM_SAVE_FILES * (4 + sizeof(struct SaveFile))]; u8 filler[EEPROM_SIZE / 2 - SUBTRAHEND - NUM_SAVE_FILES * (4 + sizeof(struct SaveFile))];
#endif
struct SaveBlockSignature signature; struct SaveBlockSignature signature;
}; };
@ -86,9 +70,6 @@ struct SaveBuffer
struct SaveFile files[NUM_SAVE_FILES][2]; struct SaveFile files[NUM_SAVE_FILES][2];
// The main menu data has two copies. If one is bad, the other is used as a backup. // The main menu data has two copies. If one is bad, the other is used as a backup.
struct MainMenuSaveData menuData[2]; struct MainMenuSaveData menuData[2];
#ifdef BETTERCAMERA
u8 filler[1535]; //!I still haven't done an algorithm for this yet lol
#endif
}; };
struct WarpNode; struct WarpNode;
@ -163,12 +144,6 @@ s32 save_file_get_cap_pos(Vec3s capPos);
void save_file_set_sound_mode(u16 mode); void save_file_set_sound_mode(u16 mode);
u16 save_file_get_sound_mode(void); u16 save_file_get_sound_mode(void);
void save_file_move_cap_to_default_location(void); void save_file_move_cap_to_default_location(void);
#ifdef BETTERCAMERA
void save_set_firsttime(void);
u8 save_check_firsttime(void);
void save_file_get_setting(void);
void save_file_set_setting(void);
#endif
void disable_warp_checkpoint(void); void disable_warp_checkpoint(void);
void check_if_should_set_warp_checkpoint(struct WarpNode *a); void check_if_should_set_warp_checkpoint(struct WarpNode *a);

View File

@ -58,7 +58,17 @@ unsigned int configMouseB = 1;
unsigned int configMouseL = 4; unsigned int configMouseL = 4;
unsigned int configMouseR = 5; unsigned int configMouseR = 5;
unsigned int configMouseZ = 2; unsigned int configMouseZ = 2;
#ifdef BETTERCAMERA
// BetterCamera settings
unsigned int configCameraXSens = 50;
unsigned int configCameraYSens = 50;
unsigned int configCameraAggr = 0;
unsigned int configCameraPan = 0;
bool configCameraInvertX = false;
bool configCameraInvertY = false;
bool configEnableCamera = false;
bool configCameraMouse = false;
#endif
static const struct ConfigOption options[] = { static const struct ConfigOption options[] = {
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen}, {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen},
@ -87,6 +97,16 @@ static const struct ConfigOption options[] = {
{.name = "mouse_l", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseL}, {.name = "mouse_l", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseL},
{.name = "mouse_r", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseR}, {.name = "mouse_r", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseR},
{.name = "mouse_z", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseZ}, {.name = "mouse_z", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseZ},
#ifdef BETTERCAMERA
{.name = "bettercam_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCamera},
{.name = "bettercam_mouse_look", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraMouse},
{.name = "bettercam_invertx", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraInvertX},
{.name = "bettercam_inverty", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraInvertY},
{.name = "bettercam_xsens", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraXSens},
{.name = "bettercam_ysens", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraYSens},
{.name = "bettercam_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraAggr},
{.name = "bettercam_pan_level", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraPan},
#endif
}; };
// Reads an entire line from a file (excluding the newline character) and returns an allocated string // Reads an entire line from a file (excluding the newline character) and returns an allocated string

View File

@ -1,6 +1,10 @@
#ifndef CONFIGFILE_H #ifndef CONFIGFILE_H
#define CONFIGFILE_H #define CONFIGFILE_H
#include <stdbool.h>
#define CONFIG_FILE "sm64config.txt"
extern bool configFullscreen; extern bool configFullscreen;
extern unsigned int configKeyA; extern unsigned int configKeyA;
extern unsigned int configKeyB; extern unsigned int configKeyB;
@ -28,6 +32,16 @@ extern unsigned int configMouseStart;
extern unsigned int configMouseL; extern unsigned int configMouseL;
extern unsigned int configMouseR; extern unsigned int configMouseR;
extern unsigned int configMouseZ; extern unsigned int configMouseZ;
#ifdef BETTERCAMERA
extern unsigned int configCameraXSens;
extern unsigned int configCameraYSens;
extern unsigned int configCameraAggr;
extern unsigned int configCameraPan;
extern bool configCameraInvertX;
extern bool configCameraInvertY;
extern bool configEnableCamera;
extern bool configCameraMouse;
#endif
void configfile_load(const char *filename); void configfile_load(const char *filename);
void configfile_save(const char *filename); void configfile_save(const char *filename);

View File

@ -20,8 +20,6 @@
#include "configfile.h" #include "configfile.h"
#define CONFIG_FILE "sm64config.txt"
OSMesg D_80339BEC; OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue; OSMesgQueue gSIEventMesgQueue;