mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-01-20 01:10:13 +00:00
Moved Hash40 and Vector3f structs from l2c.cpp to useful.h
Moved LOAD64 macro from l2c_imports.hpp to useful.h Moved round_to and the various linear interpolation functions from useful.h to useful_visual.h More formatting fixes
This commit is contained in:
parent
0b9857c8d2
commit
216bcbc0c2
10 changed files with 88 additions and 86 deletions
|
@ -1,12 +1,13 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "l2c.hpp"
|
||||
#include "useful.h"
|
||||
#include "useful_visual.h"
|
||||
|
||||
#include "l2c_imports.hpp"
|
||||
#include "acmd_wrapper.hpp"
|
||||
#include "saltysd_helper.hpp"
|
||||
#include "const_value_table.h"
|
||||
#include "taunt_toggles.h"
|
||||
#include "useful.h"
|
||||
|
||||
using namespace lib;
|
||||
using namespace app::lua_bind;
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef L2C_H
|
||||
#define L2C_H
|
||||
|
||||
typedef struct Hash40 {
|
||||
uint64_t hash : 40;
|
||||
} Hash40;
|
||||
|
||||
typedef struct Vector3f {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3f;
|
||||
|
||||
#endif // L2C_H
|
|
@ -5,10 +5,9 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include "l2c.hpp"
|
||||
#include "lua_bind_hash.hpp"
|
||||
#include "useful.h"
|
||||
|
||||
#define LOAD64 *(u64 *)
|
||||
#include "lua_bind_hash.hpp"
|
||||
|
||||
u64 is_training_mode(void) asm("_ZN3app9smashball16is_training_modeEv") LINKABLE;
|
||||
|
||||
|
@ -25,14 +24,14 @@ namespace lib {
|
|||
L2C_string = 8,
|
||||
};
|
||||
|
||||
struct L2CTable_meta {
|
||||
typedef struct L2CTable_meta {
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
uint64_t c;
|
||||
uint64_t d;
|
||||
};
|
||||
} L2CTable_meta;
|
||||
|
||||
struct L2CTable {
|
||||
typedef struct L2CTable {
|
||||
uint32_t refcnt;
|
||||
uint32_t unk;
|
||||
|
||||
|
@ -41,9 +40,9 @@ namespace lib {
|
|||
uint64_t also_end; // L2CValue*
|
||||
struct L2CTable_meta meta;
|
||||
uint64_t unk_ptr;
|
||||
};
|
||||
} L2CTable;
|
||||
|
||||
struct L2CInnerFunctionBase {
|
||||
typedef struct L2CInnerFunctionBase {
|
||||
uint64_t unk;
|
||||
uint32_t refcnt;
|
||||
} L2CInnerFunctionBase;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "saltysd_dynamic.h"
|
||||
|
||||
#include "saltysd_helper.hpp"
|
||||
#include "l2c.hpp"
|
||||
#include "l2c_imports.hpp"
|
||||
#include "acmd_imports.hpp"
|
||||
|
||||
|
|
|
@ -23,21 +23,21 @@ using namespace app::lua_bind;
|
|||
*/
|
||||
|
||||
const float segment_dict[15][5] = {
|
||||
{0,RAYGUN_HEIGHT*2,0,0,0.25}, // a
|
||||
{0,RAYGUN_HEIGHT,RAYGUN_LENGTH,90,0.25}, // b
|
||||
{0,0,RAYGUN_LENGTH,90,0.25}, // c
|
||||
{0,0,0,0,0.25}, // d
|
||||
{0,0,0,90,0.25}, //e
|
||||
{0,RAYGUN_HEIGHT,0,90,0.25}, // f
|
||||
{0,RAYGUN_HEIGHT,0,0,0.25}, // g mid
|
||||
{0,RAYGUN_HEIGHT,RAYGUN_LENGTH/2,90,0.25}, // h
|
||||
{0,RAYGUN_HEIGHT,RAYGUN_LENGTH/2,52,0.2}, // i
|
||||
{0,RAYGUN_HEIGHT,RAYGUN_LENGTH/2,-52,0.2}, //j
|
||||
{0,0,RAYGUN_LENGTH/2,90,0.25}, // k
|
||||
{0,RAYGUN_HEIGHT/2,RAYGUN_LENGTH*3/16,52,0.2}, // l
|
||||
{0,RAYGUN_HEIGHT*3/2,RAYGUN_LENGTH*3/16,-52,0.2}, // m
|
||||
{0,RAYGUN_HEIGHT,0,0,0.15}, // n
|
||||
{0,RAYGUN_HEIGHT,RAYGUN_LENGTH/2,0,0.15}, // o
|
||||
{0, RAYGUN_HEIGHT*2, 0, 0, 0.25}, // a
|
||||
{0, RAYGUN_HEIGHT, RAYGUN_LENGTH, 90, 0.25}, // b
|
||||
{0, 0, RAYGUN_LENGTH, 90, 0.25}, // c
|
||||
{0, 0, 0, 0, 0.25}, // d
|
||||
{0, 0, 0, 90, 0.25}, // e
|
||||
{0, RAYGUN_HEIGHT, 0, 90, 0.25}, // f
|
||||
{0, RAYGUN_HEIGHT, 0, 0, 0.25}, // g mid
|
||||
{0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2, 90, 0.25}, // h
|
||||
{0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2, 52, 0.2}, // i
|
||||
{0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2, -52, 0.2}, // j
|
||||
{0, 0, RAYGUN_LENGTH/2, 90, 0.25}, // k
|
||||
{0, RAYGUN_HEIGHT/2, RAYGUN_LENGTH*3/16, 52, 0.2}, // l
|
||||
{0, RAYGUN_HEIGHT*3/2, RAYGUN_LENGTH*3/16, -52, 0.2}, // m
|
||||
{0, RAYGUN_HEIGHT, 0, 0, 0.15}, // n
|
||||
{0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2, 0, 0.15}, // o
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -107,12 +107,12 @@ const char segment_rev[15] = {
|
|||
};
|
||||
|
||||
void show_segment(u64 battle_object_module_accessor, float z, float y, float x, float zrot, float size) {
|
||||
Hash40 raygunShot = {.hash = 0x11e470b07fLL};
|
||||
Hash40 top = {.hash = 0x031ed91fcaLL};
|
||||
Hash40 raygunShot = { .hash = 0x11e470b07fLL };
|
||||
Hash40 top = { .hash = 0x031ed91fcaLL };
|
||||
|
||||
Vector3f pos = {.x = x, .y = y, .z = z};
|
||||
Vector3f rot = {.x = 0, .y = 90, .z = zrot};
|
||||
Vector3f random = {.x = 0, .y = 0, .z = 0};
|
||||
Vector3f pos = { .x = x, .y = y, .z = z };
|
||||
Vector3f rot = { .x = 0, .y = 90, .z = zrot };
|
||||
Vector3f random = { .x = 0, .y = 0, .z = 0 };
|
||||
|
||||
EffectModule::req_on_joint(battle_object_module_accessor, raygunShot.hash, top.hash,
|
||||
&pos, &rot, size,
|
||||
|
@ -150,9 +150,9 @@ void print_char( u64 module_accessor, char to_print, int line_num, float horiz_o
|
|||
const float* segment;
|
||||
int index = segment_str[i] - 'a';
|
||||
|
||||
if (facing_left == -1)
|
||||
if (facing_left == -1) {
|
||||
index = segment_rev[index] - 'a';
|
||||
|
||||
}
|
||||
segment = segment_dict[index];
|
||||
|
||||
float z = segment[0];
|
||||
|
@ -170,7 +170,7 @@ void print_char( u64 module_accessor, char to_print, int line_num, float horiz_o
|
|||
|
||||
void print_string( u64 module_accessor, const char* print_str) {
|
||||
// Delete any previous strings
|
||||
Hash40 raygunShot = {.hash = 0x11e470b07fLL};
|
||||
Hash40 raygunShot = { .hash = 0x11e470b07fLL };
|
||||
EffectModule::kill_kind(module_accessor, raygunShot.hash, 0, 1);
|
||||
|
||||
int line_num = 0;
|
||||
|
@ -179,8 +179,9 @@ void print_string( u64 module_accessor, const char* print_str) {
|
|||
|
||||
float facing_left = PostureModule::lr(module_accessor);
|
||||
|
||||
if (strlen(print_str) <= 8 && strchr(print_str, '\n') == NULL)
|
||||
if (strlen(print_str) <= 8 && strchr(print_str, '\n') == NULL) {
|
||||
line_num = 1;
|
||||
}
|
||||
horiz_offset = 0;
|
||||
char_num = 0;
|
||||
for (size_t i = 0; i < strlen(print_str); i++) {
|
||||
|
@ -196,10 +197,11 @@ void print_string( u64 module_accessor, const char* print_str) {
|
|||
|
||||
char_num++;
|
||||
// short characters
|
||||
if (curr_char == 'D' || curr_char == '1' )
|
||||
if (curr_char == 'D' || curr_char == '1') {
|
||||
horiz_offset += facing_left * (RAYGUN_LENGTH/2 + 3);
|
||||
else
|
||||
horiz_offset += facing_left * (RAYGUN_LENGTH+3);
|
||||
} else {
|
||||
horiz_offset += facing_left * (RAYGUN_LENGTH + 3);
|
||||
}
|
||||
|
||||
if (char_num > 8) {
|
||||
horiz_offset = 0;
|
||||
|
@ -209,4 +211,4 @@ void print_string( u64 module_accessor, const char* print_str) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif // RAYGUN_PRINTER_H
|
||||
#endif // RAYGUN_PRINTER_H
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "crc32.h"
|
||||
#include "useful.h"
|
||||
|
||||
#include "l2c.hpp"
|
||||
#include "l2c_imports.hpp"
|
||||
#include "acmd_wrapper.hpp"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "l2c.hpp"
|
||||
#include "saltysd_helper.hpp"
|
||||
#include "useful.h"
|
||||
#include "l2c_imports.hpp"
|
||||
#include "saltysd_helper.hpp"
|
||||
#include "acmd_imports.hpp"
|
||||
#include "taunt_toggles.h"
|
||||
#include "raygun_printer.hpp"
|
||||
|
|
|
@ -5,38 +5,22 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "l2c.hpp"
|
||||
|
||||
#define LINKABLE __attribute__ ((weak))
|
||||
|
||||
#define debug_log(...) \
|
||||
{char log_buf[0x200]; snprintf(log_buf, 0x200, __VA_ARGS__); \
|
||||
svcOutputDebugString(log_buf, strlen(log_buf));}
|
||||
#define LOAD64 *(u64 *)
|
||||
|
||||
/**
|
||||
* Rounds a number to the nearest multiple of another number.
|
||||
*/
|
||||
float round_to(float val, float align);
|
||||
#define debug_log(...) {\
|
||||
char log_buf[0x200]; snprintf(log_buf, 0x200, __VA_ARGS__); \
|
||||
svcOutputDebugString(log_buf, strlen(log_buf)); }
|
||||
|
||||
/**
|
||||
* Linearly interpolates between two numbers, without bounds checking.
|
||||
*/
|
||||
float lerp(float min, float max, float t);
|
||||
float unlerp(float min, float max, float val);
|
||||
/**
|
||||
* Linearly interpolates between two numbers, with bounds checking.
|
||||
*/
|
||||
float lerp_bounded(float min, float max, float t);
|
||||
float unlerp_bounded(float min, float max, float val);
|
||||
typedef struct Hash40 {
|
||||
uint64_t hash : 40;
|
||||
} Hash40;
|
||||
|
||||
/**
|
||||
* Linearly nterpolates between two colors, with bounds checking, accounting for gamma.
|
||||
* arguments:
|
||||
* - min_color (Vector3f) -- xyz maps to rgb, components are usually in the range [0.0f, 1.0f] but can go beyond to account for super-bright or super-dark colors
|
||||
* - max_Color (Vector3f) -- same as minColor
|
||||
* - t (float) -- how far to interpolate between the colors
|
||||
* - gamma (float = 2.0f) -- used for color correction, helps avoid ugly dark colors when interpolating b/t bright colors
|
||||
*/
|
||||
Vector3f color_lerp(Vector3f min_color, Vector3f max_color, float t, float gamma = 2.0f);
|
||||
typedef struct Vector3f {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3f;
|
||||
|
||||
#endif // USEFUL_H
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "useful.h"
|
||||
#include "useful_visual.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "l2c.hpp"
|
||||
#include "useful.h"
|
||||
|
||||
float round_to(float val, float align) {
|
||||
return roundf(val / align) * align;
|
31
source/useful_visual.h
Normal file
31
source/useful_visual.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef USEFUL_VISUAL_H
|
||||
#define USEFUL_VISUAL_H
|
||||
|
||||
#include "useful.h"
|
||||
/**
|
||||
* Rounds a number to the nearest multiple of another number.
|
||||
*/
|
||||
float round_to(float val, float align);
|
||||
|
||||
/**
|
||||
* Linearly interpolates between two numbers, without bounds checking.
|
||||
*/
|
||||
float lerp(float min, float max, float t);
|
||||
float unlerp(float min, float max, float val);
|
||||
/**
|
||||
* Linearly interpolates between two numbers, with bounds checking.
|
||||
*/
|
||||
float lerp_bounded(float min, float max, float t);
|
||||
float unlerp_bounded(float min, float max, float val);
|
||||
|
||||
/**
|
||||
* Linearly nterpolates between two colors, with bounds checking, accounting for gamma.
|
||||
* arguments:
|
||||
* - min_color (Vector3f) -- xyz maps to rgb, components are usually in the range [0.0f, 1.0f] but can go beyond to account for super-bright or super-dark colors
|
||||
* - max_Color (Vector3f) -- same as minColor
|
||||
* - t (float) -- how far to interpolate between the colors
|
||||
* - gamma (float = 2.0f) -- used for color correction, helps avoid ugly dark colors when interpolating b/t bright colors
|
||||
*/
|
||||
Vector3f color_lerp(Vector3f min_color, Vector3f max_color, float t, float gamma = 2.0f);
|
||||
|
||||
#endif // USEFUL_VISUAL_H
|
Loading…
Reference in a new issue