Merge pull request #51 from fgsfdsfgs/patch-2

Move bettercamera settings out of EEPROM and into the config file (again)
This commit is contained in:
IvanDSM 2020-05-10 16:41:04 -03:00 committed by GitHub
commit a73accc906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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_check_pause_buttons(void);
extern void newcam_init_settings(void);
extern void newcam_save_settings(void);
extern void newcam_render_option_text(void);
extern void newcam_diagnostics(void);

View File

@ -8,6 +8,7 @@
#include "bettercamera.h"
#include "include/text_strings.h"
#include "engine/surface_collision.h"
#include "pc/configfile.h"
#include <stdio.h>
@ -153,28 +154,28 @@ static f32 newcam_clamp(f32 value, f32 max, f32 min)
return value;
}
///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())
{
save_file_get_setting();
newcam_clamp(newcam_sensitivityX, 10, 250);
newcam_clamp(newcam_sensitivityY, 10, 250);
newcam_clamp(newcam_aggression, 0, 100);
newcam_clamp(newcam_panlevel, 0, 100);
newcam_clamp(newcam_invertX, 0, 1);
newcam_clamp(newcam_invertY, 0, 1);
}
else
{
newcam_sensitivityX = 75;
newcam_sensitivityY = 75;
newcam_aggression = 0;
newcam_panlevel = 75;
newcam_invertX = 0;
newcam_invertY = 0;
save_set_firsttime();
}
newcam_sensitivityX = newcam_clamp(configCameraXSens, 10, 250);
newcam_sensitivityY = newcam_clamp(configCameraYSens, 10, 250);
newcam_aggression = newcam_clamp(configCameraAggr, 0, 100);
newcam_panlevel = newcam_clamp(configCameraPan, 0, 100);
newcam_invertX = (u8)configCameraInvertX;
newcam_invertY = (u8)configCameraInvertY;
newcam_mouse = (u8)configCameraMouse;
newcam_analogue = (u8)configEnableCamera;
}
void newcam_save_settings(void)
{
configCameraXSens = newcam_sensitivityX;
configCameraYSens = newcam_sensitivityY;
configCameraAggr = newcam_aggression;
configCameraPan = newcam_panlevel;
configCameraInvertX = newcam_invertX != 0;
configCameraInvertY = newcam_invertY != 0;
configEnableCamera = newcam_analogue != 0;
configCameraMouse = newcam_mouse != 0;
}
/** 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)
{
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;
}
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)
{
@ -834,7 +835,7 @@ void newcam_check_pause_buttons()
else
{
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];
}
}
#ifdef BETTERCAMERA
// load bettercam settings from the config file
newcam_init_settings();
#endif
}
void setup_game_memory(void) {

View File

@ -11,9 +11,6 @@
#include "level_table.h"
#include "course_table.h"
#include "thread6.h"
#ifdef BETTERCAMERA
#include "bettercamera.h"
#endif
#define MENU_DATA_MAGIC 0x4849
#define SAVE_FILE_MAGIC 0x4441
@ -568,50 +565,6 @@ u16 save_file_get_sound_mode(void) {
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) {
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND) {
switch (gSaveBuffer.files[gCurrSaveFileNum - 1][0].capLevel) {

View File

@ -6,11 +6,7 @@
#include "course_table.h"
#ifndef BETTERCAMERA
#define EEPROM_SIZE 0x200
#else
#define EEPROM_SIZE 0x800
#endif
#define NUM_SAVE_FILES 4
struct SaveBlockSignature
@ -54,16 +50,7 @@ struct MainMenuSaveData
// on the high score screen.
u32 coinScoreAges[NUM_SAVE_FILES];
u16 soundMode;
#ifdef BETTERCAMERA
u8 camx;
u8 camy;
u8 analogue;
u8 invertx;
u8 inverty;
u8 camc;
u8 camp;
u8 firsttime;
#endif
#ifdef VERSION_EU
u16 language;
#define SUBTRAHEND 8
@ -71,11 +58,8 @@ struct MainMenuSaveData
#define SUBTRAHEND 6
#endif
// 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))];
#endif
struct SaveBlockSignature signature;
};
@ -86,9 +70,6 @@ struct SaveBuffer
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.
struct MainMenuSaveData menuData[2];
#ifdef BETTERCAMERA
u8 filler[1535]; //!I still haven't done an algorithm for this yet lol
#endif
};
struct WarpNode;
@ -163,12 +144,6 @@ s32 save_file_get_cap_pos(Vec3s capPos);
void save_file_set_sound_mode(u16 mode);
u16 save_file_get_sound_mode(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 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 configMouseR = 5;
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[] = {
{.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_r", .type = CONFIG_TYPE_UINT, .uintValue = &configMouseR},
{.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

View File

@ -1,6 +1,10 @@
#ifndef CONFIGFILE_H
#define CONFIGFILE_H
#include <stdbool.h>
#define CONFIG_FILE "sm64config.txt"
extern bool configFullscreen;
extern unsigned int configKeyA;
extern unsigned int configKeyB;
@ -28,6 +32,16 @@ extern unsigned int configMouseStart;
extern unsigned int configMouseL;
extern unsigned int configMouseR;
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_save(const char *filename);

View File

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