Skip to content

Commit

Permalink
RC3
Browse files Browse the repository at this point in the history
  • Loading branch information
mon committed Oct 28, 2024
1 parent 25c4b49 commit db6761b
Show file tree
Hide file tree
Showing 9 changed files with 553 additions and 250 deletions.
309 changes: 244 additions & 65 deletions festo/ultimate/categories.cc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions festo/ultimate/categories.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

extern const std::vector<category_hierarchy_t> extra_category_hierarchy;
extern const std::vector<category_listing_t> extra_category_layout;
extern const std::vector<hierarchy_texture_t> extra_hierarchy_textures;

extern const std::vector<grouping_textures_t> extra_group_textures;
uint32_t __fastcall category_group_fn_alphabet(enum group_type group_type, const music_info_for_grouping_t *info);
Expand Down
274 changes: 170 additions & 104 deletions festo/ultimate/category_hooks.cc

Large diffs are not rendered by default.

39 changes: 25 additions & 14 deletions festo/ultimate/category_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void init() {
*/

// selecting a category
enum folder_sort_id: uint32_t {
enum folder_sort_id : uint32_t {
SORT_NULL = 0, // empty tile with nothing to click on
SORT_ROOT = 1,
SORT_ALL = 2,
Expand Down Expand Up @@ -96,12 +96,12 @@ enum folder_sort_id: uint32_t {
SORT_FULLCOMBO_CHALLENGE = 38,
SORT_CATEGORY_PERFORMANCE = 39,
SORT_UNPLAYED = 40,
SORT_IS_FULL_COMBO1 = 41,
SORT_IS_FULL_COMBO2 = 42,
SORT_IS_NO_GRAY1 = 43,
SORT_IS_NO_GRAY2 = 44,
SORT_IS_ALL_YELLOW1 = 45,
SORT_IS_ALL_YELLOW2 = 46,
SORT_NOT_FULL_COMBO = 41,
SORT_HAS_FULL_COMBO = 42,
SORT_SOME_GRAY = 43,
SORT_NO_GRAY = 44,
SORT_NOT_ALL_YELLOW = 45,
SORT_HAS_ALL_YELLOW = 46,
SORT_RANK_E = 47,
SORT_RANK_D = 48,
SORT_RANK_C = 49,
Expand All @@ -112,7 +112,7 @@ enum folder_sort_id: uint32_t {
SORT_RANK_SSS = 54,
SORT_RANK_EXC = 55,
SORT_MYBEST = 56,
SORT_CATEGORY_TOURNAMENT_PARTICIPATION = 57,
SORT_CATEGORY_TOURNAMENT = 57,
SORT_TOURNAMENT_1 = 58,
SORT_TOURNAMENT_2 = 59,
SORT_TOURNAMENT_3 = 60,
Expand Down Expand Up @@ -167,6 +167,8 @@ enum folder_sort_id: uint32_t {
SORT_SHOP = 114,
SORT_PJ_MATCH = 115,
SORT_TUNE_RUN = 118,
SORT_TUNE_RUN_1 = 119,
SORT_TUNE_RUN_2 = 120,
SORT_TARGET_MUSIC = 121,
SORT_THIS_WEEK_RECOMMENDED = 122,

Expand Down Expand Up @@ -255,7 +257,7 @@ enum song_group_id {
GROUP_DEFAULT_MAX_ID,
};

typedef bool (__cdecl *music_sort_function)(unsigned music_id, int diff, uint8_t level);
typedef bool(__cdecl *music_sort_function)(unsigned music_id, int diff, uint8_t level);

typedef struct {
// not enum folder_sort_id as the extra casts for custom values suck
Expand Down Expand Up @@ -290,17 +292,24 @@ typedef struct {
uint8_t level;
uint8_t level_detail;
uint8_t _unk0;
const char* _unk1;
const char* LabDBSeqName;
const char *_unk1;
const char *LabDBSeqName;
int _unk2;
int LabDBNo;
uint8_t _unk3;
bool has_rival; // unsure
uint8_t _unk4;
uint8_t _unk5;
void* sequence_record_set;
void *sequence_record_set;
} music_info_for_grouping_t;

typedef struct {
uint32_t id; // folder_sort_id
uint32_t parent; // folder_sort_id
int flags; // 0: root, 1: branch, 2: leaf
const char *texture_basename;
} hierarchy_texture_t;

// must be called before category_hooks_init
void category_hooks_add_category_definitions(std::vector<category_hierarchy_t> categories);
void category_hooks_add_category_layouts(std::vector<category_listing_t> listings);
Expand All @@ -309,7 +318,8 @@ void category_hooks_add_group_textures(std::vector<grouping_textures_t> groups);

// no custom group_type for now, so use the actual enum. Return GROUP_INVALID if
// you want a later hook or the default game function to handle it.
typedef uint32_t (__fastcall *category_group_hook_fn_t)(enum group_type group_type, const music_info_for_grouping_t *info);
typedef uint32_t(__fastcall *category_group_hook_fn_t)(
enum group_type group_type, const music_info_for_grouping_t *info);
void category_hooks_add_grouping_hook_fn(category_group_hook_fn_t hook);

void category_hooks_init(HANDLE process, const MODULEINFO &jubeat_info);
Expand All @@ -319,4 +329,5 @@ void category_hooks_init(HANDLE process, const MODULEINFO &jubeat_info);
category_listing_t *category_hooks_get_listing(uint32_t id);

// used by the extended display grouper thing
extern int (__cdecl *name_sorter)(const music_info_for_grouping_t *a, const music_info_for_grouping_t *b);
extern int(__cdecl *name_sorter)(
const music_info_for_grouping_t *a, const music_info_for_grouping_t *b);
46 changes: 25 additions & 21 deletions festo/ultimate/category_textures_default.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// clang-format off

// it is *significantly* easier to just grab this from the game than to hook
// mid-way through the function to modify the list
{ SORT_ROOT, ENV_LANG_J, "smm_t0903_ja.png", },
Expand Down Expand Up @@ -120,24 +122,24 @@
{ SORT_UNPLAYED, ENV_LANG_J, "smm_t0710_ja.png", },
{ SORT_UNPLAYED, ENV_LANG_A, "smm_t0710_ja.png", },
{ SORT_UNPLAYED, ENV_LANG_K, "smm_t0710_ko.png", },
{ SORT_IS_FULL_COMBO1, ENV_LANG_J, "smm_t0720_ja.png", },
{ SORT_IS_FULL_COMBO1, ENV_LANG_A, "smm_t0720_ja.png", },
{ SORT_IS_FULL_COMBO1, ENV_LANG_K, "smm_t0720_ko.png", },
{ SORT_IS_FULL_COMBO2, ENV_LANG_J, "smm_t0721_ja.png", },
{ SORT_IS_FULL_COMBO2, ENV_LANG_A, "smm_t0721_ja.png", },
{ SORT_IS_FULL_COMBO2, ENV_LANG_K, "smm_t0721_ko.png", },
{ SORT_IS_NO_GRAY1, ENV_LANG_J, "smm_t0730_ja.png", },
{ SORT_IS_NO_GRAY1, ENV_LANG_A, "smm_t0730_ja.png", },
{ SORT_IS_NO_GRAY1, ENV_LANG_K, "smm_t0730_ko.png", },
{ SORT_IS_NO_GRAY2, ENV_LANG_J, "smm_t0731_ja.png", },
{ SORT_IS_NO_GRAY2, ENV_LANG_A, "smm_t0731_ja.png", },
{ SORT_IS_NO_GRAY2, ENV_LANG_K, "smm_t0731_ko.png", },
{ SORT_IS_ALL_YELLOW1, ENV_LANG_J, "smm_t0732_ja.png", },
{ SORT_IS_ALL_YELLOW1, ENV_LANG_A, "smm_t0732_ja.png", },
{ SORT_IS_ALL_YELLOW1, ENV_LANG_K, "smm_t0732_ko.png", },
{ SORT_IS_ALL_YELLOW2, ENV_LANG_J, "smm_t0733_ja.png", },
{ SORT_IS_ALL_YELLOW2, ENV_LANG_A, "smm_t0733_ja.png", },
{ SORT_IS_ALL_YELLOW2, ENV_LANG_K, "smm_t0733_ko.png", },
{ SORT_NOT_FULL_COMBO, ENV_LANG_J, "smm_t0720_ja.png", },
{ SORT_NOT_FULL_COMBO, ENV_LANG_A, "smm_t0720_ja.png", },
{ SORT_NOT_FULL_COMBO, ENV_LANG_K, "smm_t0720_ko.png", },
{ SORT_HAS_FULL_COMBO, ENV_LANG_J, "smm_t0721_ja.png", },
{ SORT_HAS_FULL_COMBO, ENV_LANG_A, "smm_t0721_ja.png", },
{ SORT_HAS_FULL_COMBO, ENV_LANG_K, "smm_t0721_ko.png", },
{ SORT_SOME_GRAY, ENV_LANG_J, "smm_t0730_ja.png", },
{ SORT_SOME_GRAY, ENV_LANG_A, "smm_t0730_ja.png", },
{ SORT_SOME_GRAY, ENV_LANG_K, "smm_t0730_ko.png", },
{ SORT_NO_GRAY, ENV_LANG_J, "smm_t0731_ja.png", },
{ SORT_NO_GRAY, ENV_LANG_A, "smm_t0731_ja.png", },
{ SORT_NO_GRAY, ENV_LANG_K, "smm_t0731_ko.png", },
{ SORT_NOT_ALL_YELLOW, ENV_LANG_J, "smm_t0732_ja.png", },
{ SORT_NOT_ALL_YELLOW, ENV_LANG_A, "smm_t0732_ja.png", },
{ SORT_NOT_ALL_YELLOW, ENV_LANG_K, "smm_t0732_ko.png", },
{ SORT_HAS_ALL_YELLOW, ENV_LANG_J, "smm_t0733_ja.png", },
{ SORT_HAS_ALL_YELLOW, ENV_LANG_A, "smm_t0733_ja.png", },
{ SORT_HAS_ALL_YELLOW, ENV_LANG_K, "smm_t0733_ko.png", },
{ SORT_RANK_E, ENV_LANG_J, "smm_t0740_ja.png", },
{ SORT_RANK_E, ENV_LANG_A, "smm_t0740_ja.png", },
{ SORT_RANK_E, ENV_LANG_K, "smm_t0740_ko.png", },
Expand Down Expand Up @@ -168,9 +170,9 @@
{ SORT_MYBEST, ENV_LANG_J, "smm_t0113_ja.png", },
{ SORT_MYBEST, ENV_LANG_A, "smm_t0113_ja.png", },
{ SORT_MYBEST, ENV_LANG_K, "smm_t0113_ko.png", },
{ SORT_CATEGORY_TOURNAMENT_PARTICIPATION, ENV_LANG_J, "smm_t0800_ja.png", },
{ SORT_CATEGORY_TOURNAMENT_PARTICIPATION, ENV_LANG_A, "smm_t0800_ja.png", },
{ SORT_CATEGORY_TOURNAMENT_PARTICIPATION, ENV_LANG_K, "smm_t0800_ko.png", },
{ SORT_CATEGORY_TOURNAMENT, ENV_LANG_J, "smm_t0800_ja.png", },
{ SORT_CATEGORY_TOURNAMENT, ENV_LANG_A, "smm_t0800_ja.png", },
{ SORT_CATEGORY_TOURNAMENT, ENV_LANG_K, "smm_t0800_ko.png", },
{ SORT_TOURNAMENT_1, ENV_LANG_J, "smm_t0810_ja.png", },
{ SORT_TOURNAMENT_1, ENV_LANG_A, "smm_t0810_ja.png", },
{ SORT_TOURNAMENT_1, ENV_LANG_K, "smm_t0810_ko.png", },
Expand Down Expand Up @@ -339,3 +341,5 @@
{ SORT_THIS_WEEK_RECOMMENDED, ENV_LANG_J, "smm_t0105_ja.png", },
{ SORT_THIS_WEEK_RECOMMENDED, ENV_LANG_A, "smm_t0105_ja.png", },
{ SORT_THIS_WEEK_RECOMMENDED, ENV_LANG_K, "smm_t0105_ko.png", },

// clang-format on
85 changes: 43 additions & 42 deletions festo/ultimate/music_db.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define LOG_MODULE "ultimate::music_db"

#include <bit>
#include <cstdint>
#include <cstdlib>

Expand Down Expand Up @@ -1005,12 +1006,12 @@ music_db_filtered_list(const char *func, int limit, int *results, music_filter_f
int found = 0;

// special handler for the "one for every region" やんややんやNight
const char* area_code = config_game_get_area_code();
const char *area_code = config_game_get_area_code();
int allowed_yanyan = 80000300; // "Japan" instead of a specific area
// avoid misconfigured/other region
if(area_code && strncmp(area_code, "JP-", 3) == 0) {
if (area_code && strncmp(area_code, "JP-", 3) == 0) {
int code = atoi(&area_code[3]); // returns 0 on failure, which is convenient
if(code >= 0 && code <= 47) {
if (code >= 0 && code <= 47) {
allowed_yanyan = 80000300 + code;
}
}
Expand All @@ -1022,7 +1023,9 @@ music_db_filtered_list(const char *func, int limit, int *results, music_filter_f
continue;
}

if(song->music_id >= 80000300 && song->music_id <= 80000347 && song->music_id != allowed_yanyan) {
if (song->music_id >= 80000300 && song->music_id <= 80000347 &&
song->music_id != allowed_yanyan)
{
continue;
}

Expand Down Expand Up @@ -1098,9 +1101,12 @@ static enum music_load_res music_load_individual(int index, void *node)
property_node_refer(nullptr, node, "/version", PROP_TYPE_str, tmp, sizeof(tmp));
song->version = strtoul(tmp, nullptr, 16);

if (!song->version) {
return MUSIC_LOAD_BAD_VER;
}
// Extend songs use a version of 0, we've now patched anything that might
// need nonzero (allll the sorting and grouping functions, for example)

// if (!song->version) {
// return MUSIC_LOAD_BAD_VER;
// }

// sane defaults
memset(song->genre_list, 0, sizeof(song->genre_list));
Expand Down Expand Up @@ -1136,9 +1142,12 @@ static enum music_load_res music_load_individual(int index, void *node)
property_node_refer(nullptr, node, "/music_type", PROP_TYPE_s32, &song->music_type, 4);

// ultimate music db only has detail_level
property_node_refer(nullptr, node, "/detail_level_bsc", PROP_TYPE_float, &song->detail_level_bsc, 4);
property_node_refer(nullptr, node, "/detail_level_adv", PROP_TYPE_float, &song->detail_level_adv, 4);
property_node_refer(nullptr, node, "/detail_level_ext", PROP_TYPE_float, &song->detail_level_ext, 4);
property_node_refer(
nullptr, node, "/detail_level_bsc", PROP_TYPE_float, &song->detail_level_bsc, 4);
property_node_refer(
nullptr, node, "/detail_level_adv", PROP_TYPE_float, &song->detail_level_adv, 4);
property_node_refer(
nullptr, node, "/detail_level_ext", PROP_TYPE_float, &song->detail_level_ext, 4);

property_node_refer(nullptr, node, "/pos_index", PROP_TYPE_s16, &song->pos_index, 2);
property_node_refer(nullptr, node, "/is_default", PROP_TYPE_s32, &song->is_default, 4);
Expand All @@ -1151,19 +1160,26 @@ static enum music_load_res music_load_individual(int index, void *node)
property_node_refer(nullptr, node, "/step", PROP_TYPE_s32, &song->step, 4);
property_node_refer(nullptr, node, "genre/pops", PROP_TYPE_u8, &song->genre_pops, 1);
property_node_refer(nullptr, node, "genre/anime", PROP_TYPE_u8, &song->genre_anime, 1);
property_node_refer(nullptr, node, "genre/socialmusic", PROP_TYPE_u8, &song->genre_socialmusic, 1);
property_node_refer(
nullptr, node, "genre/socialmusic", PROP_TYPE_u8, &song->genre_socialmusic, 1);
property_node_refer(nullptr, node, "genre/game", PROP_TYPE_u8, &song->genre_game, 1);
property_node_refer(nullptr, node, "genre/classic", PROP_TYPE_u8, &song->genre_classical, 1);
property_node_refer(nullptr, node, "genre/original", PROP_TYPE_u8, &song->genre_original, 1);
property_node_refer(nullptr, node, "genre/toho", PROP_TYPE_u8, &song->genre_toho, 1);
property_node_refer(nullptr, node, "/grouping_category", PROP_TYPE_str, tmp, sizeof(tmp));
property_node_refer(nullptr, node, "/pack_id", PROP_TYPE_s32, &song->pack_id, 4);
property_node_refer(nullptr, node, "ultimate/vanilla", PROP_TYPE_u8, &song->ultimate_list_vanilla, 1);
property_node_refer(nullptr, node, "ultimate/omnimix", PROP_TYPE_u8, &song->ultimate_list_omnimix, 1);
property_node_refer( nullptr, node, "ultimate/jubeat_plus", PROP_TYPE_u8, &song->ultimate_list_jubeat_plus, 1);
property_node_refer( nullptr, node, "ultimate/jubeat_2020", PROP_TYPE_u8, &song->ultimate_list_jubeat_2020, 1);
property_node_refer(nullptr, node, "ultimate/jukebeat", PROP_TYPE_u8, &song->ultimate_list_jukebeat, 1);
property_node_refer(nullptr, node, "ultimate/western", PROP_TYPE_u8, &song->ultimate_list_western, 1);
property_node_refer(
nullptr, node, "ultimate/vanilla", PROP_TYPE_u8, &song->ultimate_list_vanilla, 1);
property_node_refer(
nullptr, node, "ultimate/omnimix", PROP_TYPE_u8, &song->ultimate_list_omnimix, 1);
property_node_refer(
nullptr, node, "ultimate/jubeat_plus", PROP_TYPE_u8, &song->ultimate_list_jubeat_plus, 1);
property_node_refer(
nullptr, node, "ultimate/jubeat_2020", PROP_TYPE_u8, &song->ultimate_list_jubeat_2020, 1);
property_node_refer(
nullptr, node, "ultimate/jukebeat", PROP_TYPE_u8, &song->ultimate_list_jukebeat, 1);
property_node_refer(
nullptr, node, "ultimate/western", PROP_TYPE_u8, &song->ultimate_list_western, 1);
song->grouping_category = strtoul(tmp, nullptr, 16);
property_node_refer(
nullptr, node, "/title_name", PROP_TYPE_str, song->title_name, sizeof(song->title_name));
Expand Down Expand Up @@ -1427,16 +1443,8 @@ typedef struct {
} kata_lookup_t;

static const std::vector<kata_lookup_t> kata_lookup = {
{"","", 0},
{"","", 1},
{"","", 2},
{"","", 3},
{"","", 4},
{"","", 5},
{"","", 6},
{"","", 7},
{"","", 8},
{"","", 9},
{ "", "", 0 }, { "", "", 1 }, { "", "", 2 }, { "", "", 3 }, { "", "", 4 },
{ "", "", 5 }, { "", "", 6 }, { "", "", 7 }, { "", "", 8 }, { "", "", 9 },
};

static int __cdecl music_db_get_music_name_head_index(int id)
Expand All @@ -1463,14 +1471,14 @@ static int __cdecl music_db_get_music_name_head_index(int id)

// unicode values of kana are 3 bytes each, this is an efficiency boost
// instead of strlen-ing both strings
if(strnlen(song->sort_name, 3) < 3) {
if (strnlen(song->sort_name, 3) < 3) {
return 0;
}

for(auto &lookup : kata_lookup) {
for (auto &lookup : kata_lookup) {
int start = strncmp(song->sort_name, lookup.start, 3);
int end = strncmp(song->sort_name, lookup.end, 3);
if(start == 0 || end == 0 || (start > 0 && end < 0)) {
if (start == 0 || end == 0 || (start > 0 && end < 0)) {
// it's a bit flag
return 1 << lookup.result;
}
Expand Down Expand Up @@ -1527,14 +1535,7 @@ static int version_bit_count(int id)
return 0;
}

int bits = 0;
while (!((1 << bits) & song->version)) {
if (++bits >= 14) {
break;
}
}

return bits;
return std::countr_zero(song->version);
}

bool __cdecl music_db_is_exists_version_from_ver1(int id)
Expand Down Expand Up @@ -1672,11 +1673,11 @@ static bool __cdecl music_db_is_possession_for_contained_music_list(uint8_t flag
reinterpret_cast<uint8_t *>(dll_dos) + dll_dos->e_lfanew);
auto section_count = nt_headers->FileHeader.NumberOfSections;

// iterate sections
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
// iterate sections
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
PIMAGE_SECTION_HEADER section_header = IMAGE_FIRST_SECTION(nt_headers);
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
for (size_t i = 0; i < section_count; section_header++, i++) {
auto name = reinterpret_cast<const char *>(section_header->Name);

Expand Down
4 changes: 2 additions & 2 deletions festo/ultimate/music_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {

void hook_music_db(HANDLE process, HMODULE jubeat_handle, HMODULE music_db_handle);

enum genre_type: uint8_t {
enum genre_type : uint8_t {
GENRE_NOT_IN = 0,
// the song is in this genre
GENRE_SECONDARY = 1,
Expand All @@ -35,7 +35,7 @@ struct music_db_entry_t {
float bpm_max;
float bpm_min;
int music_type;
int version;
unsigned int version;
int16_t pos_index;
int index_start;
int is_default; // was: char
Expand Down
Loading

0 comments on commit db6761b

Please sign in to comment.