wip longest bpm

This commit is contained in:
CrazyRedMachine 2023-08-25 00:26:57 +02:00
parent 9adefd2ba3
commit c099d5da17

View File

@ -3990,11 +3990,47 @@ uint32_t g_hispeed = 0;
unsigned char *g_chart_addr = 0;
bool g_longest_bpm_old_chart = false;
typedef struct chart_chunk_s {
uint32_t timestamp;
uint16_t operation;
uint16_t data;
uint32_t duration;
} chart_chunk_t;
#define CHART_OP_BPM 0x0445
#define CHART_OP_END 0x0645
void compute_longest_bpm(){
if (g_chart_addr[0] == 0x64)
g_longest_bpm = 350;
else
g_longest_bpm = 175;
chart_chunk_t* chunk = NULL;
unsigned char *chart_ptr = g_chart_addr;
int chunk_size = g_longest_bpm_old_chart? 8 : 12;
uint32_t prev_timestamp = 0x64;
uint16_t prev_bpm = 0;
uint32_t max_duration = 0;
uint16_t longest_bpm = 0;
do {
chunk = (chart_chunk_t*) chart_ptr;
if ( chunk->operation == CHART_OP_BPM || chunk->operation == CHART_OP_END )
{
if (prev_bpm)
{
uint32_t duration = chunk->timestamp - prev_timestamp;
//if prev_bpm doesn't have an entry, make one
//add duration to prev_bpm entry
//check if prev_bpm entry is > max_duration : max_duration=entry[prev_bpm] and longest_bpm=prev_bpm if required
}
prev_bpm = chunk->data;
prev_timestamp = chunk->timestamp;
}
chart_ptr += chunk_size;
} while ( chunk->operation != CHART_OP_END );
g_longest_bpm = longest_bpm;
}
void (*real_set_hispeed)();