Skip to content

Commit

Permalink
Tools: VAL-FX, fortISSimO, VGM2GBSFX, compat
Browse files Browse the repository at this point in the history
- SFX: VAL-FX support (untested)
- SFX: VGM2GBSFX
- Music: fortISSimO
- Use macros(c) and functions(js) to allow copy and paste of C testing code into JS. Only SFX and Music converted yet.
  • Loading branch information
bbbbbr committed Oct 26, 2022
1 parent d569b02 commit a55265c
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 66 deletions.
8 changes: 7 additions & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
// Get string length without trailing terminator
#define sizeof_str_noterm(instr) (sizeof(instr) - 1)

// DEBUG_LOG_MATCHES
// Debug option
// #define DEBUG_LOG_MATCHES

// For code copy & paste compat between C version and JS version
#define FIND_PATTERN_BUF(ptr_to_buf) (find_pattern(ptr_to_buf, sizeof(ptr_to_buf)))
#define FIND_PATTERN_STR_NOTERM(ptr_to_buf) (find_pattern(ptr_to_buf, sizeof_str_noterm(ptr_to_buf)))
#define FORMAT_ENTRY(e_type, e_name, e_version) ((tool_entry){.type = e_type, .c_name = e_name, .c_version = e_version})

#endif // _COMMON_H
3 changes: 3 additions & 0 deletions src/sig_gbstudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// const table: https://github.com/chrismaltby/gb-studio/blame/d045e345be310314ccc4f371a7d5370cae702d3e/appData/src/gb/src/core/math.c
const uint8_t sig_gbs_math_c_sinetable_3_0_0_alpha1_plus[] = {0x00, 0x03, 0x06, 0x09, 0x0C, 0x10, 0x13, 0x16, 0x19, 0x1C, 0x1F, 0x22, 0x25, 0x28, 0x2B, 0x2E, 0x31, 0x33, 0x36, 0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x49, 0x4C, 0x4E, 0x51, 0x53, 0x55, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6B, 0x6D, 0x6F, 0x70, 0x71, 0x73, 0x74, 0x75, 0x76, 0x78, 0x79, 0x7A};

//TODO: See SFX: sig_vgm2gbsfx_aud3waveram_load[] for GBStudio 3.1.0+ (not confirmed present for all)



// Check GBStudio engine
bool check_gbstudio(void) {
Expand Down
97 changes: 52 additions & 45 deletions src/sig_music.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
const uint8_t sig_hugetracker_fx_vol_slide_base_v1[] = {0x79, 0xE6, 0x0F, 0x57, 0x79, 0xE6, 0xF0, 0x5F, 0xCB, 0x33 ,0x7E, 0xE6, 0xF0, 0xCB, 0x37, 0x92};
// https://github.com/SuperDisk/hUGEDriver/blob/e996cfab0b16bea6e394f269e89a5729d8421bb2/hUGEDriver.asm#L736 -> 743
const uint8_t sig_hugetracker_fx_vol_slide_base_v2[] = {0x79, 0xE6, 0x0F, 0x57, 0x79, 0xE6, 0xF0, 0x5F, 0xCB, 0x33 ,0x78, 0x87, 0x87, 0x80, 0xC6, 0x12, 0x4F, 0xF2, 0xE6, 0xF0, 0xCB, 0x37, 0x92};

// ADDED: Initial Release (2022-10)
// asm: https://github.com/ISSOtm/fortISSimO/blob/master/fortISSimO.asm#L937
const uint8_t sig_hugetracker_fortissimo_fx_vol_slide[] = {0xA1, 0xC8, 0xEE, 0x02, 0x3C, 0xEE, 0x04, 0xC6, 0x12, 0x4F, 0x78, 0x06, 0xF0, 0xA0, 0x67, 0x78, 0xCB, 0x37, 0xA0, 0x6F, 0xF2, 0xA0, 0x95};

// engine.asm, tbe_thumbprint::
const uint8_t sig_tbengine_noisetable[] = "tbengine - sound driver by stoneface";
Expand Down Expand Up @@ -107,86 +109,91 @@
void check_music(void) {
tool_entry entry;

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "GHX", .c_version = ""};
if (find_pattern(sig_str_ghx_audio, sizeof_str_noterm(sig_str_ghx_audio)) ||
find_pattern(sig_str_ghx_sound, sizeof_str_noterm(sig_str_ghx_sound)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"GHX", "");
if (FIND_PATTERN_STR_NOTERM(sig_str_ghx_audio) ||
FIND_PATTERN_STR_NOTERM(sig_str_ghx_sound))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "DevSound", .c_version = "Standard"};
if (find_pattern(sig_str_devsound_standard, sizeof_str_noterm(sig_str_devsound_standard)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"DevSound","Standard");
if (FIND_PATTERN_STR_NOTERM(sig_str_devsound_standard))
entry_add(entry);
else {
entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "DevSound", .c_version = "Lite"};
if (find_pattern(sig_str_devsound_lite, sizeof_str_noterm(sig_str_devsound_lite)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"DevSound","Lite");
if (FIND_PATTERN_STR_NOTERM(sig_str_devsound_lite))
entry_add(entry);
}

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Visual Impact", .c_version = ""};
if (find_pattern(sig_str_gbmusicplayer_audio, sizeof_str_noterm(sig_str_gbmusicplayer_audio)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Visual Impact", "");
if (FIND_PATTERN_STR_NOTERM(sig_str_gbmusicplayer_audio))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "MusyX", .c_version = ""};
if (find_pattern(sig_str_MusyX_1, sizeof_str_noterm(sig_str_MusyX_1)) ||
find_pattern(sig_str_MusyX_2, sizeof_str_noterm(sig_str_MusyX_2)) ||
find_pattern(sig_str_MusyX_3, sizeof_str_noterm(sig_str_MusyX_3)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"MusyX", "");
if (FIND_PATTERN_STR_NOTERM(sig_str_MusyX_1) ||
FIND_PATTERN_STR_NOTERM(sig_str_MusyX_2) ||
FIND_PATTERN_STR_NOTERM(sig_str_MusyX_3))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Freaq", .c_version = ""};
if (find_pattern(sig_str_freaq_1, sizeof_str_noterm(sig_str_freaq_1)) ||
find_pattern(sig_str_freaq_2, sizeof_str_noterm(sig_str_freaq_2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Freaq", "");
if (FIND_PATTERN_STR_NOTERM(sig_str_freaq_1) ||
FIND_PATTERN_STR_NOTERM(sig_str_freaq_2))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "LSDJ", .c_version = ""};
if (find_pattern(sig_str_lsdj_1, sizeof_str_noterm(sig_str_lsdj_1)) ||
find_pattern(sig_str_lsdj_2, sizeof_str_noterm(sig_str_lsdj_2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"LSDJ", "");
if (FIND_PATTERN_STR_NOTERM(sig_str_lsdj_1) ||
FIND_PATTERN_STR_NOTERM(sig_str_lsdj_2))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "hUGETracker", .c_version = ""};
if (find_pattern(sig_hugetracker_fx_vol_slide_base_v1, sizeof(sig_hugetracker_fx_vol_slide_base_v1)))
// hUGETracker and variants
entry = FORMAT_ENTRY(TYPE_MUSIC,"hUGETracker","SuperDisk");
if (FIND_PATTERN_BUF(sig_hugetracker_fx_vol_slide_base_v1))
entry_add(entry);
else if (FIND_PATTERN_BUF(sig_hugetracker_fx_vol_slide_base_v2))
entry_add(entry);
else if (find_pattern(sig_hugetracker_fx_vol_slide_base_v2, sizeof(sig_hugetracker_fx_vol_slide_base_v2)))
else if (FIND_PATTERN_BUF(sig_hugetracker_fortissimo_fx_vol_slide)) {
entry = FORMAT_ENTRY(TYPE_MUSIC,"hUGETracker","fortISSimO");
entry_add(entry);
}

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Trackerboy engine", .c_version = ""};
if (find_pattern(sig_tbengine_noisetable, sizeof_str_noterm(sig_tbengine_noisetable)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Trackerboy engine", "");
if (FIND_PATTERN_STR_NOTERM(sig_tbengine_noisetable))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Black Box Music Box", .c_version = ""};
if (find_pattern(sig_blackboxplayer_1, sizeof(sig_blackboxplayer_1)) &&
find_pattern(sig_blackboxplayer_2, sizeof(sig_blackboxplayer_2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Black Box Music Box", "");
if (FIND_PATTERN_BUF(sig_blackboxplayer_1) &&
FIND_PATTERN_BUF(sig_blackboxplayer_2))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Lemon", .c_version = ""};
if (find_pattern(sig_lemon_wave_default, sizeof(sig_lemon_wave_default)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Lemon", "");
if (FIND_PATTERN_BUF(sig_lemon_wave_default))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "GBT Player", .c_version = ""};
if (find_pattern(sig_gbtplayer_gbt_wave, sizeof(sig_gbtplayer_gbt_wave)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"GBT Player", "");
if (FIND_PATTERN_BUF(sig_gbtplayer_gbt_wave))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "Carillon Player", .c_version = ""};
if (find_pattern(sig_carillon_player_1, sizeof_str_noterm(sig_carillon_player_1)) ||
find_pattern(sig_carillon_player_2, sizeof_str_noterm(sig_carillon_player_2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"Carillon Player", "");
if (FIND_PATTERN_STR_NOTERM(sig_carillon_player_1) ||
FIND_PATTERN_STR_NOTERM(sig_carillon_player_2))
entry_add(entry);

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "MPlay", .c_version = ""};
if (find_pattern(sig_mplay2, sizeof(sig_mplay2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"MPlay", "");
if (FIND_PATTERN_BUF(sig_mplay2))
entry_add_with_version(entry, "2");
else if (find_pattern(sig_mplay1, sizeof(sig_mplay1)))
else if (FIND_PATTERN_BUF(sig_mplay1))
entry_add_with_version(entry, "1");

entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "GBSoundSystem", .c_version = "Modern"};
if (find_pattern(sig_gbsoundsystem_modern_SSFP_multi_sfx, sizeof(sig_gbsoundsystem_modern_SSFP_multi_sfx))) {
// GBSoundSystem (Paragon5) and variants
entry = FORMAT_ENTRY(TYPE_MUSIC,"GBSoundSystem","Modern");
if (FIND_PATTERN_BUF(sig_gbsoundsystem_modern_SSFP_multi_sfx)) {
entry_add(entry);
}
else {
entry = (tool_entry){.type = TYPE_MUSIC, .c_name = "GBSoundSystem", .c_version = "Classic"};
if (find_pattern(sig_str_gbsoundsystem_1, sizeof_str_noterm(sig_str_gbsoundsystem_1)) &&
find_pattern(sig_str_gbsoundsystem_2, sizeof_str_noterm(sig_str_gbsoundsystem_2)))
entry = FORMAT_ENTRY(TYPE_MUSIC,"GBSoundSystem","Classic");
if (FIND_PATTERN_STR_NOTERM(sig_str_gbsoundsystem_1) &&
FIND_PATTERN_STR_NOTERM(sig_str_gbsoundsystem_2))
entry_add(entry);
else if (find_pattern(sig_gbsoundsystem_MultiSFXLoop, sizeof(sig_gbsoundsystem_MultiSFXLoop)))
else if (FIND_PATTERN_BUF(sig_gbsoundsystem_MultiSFXLoop))
entry_add(entry);
}


}
60 changes: 40 additions & 20 deletions src/sig_soundfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,54 @@
#include "gbtoolchainid.h"


// ==== FX Hammer Player
// Records can be at any location

// From "Sliced" 32KB SRAM File (*.sav) into two files (or ROM banks for assembler)
// Slices a 32KB SRAM File (*.sav) into two files (or ROM banks for assembler):
// 1) 16KB music player code and music data (*.bin)
// "@FX HAMMER Version 1.0 (c)2000 Aleksi Eeben (email:[email protected])";
// FX@HAMMER@V1:0@@@ ... @<2000@ALEKSI@EEBEN@
const uint8_t sig_fxhammer_info_1[] = "FX HAMMER";
const uint8_t sig_fxhammer_info_2[] = "FX@HAMMER";

// ==== CBT-FX
// Records can be at any location
// ==== FX Hammer Player
// Records can be at any location

// From "Sliced" 32KB SRAM File (*.sav) into two files (or ROM banks for assembler)
// Slices a 32KB SRAM File (*.sav) into two files (or ROM banks for assembler):
// 1) 16KB music player code and music data (*.bin)
// "@FX HAMMER Version 1.0 (c)2000 Aleksi Eeben (email:[email protected])";
// FX@HAMMER@V1:0@@@ ... @<2000@ALEKSI@EEBEN@
const uint8_t sig_fxhammer_info_1[] = "FX HAMMER";
const uint8_t sig_fxhammer_info_2[] = "FX@HAMMER";

// ==== CBT-FX
// Records can be at any location
// constant : https://github.com/datguywitha3ds/CBT-FX/tree/main
const uint8_t sig_cbtfx_info[] = "CBT-FX BY COFFEEBAT 2021";

// ==== VAL-FX
// Records can be at any location
// constant: https://github.com/ISSOtm/val-fx/blob/master/val-fx.asm#L49
const uint8_t sig_valfx_info[] = "VAL-FX BY CVB";

// ==== VGM2GBSFX
// Records can be at any location
// This may also ID GBStudio 3.1.0+
// asm : https://github.com/untoxa/VGM2GBSFX/blob/main/src/gbz80/sfxplayer.c#L61
const uint8_t sig_vgm2gbsfx_aud3waveram_load[] = {0x2A, 0x47, 0xE6, 0x07, 0xFE, 0x05, 0x38, 0x5A, 0xFE, 0x07, 0x28, 0x50, 0xAF, 0xEA, 0x1A, 0xFF, 0x0E, 0x30, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C};
// Full version, but prob not needed // {0x2A, 0x47, 0xE6, 0x07, 0xFE, 0x05, 0x38, 0x5A, 0xFE, 0x07, 0x28, 0x50, 0xAF, 0xEA, 0x1A, 0xFF, 0x0E, 0x30, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C, 0x2A, 0xE2, 0x0C};


// Check for Sound FX drivers
void check_soundfx(void) {

tool_entry entry;

// FXHammer music 1.0
entry = (tool_entry){.type = TYPE_SOUNDFX, .c_name = "FX Hammer", .c_version = ""};
if (find_pattern(sig_fxhammer_info_1, sizeof_str_noterm(sig_fxhammer_info_1)) ||
find_pattern(sig_fxhammer_info_2, sizeof_str_noterm(sig_fxhammer_info_2)) )
entry = FORMAT_ENTRY(TYPE_SOUNDFX,"FX Hammer", "");
if (FIND_PATTERN_STR_NOTERM(sig_fxhammer_info_1) ||
FIND_PATTERN_STR_NOTERM(sig_fxhammer_info_2) )
entry_add(entry);

entry = FORMAT_ENTRY(TYPE_SOUNDFX,"CBT-FX", "");
if (FIND_PATTERN_STR_NOTERM(sig_cbtfx_info))
entry_add(entry);

entry = FORMAT_ENTRY(TYPE_SOUNDFX,"VAL-FX", "");
if (FIND_PATTERN_STR_NOTERM(sig_valfx_info))
entry_add(entry);

// CBT-FX : https://github.com/datguywitha3ds/CBT-FX/tree/main
entry = (tool_entry){.type = TYPE_SOUNDFX, .c_name = "CBT-FX", .c_version = ""};
if (find_pattern(sig_cbtfx_info, sizeof_str_noterm(sig_cbtfx_info)))
entry = FORMAT_ENTRY(TYPE_SOUNDFX,"VGM2GBSFX", "");
if (FIND_PATTERN_BUF(sig_vgm2gbsfx_aud3waveram_load))
entry_add(entry);
}

0 comments on commit a55265c

Please sign in to comment.