diff --git a/core/core.cpp b/core/core.cpp index 5d43b7e..b9a0f72 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -313,6 +313,35 @@ sint32 NSFCore::group_enum(const char* key, int len) return -1; } +NSFSetInfo NSFCore::set_info(sint32 setenum) const +{ + NSFSetInfo info = {0}; info.group = -1; + if (setenum < 0 || setenum > NSFP_SET_COUNT) return info; + const NSFSetData& SD = NSFPD_SET[setenum]; + info.group = SD.group; + info.key = SD.key; + info.name = local_text(SD.text+0); + info.desc = local_text(SD.text+1); + info.is_string = (SD.default_str != NULL); + info.default_int = SD.default_int; + info.min_int = SD.min_int; + info.max_int = SD.max_int; + info.list = (SD.list >= 0) ? (local_text(NSFPD_LIST_TEXT[SD.list])) : NULL; + info.default_str = SD.default_str; + return info; +} + +NSFSetGroupInfo NSFCore::group_info(sint32 group) const +{ + NSFSetGroupInfo info = {0}; + if (group < 0 || group > NSFP_GROUP_COUNT) return info; + const NSFSetGroupData& GD = NSFPD_GROUP[group]; + info.key = GD.key; + info.name = local_text(GD.text+0); + info.desc = local_text(GD.text+1); + return info; +} + const char* NSFCore::ini_line(sint32 setenum) const { if (setenum < 0 || setenum >= NSFP_SET_COUNT) return ""; @@ -397,6 +426,10 @@ const char* NSFCore::local_text(sint32 textenum) const const char* NSFCore::local_text(sint32 textenum, sint32 locale) { if (locale < 0 || locale >= NSFP_LOCALE_COUNT || textenum < 0 || textenum >= NSFP_TEXT_COUNT) - return ""; - return (const char*)(NSFPD_LOCAL_TEXT_DATA + NSFPD_LOCAL_TEXT[locale][textenum+NSFP_TEXT_INDEX]); + { + // text 0 is a default value + locale = 0; + textenum = 0; + } + return (const char*)(NSFPD_LOCAL_TEXT_DATA + NSFPD_LOCAL_TEXT[locale][textenum]); } diff --git a/core/core.h b/core/core.h index 3fb4d45..eb60f2b 100644 --- a/core/core.h +++ b/core/core.h @@ -61,11 +61,11 @@ typedef struct NSFCore_ static sint32 set_enum(const char* key, int len=-1); // len truncates, len<0 uses strlen static sint32 group_enum(const char* key, int len=-1); + NSFSetInfo set_info(sint32 setenum) const; + NSFSetGroupInfo group_info(sint32 group) const; const char* ini_line(sint32 setenum) const; bool parse_ini_line(const char* line, int len, int linenum); // used by set_ini - // TODO after changing settings, they need to be applied at some point, some might be immediate - const char* local_text(sint32 textenum) const; // NSFP_TEXT_x for curent locale static const char* local_text(sint32 textenum, sint32 locale); // NSFP_TEXT_x for specific locale diff --git a/core/enums_data.h b/core/enums_data.h index 85f3fb9..642d8c5 100644 --- a/core/enums_data.h +++ b/core/enums_data.h @@ -1,11 +1,11 @@ #pragma once // generated by nsfplayenums.py -// 2024-04-21 23:02:38 +// 2024-04-22 00:45:03 #include "../include/nsfplayenums.h" -const int32_t NSFPD_LIST[NSFP_LIST_COUNT] = { - 0, 1, +const int32_t NSFPD_LIST_TEXT[NSFP_LIST_COUNT] = { + 1, 2, }; typedef struct { @@ -13,9 +13,9 @@ typedef struct { int32_t text; } NSFSetGroupData; const NSFSetGroupData NSFPD_GROUP[NSFP_GROUP_COUNT] = { - { "MAIN", 2 }, - { "APU0", 4 }, - { "APU1", 6 }, + { "MAIN", 3 }, + { "APU0", 5 }, + { "APU1", 7 }, }; typedef struct { @@ -23,11 +23,11 @@ typedef struct { int32_t unit, text; } NSFChannelData; const NSFChannelData NSFPD_CHANNEL[NSFP_CHANNEL_COUNT] = { - { "SQU0", 0, 8 }, - { "SQU1", 0, 9 }, - { "TRI", 1, 10 }, - { "NSE", 1, 11 }, - { "DPCM", 1, 12 }, + { "SQU0", 0, 9 }, + { "SQU1", 0, 10 }, + { "TRI", 1, 11 }, + { "NSE", 1, 12 }, + { "DPCM", 1, 13 }, }; typedef struct { @@ -37,26 +37,26 @@ typedef struct { const char* default_str; } NSFSetData; const NSFSetData NSFPD_SET[NSFP_SET_COUNT] = { - { "VOLUME", 0, 13, 500, 0, 1000, -1,NULL }, - { "SAMPLERATE", 0, 15, 48000, 1000,4000000, -1,NULL }, - { "STEREO", 0, 17, 1, 0, 1, 0,NULL }, - { "TITLE_FORMAT", 0, 19, 0, 0, 0, -1,"%L (%n/%e) %T - %A" }, - { "LOCALE", 0, 21, 0, 0, 1, 1,NULL }, - { "SQU0_ON", 1, 23, 1, 0, 1, 0,NULL }, - { "SQU0_VOL", 1, 25, 500, 0, 1000, -1,NULL }, - { "SQU0_PAN", 1, 27, 500, 0, 1000, -1,NULL }, - { "SQU1_ON", 1, 29, 1, 0, 1, 0,NULL }, - { "SQU1_VOL", 1, 31, 500, 0, 1000, -1,NULL }, - { "SQU1_PAN", 1, 33, 500, 0, 1000, -1,NULL }, - { "TRI_ON", 2, 35, 1, 0, 1, 0,NULL }, - { "TRI_VOL", 2, 37, 500, 0, 1000, -1,NULL }, - { "TRI_PAN", 2, 39, 500, 0, 1000, -1,NULL }, - { "NSE_ON", 2, 41, 1, 0, 1, 0,NULL }, - { "NSE_VOL", 2, 43, 500, 0, 1000, -1,NULL }, - { "NSE_PAN", 2, 45, 500, 0, 1000, -1,NULL }, - { "DPCM_ON", 2, 47, 1, 0, 1, 0,NULL }, - { "DPCM_VOL", 2, 49, 500, 0, 1000, -1,NULL }, - { "DPCM_PAN", 2, 51, 500, 0, 1000, -1,NULL }, + { "VOLUME", 0, 14, 500, 0, 1000, -1,NULL }, + { "SAMPLERATE", 0, 16, 48000, 1000,4000000, -1,NULL }, + { "STEREO", 0, 18, 1, 0, 1, 0,NULL }, + { "TITLE_FORMAT", 0, 20, 0, 0, 0, -1,"%L (%n/%e) %T - %A" }, + { "LOCALE", 0, 22, 0, 0, 1, 1,NULL }, + { "SQU0_ON", 1, 24, 1, 0, 1, 0,NULL }, + { "SQU0_VOL", 1, 26, 500, 0, 1000, -1,NULL }, + { "SQU0_PAN", 1, 28, 500, 0, 1000, -1,NULL }, + { "SQU1_ON", 1, 30, 1, 0, 1, 0,NULL }, + { "SQU1_VOL", 1, 32, 500, 0, 1000, -1,NULL }, + { "SQU1_PAN", 1, 34, 500, 0, 1000, -1,NULL }, + { "TRI_ON", 2, 36, 1, 0, 1, 0,NULL }, + { "TRI_VOL", 2, 38, 500, 0, 1000, -1,NULL }, + { "TRI_PAN", 2, 40, 500, 0, 1000, -1,NULL }, + { "NSE_ON", 2, 42, 1, 0, 1, 0,NULL }, + { "NSE_VOL", 2, 44, 500, 0, 1000, -1,NULL }, + { "NSE_PAN", 2, 46, 500, 0, 1000, -1,NULL }, + { "DPCM_ON", 2, 48, 1, 0, 1, 0,NULL }, + { "DPCM_VOL", 2, 50, 500, 0, 1000, -1,NULL }, + { "DPCM_PAN", 2, 52, 500, 0, 1000, -1,NULL }, }; typedef struct { @@ -64,11 +64,11 @@ typedef struct { int32_t type, text; } NSFPropData; const NSFPropData NSFPD_PROP[NSFP_PROP_COUNT] = { - { "SONGCOUNT",1, 53 }, - { "LONG",2, 54 }, - { "TITLE",3, 55 }, - { "INFO",4, 56 }, - { "BLOB",5, 57 }, + { "SONGCOUNT",1, 54 }, + { "LONG",2, 55 }, + { "TITLE",3, 56 }, + { "INFO",4, 57 }, + { "BLOB",5, 58 }, }; typedef struct { @@ -76,52 +76,53 @@ typedef struct { int32_t type, text; } NSFSongPropData; const NSFSongPropData NSFPD_SONGPROP[NSFP_SONGPROP_COUNT] = { - { "INT",1, 58 }, - { "SONGTEST",1, 59 }, - { "LONG",2, 60 }, - { "TITLE",3, 61 }, - { "INFO",4, 62 }, - { "BLOB",5, 63 }, + { "INT",1, 59 }, + { "SONGTEST",1, 60 }, + { "LONG",2, 61 }, + { "TITLE",3, 62 }, + { "INFO",4, 63 }, + { "BLOB",5, 64 }, }; -const int32_t NSFPD_LOCAL_TEXT[NSFP_LOCALE_COUNT][72] = { +const int32_t NSFPD_LOCAL_TEXT[NSFP_LOCALE_COUNT][73] = { { - 0x000000,0x000008,0x00001B,0x000020,0x00002E,0x000033,0x00002E,0x00002E,0x000057,0x00005C,0x000061,0x000065,0x000069,0x00006E,0x000075,0x00007C, - 0x000087,0x000092,0x000099,0x0000A0,0x0000AD,0x0000C3,0x0000C3,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000D1,0x0000D1,0x0000D1, - 0x0000D1,0x0000D1,0x0000D1,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000E4, - 0x0000E4,0x0000E4,0x0000E4,0x0000E4,0x0000E4,0x0000EB,0x0000F6,0x0000FB,0x000101,0x000106,0x00010B,0x00010F,0x0000F6,0x000119,0x000101,0x000106, - 0x000124,0x000136,0x000158,0x00017A,0x0001AE,0x0001DA,0x000208,0x000238, + 0x000000,0x00000F,0x000017,0x00002A,0x00002F,0x00003D,0x000042,0x00003D,0x00003D,0x000066,0x00006B,0x000070,0x000074,0x000078,0x00007D,0x000084, + 0x00008B,0x000096,0x0000A1,0x0000A8,0x0000AF,0x0000BC,0x0000D2,0x0000D2,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000E0,0x0000E0, + 0x0000E0,0x0000E0,0x0000E0,0x0000E0,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000ED,0x0000ED,0x0000ED,0x0000ED,0x0000ED,0x0000ED, + 0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000FA,0x000105,0x00010A,0x000110,0x000115,0x00011A,0x00011E,0x000105,0x000128,0x000110, + 0x000115,0x000133,0x000145,0x000167,0x000189,0x0001BD,0x0001E9,0x000217,0x000247, }, { - 0x000000,0x000008,0x00001B,0x000020,0x00002E,0x000033,0x00002E,0x00002E,0x000057,0x00005C,0x000061,0x000065,0x000069,0x00006E,0x000075,0x00007C, - 0x000087,0x000092,0x000099,0x0000A0,0x0000AD,0x0000C3,0x0000C3,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000CA,0x0000D1,0x0000D1,0x0000D1, - 0x0000D1,0x0000D1,0x0000D1,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000D8,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000DE,0x0000E4, - 0x0000E4,0x0000E4,0x0000E4,0x0000E4,0x0000E4,0x0000EB,0x0000F6,0x0000FB,0x000101,0x000106,0x00010B,0x00010F,0x0000F6,0x000119,0x000101,0x000106, - 0x00012E,0x000146,0x00016B,0x00019B,0x0001C6,0x0001F6,0x000226,0x000265, + 0x000000,0x00000F,0x000017,0x00002A,0x00002F,0x00003D,0x000042,0x00003D,0x00003D,0x000066,0x00006B,0x000070,0x000074,0x000078,0x00007D,0x000084, + 0x00008B,0x000096,0x0000A1,0x0000A8,0x0000AF,0x0000BC,0x0000D2,0x0000D2,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000D9,0x0000E0,0x0000E0, + 0x0000E0,0x0000E0,0x0000E0,0x0000E0,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000E7,0x0000ED,0x0000ED,0x0000ED,0x0000ED,0x0000ED,0x0000ED, + 0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000F3,0x0000FA,0x000105,0x00010A,0x000110,0x000115,0x00011A,0x00011E,0x000105,0x000128,0x000110, + 0x000115,0x00013D,0x000155,0x00017A,0x0001AA,0x0001D5,0x000205,0x000235,0x000274, }, }; -const uint8_t NSFPD_LOCAL_TEXT_DATA[0x000279] = { - 0x4F,0x66,0x66,0x00,0x4F,0x6E,0x00,0x00,0x45,0x6E,0x67,0x6C,0x69,0x73,0x68,0x00,0xE6,0x97,0xA5,0xE6,0x9C,0xAC,0xE8,0xAA,0x9E,0x00,0x00,0x4D,0x61,0x69,0x6E,0x00, - 0x4D,0x61,0x69,0x6E,0x20,0x53,0x65,0x74,0x74,0x69,0x6E,0x67,0x73,0x00,0x41,0x50,0x55,0x31,0x00,0x42,0x75,0x69,0x6C,0x74,0x2D,0x69,0x6E,0x20,0x74,0x72,0x69,0x61, - 0x6E,0x67,0x6C,0x65,0x2C,0x20,0x6E,0x6F,0x69,0x73,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20,0x44,0x50,0x43,0x4D,0x2E,0x00,0x53,0x51,0x55,0x30,0x00,0x53,0x51,0x55,0x31, - 0x00,0x54,0x52,0x49,0x00,0x4E,0x53,0x45,0x00,0x44,0x50,0x43,0x4D,0x00,0x56,0x4F,0x4C,0x55,0x4D,0x45,0x00,0x56,0x6F,0x6C,0x75,0x6D,0x65,0x00,0x53,0x41,0x4D,0x50, - 0x4C,0x45,0x52,0x41,0x54,0x45,0x00,0x53,0x61,0x6D,0x70,0x6C,0x65,0x72,0x61,0x74,0x65,0x00,0x53,0x54,0x45,0x52,0x45,0x4F,0x00,0x53,0x74,0x65,0x72,0x65,0x6F,0x00, - 0x54,0x49,0x54,0x4C,0x45,0x5F,0x46,0x4F,0x52,0x4D,0x41,0x54,0x00,0x4E,0x53,0x46,0x20,0x73,0x6F,0x6E,0x67,0x20,0x74,0x69,0x74,0x6C,0x65,0x20,0x66,0x6F,0x72,0x6D, - 0x61,0x74,0x00,0x4C,0x4F,0x43,0x41,0x4C,0x45,0x00,0x53,0x51,0x55,0x30,0x4F,0x4E,0x00,0x53,0x51,0x55,0x31,0x4F,0x4E,0x00,0x54,0x52,0x49,0x4F,0x4E,0x00,0x4E,0x53, - 0x45,0x4F,0x4E,0x00,0x44,0x50,0x43,0x4D,0x4F,0x4E,0x00,0x53,0x6F,0x6E,0x67,0x20,0x63,0x6F,0x75,0x6E,0x74,0x00,0x4C,0x4F,0x4E,0x47,0x00,0x54,0x49,0x54,0x4C,0x45, - 0x00,0x49,0x4E,0x46,0x4F,0x00,0x42,0x4C,0x4F,0x42,0x00,0x49,0x4E,0x54,0x00,0x53,0x6F,0x6E,0x67,0x20,0x74,0x65,0x73,0x74,0x00,0x53,0x6F,0x6E,0x67,0x20,0x74,0x69, - 0x74,0x6C,0x65,0x00,0x54,0x65,0x73,0x74,0x20,0x54,0x65,0x78,0x74,0x00,0x67,0x6F,0x6F,0x64,0x62,0x79,0x65,0x00,0x49,0x6E,0x76,0x61,0x6C,0x69,0x64,0x20,0x73,0x65, - 0x74,0x74,0x69,0x6E,0x67,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x53,0x45,0x54,0x5F,0x49,0x4E,0x56,0x41,0x4C,0x49,0x44,0x00,0x57,0x72,0x6F,0x6E,0x67,0x20,0x73,0x65, - 0x74,0x74,0x69,0x6E,0x67,0x20,0x74,0x79,0x70,0x65,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x53,0x45,0x54,0x5F,0x54,0x59,0x50,0x45,0x00,0x53,0x65,0x74,0x74,0x69,0x6E, - 0x67,0x20,0x6F,0x75,0x74,0x20,0x6F,0x66,0x20,0x72,0x61,0x6E,0x67,0x65,0x3A,0x20,0x25,0x64,0x20,0x28,0x25,0x64,0x2D,0x25,0x64,0x29,0x00,0x45,0x52,0x52,0x4F,0x52, - 0x5F,0x53,0x45,0x54,0x49,0x4E,0x54,0x5F,0x52,0x41,0x4E,0x47,0x45,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65,0x20,0x25,0x64,0x20,0x6D,0x69,0x73,0x73,0x69,0x6E, - 0x67,0x20,0x27,0x3D,0x27,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x4E,0x4F,0x5F,0x45,0x51,0x55,0x41,0x4C,0x53,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69, - 0x6E,0x65,0x20,0x25,0x64,0x20,0x75,0x6E,0x6B,0x6E,0x6F,0x77,0x6E,0x20,0x73,0x65,0x74,0x74,0x69,0x6E,0x67,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F, - 0x42,0x41,0x44,0x5F,0x4B,0x45,0x59,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65,0x20,0x25,0x64,0x20,0x62,0x61,0x64,0x20,0x69,0x6E,0x74,0x65,0x67,0x65,0x72,0x20, - 0x76,0x61,0x6C,0x75,0x65,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x42,0x41,0x44,0x5F,0x49,0x4E,0x54,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65, - 0x20,0x25,0x64,0x20,0x73,0x65,0x74,0x74,0x69,0x6E,0x67,0x20,0x6F,0x75,0x74,0x20,0x6F,0x66,0x20,0x72,0x61,0x6E,0x67,0x65,0x3A,0x20,0x25,0x64,0x20,0x28,0x25,0x64, - 0x2D,0x25,0x64,0x29,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x42,0x41,0x44,0x5F,0x52,0x41,0x4E,0x47,0x45,0x00, +const uint8_t NSFPD_LOCAL_TEXT_DATA[0x000288] = { + 0x3C,0x4D,0x49,0x53,0x53,0x49,0x4E,0x47,0x20,0x54,0x45,0x58,0x54,0x3E,0x00,0x4F,0x66,0x66,0x00,0x4F,0x6E,0x00,0x00,0x45,0x6E,0x67,0x6C,0x69,0x73,0x68,0x00,0xE6, + 0x97,0xA5,0xE6,0x9C,0xAC,0xE8,0xAA,0x9E,0x00,0x00,0x4D,0x61,0x69,0x6E,0x00,0x4D,0x61,0x69,0x6E,0x20,0x53,0x65,0x74,0x74,0x69,0x6E,0x67,0x73,0x00,0x41,0x50,0x55, + 0x31,0x00,0x42,0x75,0x69,0x6C,0x74,0x2D,0x69,0x6E,0x20,0x74,0x72,0x69,0x61,0x6E,0x67,0x6C,0x65,0x2C,0x20,0x6E,0x6F,0x69,0x73,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20, + 0x44,0x50,0x43,0x4D,0x2E,0x00,0x53,0x51,0x55,0x30,0x00,0x53,0x51,0x55,0x31,0x00,0x54,0x52,0x49,0x00,0x4E,0x53,0x45,0x00,0x44,0x50,0x43,0x4D,0x00,0x56,0x4F,0x4C, + 0x55,0x4D,0x45,0x00,0x56,0x6F,0x6C,0x75,0x6D,0x65,0x00,0x53,0x41,0x4D,0x50,0x4C,0x45,0x52,0x41,0x54,0x45,0x00,0x53,0x61,0x6D,0x70,0x6C,0x65,0x72,0x61,0x74,0x65, + 0x00,0x53,0x54,0x45,0x52,0x45,0x4F,0x00,0x53,0x74,0x65,0x72,0x65,0x6F,0x00,0x54,0x49,0x54,0x4C,0x45,0x5F,0x46,0x4F,0x52,0x4D,0x41,0x54,0x00,0x4E,0x53,0x46,0x20, + 0x73,0x6F,0x6E,0x67,0x20,0x74,0x69,0x74,0x6C,0x65,0x20,0x66,0x6F,0x72,0x6D,0x61,0x74,0x00,0x4C,0x4F,0x43,0x41,0x4C,0x45,0x00,0x53,0x51,0x55,0x30,0x4F,0x4E,0x00, + 0x53,0x51,0x55,0x31,0x4F,0x4E,0x00,0x54,0x52,0x49,0x4F,0x4E,0x00,0x4E,0x53,0x45,0x4F,0x4E,0x00,0x44,0x50,0x43,0x4D,0x4F,0x4E,0x00,0x53,0x6F,0x6E,0x67,0x20,0x63, + 0x6F,0x75,0x6E,0x74,0x00,0x4C,0x4F,0x4E,0x47,0x00,0x54,0x49,0x54,0x4C,0x45,0x00,0x49,0x4E,0x46,0x4F,0x00,0x42,0x4C,0x4F,0x42,0x00,0x49,0x4E,0x54,0x00,0x53,0x6F, + 0x6E,0x67,0x20,0x74,0x65,0x73,0x74,0x00,0x53,0x6F,0x6E,0x67,0x20,0x74,0x69,0x74,0x6C,0x65,0x00,0x54,0x65,0x73,0x74,0x20,0x54,0x65,0x78,0x74,0x00,0x67,0x6F,0x6F, + 0x64,0x62,0x79,0x65,0x00,0x49,0x6E,0x76,0x61,0x6C,0x69,0x64,0x20,0x73,0x65,0x74,0x74,0x69,0x6E,0x67,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x53,0x45,0x54,0x5F,0x49, + 0x4E,0x56,0x41,0x4C,0x49,0x44,0x00,0x57,0x72,0x6F,0x6E,0x67,0x20,0x73,0x65,0x74,0x74,0x69,0x6E,0x67,0x20,0x74,0x79,0x70,0x65,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F, + 0x53,0x45,0x54,0x5F,0x54,0x59,0x50,0x45,0x00,0x53,0x65,0x74,0x74,0x69,0x6E,0x67,0x20,0x6F,0x75,0x74,0x20,0x6F,0x66,0x20,0x72,0x61,0x6E,0x67,0x65,0x3A,0x20,0x25, + 0x64,0x20,0x28,0x25,0x64,0x2D,0x25,0x64,0x29,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x53,0x45,0x54,0x49,0x4E,0x54,0x5F,0x52,0x41,0x4E,0x47,0x45,0x00,0x49,0x4E,0x49, + 0x20,0x6C,0x69,0x6E,0x65,0x20,0x25,0x64,0x20,0x6D,0x69,0x73,0x73,0x69,0x6E,0x67,0x20,0x27,0x3D,0x27,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x4E, + 0x4F,0x5F,0x45,0x51,0x55,0x41,0x4C,0x53,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65,0x20,0x25,0x64,0x20,0x75,0x6E,0x6B,0x6E,0x6F,0x77,0x6E,0x20,0x73,0x65,0x74, + 0x74,0x69,0x6E,0x67,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x42,0x41,0x44,0x5F,0x4B,0x45,0x59,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65,0x20, + 0x25,0x64,0x20,0x62,0x61,0x64,0x20,0x69,0x6E,0x74,0x65,0x67,0x65,0x72,0x20,0x76,0x61,0x6C,0x75,0x65,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x42, + 0x41,0x44,0x5F,0x49,0x4E,0x54,0x00,0x49,0x4E,0x49,0x20,0x6C,0x69,0x6E,0x65,0x20,0x25,0x64,0x20,0x73,0x65,0x74,0x74,0x69,0x6E,0x67,0x20,0x6F,0x75,0x74,0x20,0x6F, + 0x66,0x20,0x72,0x61,0x6E,0x67,0x65,0x3A,0x20,0x25,0x64,0x20,0x28,0x25,0x64,0x2D,0x25,0x64,0x29,0x00,0x45,0x52,0x52,0x4F,0x52,0x5F,0x49,0x4E,0x49,0x5F,0x42,0x41, + 0x44,0x5F,0x52,0x41,0x4E,0x47,0x45,0x00, }; // end of file diff --git a/core/nsfplaycore.cpp b/core/nsfplaycore.cpp index 70f12c1..de2ed62 100644 --- a/core/nsfplaycore.cpp +++ b/core/nsfplaycore.cpp @@ -71,74 +71,64 @@ const char* nsfplay_ini_line(const NSFCore* core, int32_t setenum) bool nsfplay_set_int(NSFCore* core, int32_t setenum, int32_t value) { - (void)core; - (void)setenum; - (void)value; - return false; + bool result = core->set_int(setenum,value); + core->set_apply(); + return result; } bool nsfplay_set_str(NSFCore* core, int32_t setenum, const char* value) { - (void)core; - (void)setenum; - (void)value; - return false; + bool result = core->set_str(setenum,value); + core->set_apply(); + return result; } int32_t nsfplay_get_int(const NSFCore* core, int32_t setenum) { - (void)core; - (void)setenum; - return 0; + return core->get_int(setenum); } const char* nsfplay_get_str(const NSFCore* core, int32_t setenum) { - (void)core; - (void)setenum; - return NULL; + return core->get_str(setenum); } bool nsfplay_set_key_int(NSFCore* core, const char* key, int32_t value) { - (void)core; - (void)key; - (void)value; - return false; + sint32 setenum = core->set_enum(key); + bool result = core->set_int(setenum,value); + core->set_apply(); + return result; } bool nsfplay_set_key_str(NSFCore* core, const char* key, const char* value) { - (void)core; - (void)key; - (void)value; - return false; + sint32 setenum = core->set_enum(key); + bool result = core->set_str(setenum,value); + core->set_apply(); + return result; } int32_t nsfplay_get_key_int(const NSFCore* core, const char* key) { - (void)core; - (void)key; - return 0; + sint32 setenum = core->set_enum(key); + return core->get_int(setenum); } const char* nsfplay_get_key_str(const NSFCore* core, const char* key) { - (void)core; - (void)key; - return NULL; + sint32 setenum = core->set_enum(key); + return core->get_str(setenum); } -NSFSetInfo nsfplay_set_info(int32_t setenum) +NSFSetInfo nsfplay_set_info(const NSFCore* core, int32_t setenum) { - (void)setenum; - return {}; + return core->set_info(setenum); } -NSFSetGroupInfo nsfplay_set_group_info(int32_t group) +NSFSetGroupInfo nsfplay_set_group_info(const NSFCore* core, int32_t group) { - (void)group; - return {}; + return core->group_info(group); } int32_t nsfplay_set_enum(const char* key) @@ -156,6 +146,7 @@ bool nsfplay_load(NSFCore* core, const void* nsf_data, uint32_t nsf_size) (void)core; (void)nsf_data; (void)nsf_size; + // TODO return false; } @@ -164,12 +155,14 @@ bool nsfplay_assume(NSFCore* core, const void* nsf_data, uint32_t nsf_size) (void)core; (void)nsf_data; (void)nsf_size; + // TODO return false; } uint32_t nsfplay_song_count(const NSFCore* core) { (void)core; + // TODO return 0; } @@ -177,23 +170,27 @@ bool nsfplay_song(NSFCore* core, uint8_t song) { (void)core; (void)song; + // TODO return false; } void nsfplay_song_play(NSFCore* core) { (void)core; + // TODO } void nsfplay_seek(NSFCore* core, uint64_t samples) { (void)core; (void)samples; + // TODO } uint64_t nsfplay_samples_played(const NSFCore* core) { (void)core; + // TODO return 0; } @@ -202,6 +199,7 @@ uint32_t nsfplay_render(NSFCore* core, uint32_t samples, int16_t* stereo_output) (void)core; (void)samples; (void)stereo_output; + // TODO return 0; } @@ -209,6 +207,7 @@ uint8_t nsfplay_emu_peek(const NSFCore* core, uint16_t address) { (void)core; (void)address; + // TODO return 0; } @@ -216,6 +215,7 @@ uint8_t nsfplay_emu_read(NSFCore* core, uint16_t address) { (void)core; (void)address; + // TODO return 0; } @@ -224,6 +224,7 @@ void nsfplay_emu_poke(NSFCore* core, uint16_t address, uint8_t value) (void)core; (void)address; (void)value; + // TODO } void nsfplay_emu_reg_set(NSFCore* core, char reg, uint16_t value) @@ -231,12 +232,14 @@ void nsfplay_emu_reg_set(NSFCore* core, char reg, uint16_t value) (void)core; (void)reg; (void)value; + // TODO } uint16_t nsfplay_emu_reg_get(const NSFCore* core, char reg) { (void)core; (void)reg; + // TODO return 0; } @@ -244,67 +247,95 @@ void nsfplay_emu_init(NSFCore* core, uint8_t song) { (void)core; (void)song; + // TODO } void nsfplay_emu_run(NSFCore* core, uint32_t cycles) { (void)core; (void)cycles; + // TODO } uint32_t nsfplay_emu_run_frame(NSFCore* core) { (void)core; + // TODO return 0; } uint32_t nsfplay_emu_run_instruction(NSFCore* core) { (void)core; + // TODO return 0; } const char* nsfplay_emu_trace(const NSFCore* core) { (void)core; + // TODO return NULL; } uint32_t nsfplay_emu_samples_pending(const NSFCore* core) { (void)core; + // TODO return 0; } void nsfplay_emu_cancel_pending(NSFCore* core) { (void)core; + // TODO } uint64_t nsfplay_emu_cycles(const NSFCore* core) { (void)core; + // TODO return 0; } uint32_t nsfplay_emu_cycles_to_next_sample(const NSFCore* core) { (void)core; + // TODO return 0; } +bool nsfplay_prop_exists(const NSFCore* core, int32_t prop) +{ + (void)core; + (void)prop; + // TODO + return false; +} + +bool nsfplay_songprop_exists(const NSFCore* core, int32_t song, int32_t prop) +{ + (void)core; + (void)song; + (void)prop; + // TODO + return false; +} + NSFPropInfo nsfplay_prop_info(const NSFCore* core, int32_t prop) { (void)core; (void)prop; + // TODO return {}; } -NSFPropInfo nsfplay_prop_song_info(const NSFCore* core, int32_t song, int32_t prop) +NSFPropInfo nsfplay_songprop_info(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return {}; } @@ -312,6 +343,7 @@ int32_t nsfplay_prop_int(const NSFCore* core, int32_t prop) { (void)core; (void)prop; + // TODO return 0; } @@ -319,6 +351,7 @@ int64_t nsfplay_prop_long(const NSFCore* core, int32_t prop) { (void)core; (void)prop; + // TODO return 0; } @@ -326,6 +359,7 @@ const char* nsfplay_prop_str(const NSFCore* core, int32_t prop) { (void)core; (void)prop; + // TODO return NULL; } @@ -333,12 +367,14 @@ int32_t nsfplay_prop_lines(const NSFCore* core, int32_t prop) { (void)core; (void)prop; + // TODO return 0; } const char* nsfplay_prop_line(const NSFCore* core) { (void)core; + // TODO return NULL; } @@ -346,54 +382,61 @@ const void* nsfplay_prop_blob(const NSFCore* core, uint32_t* blob_size) { (void)core; (void)blob_size; + // TODO return NULL; } -int32_t nsfplay_prop_song_type(const NSFCore* core, int32_t song, int32_t prop) +int32_t nsfplay_songprop_type(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return 0; } -int32_t nsfplay_prop_song_int(const NSFCore* core, int32_t song, int32_t prop) +int32_t nsfplay_songprop_int(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return 0; } -int64_t nsfplay_prop_song_long(const NSFCore* core, int32_t song, int32_t prop) +int64_t nsfplay_songprop_long(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return 0; } -const char* nsfplay_prop_song_str(const NSFCore* core, int32_t song, int32_t prop) +const char* nsfplay_songprop_str(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return NULL; } -int32_t nsfplay_prop_song_lines(const NSFCore* core, int32_t song, int32_t prop) +int32_t nsfplay_songprop_lines(const NSFCore* core, int32_t song, int32_t prop) { (void)core; (void)song; (void)prop; + // TODO return 0; } -const void* nsfplay_prop_song_blob(const NSFCore* core, int32_t song, uint32_t* blob_size) +const void* nsfplay_songprop_blob(const NSFCore* core, int32_t song, uint32_t* blob_size) { (void)core; (void)song; (void)blob_size; + // TODO return NULL; } @@ -402,6 +445,7 @@ const void* nsfplay_chunk(const NSFCore* core, const char* fourcc, uint32_t* chu (void)core; (void)fourcc; (void)chunk_size; + // TODO return NULL; } @@ -409,18 +453,21 @@ NSFChannelUnit nsfplay_channel_unit(const NSFCore* core, int32_t unit) { (void)core; (void)unit; + // TODO return {}; } NSFChannelInfo nsfplay_channel_info(int32_t global_channel) { (void)global_channel; + // TODO return {}; } int32_t nsfplay_channel_count(const NSFCore* core) { (void)core; + // TODO return 0; } @@ -428,6 +475,7 @@ NSFChannelState nsfplay_channel_state(const NSFCore* core, int32_t active_channe { (void)core; (void)active_channel; + // TODO return {}; } @@ -437,6 +485,7 @@ uint32_t nsfplay_channel_state_ex(const NSFCore* core, int32_t active_channel, v (void)active_channel; (void)data; (void)data_size; + // TODO return 0; } @@ -447,6 +496,7 @@ uint64_t nsfplay_time_to_samples(const NSFCore* core, int32_t hours, int32_t min (void)minutes; (void)seconds; (void)milliseconds; + // TODO return 0; } @@ -457,6 +507,7 @@ uint64_t nsfplay_time_to_cycles(const NSFCore* core, int32_t hours, int32_t minu (void)minutes; (void)seconds; (void)milliseconds; + // TODO return 0; } @@ -468,6 +519,7 @@ void nsfplay_samples_to_time(const NSFCore* core, uint64_t samples, int32_t* hou (void)minutes; (void)seconds; (void)milliseconds; + // TODO } void nsfplay_cycles_to_time(const NSFCore* core, uint64_t cycles, int32_t* hours, int32_t* minutes, int32_t* seconds, int32_t* milliseconds) @@ -478,10 +530,10 @@ void nsfplay_cycles_to_time(const NSFCore* core, uint64_t cycles, int32_t* hours (void)minutes; (void)seconds; (void)milliseconds; + // TODO } -const char* nsfplay_local_text(int32_t key) +const char* nsfplay_local_text(const NSFCore* core, int32_t textenum) { - (void)key; - return NULL; + return core->local_text(textenum); } diff --git a/enums/nsfplayenums.py b/enums/nsfplayenums.py index b603493..657af03 100644 --- a/enums/nsfplayenums.py +++ b/enums/nsfplayenums.py @@ -105,6 +105,7 @@ INPUT_FOLDER = "." OUTPUT_ENUM = "../include/nsfplayenums.h" OUTPUT_DATA = "../core/enums_data.h" +TEXT0 = "" VERIFY = False STRICT = False @@ -562,6 +563,8 @@ def generate_enums(file_enum,file_data,do_write): # defs_local: key, name, list, group, set, prop, songprop, unit, channel, channelset,text # table_locale = [[] for i in range(locs)] + for i in range(locs): # add default 0 text to all locales + table_locale[i].append(gen_text(TEXT0)) # # generate list data # @@ -605,7 +608,7 @@ def generate_enums(file_enum,file_data,do_write): local_list += names[i][j] + "\0" table_locale[i].append(gen_text(local_list)) gen_break(0) - gen_line("const int32_t NSFPD_LIST[NSFP_LIST_COUNT] = {",1) + gen_line("const int32_t NSFPD_LIST_TEXT[NSFP_LIST_COUNT] = {",1) gen_data(table_list,mode=2) gen_line("};",1) gen_break(1) @@ -843,10 +846,9 @@ def generate_enums(file_enum,file_data,do_write): # generate extra text # gen_enum("NSFP_TEXT_COUNT",len(defs_local[0][10])) - gen_enum("NSFP_TEXT_INDEX",len(table_locale[0])) for ti in range(len(defs_local[0][10])): text_key = defs_local[0][10][ti][0] - gen_enum("NSFP_"+text_key,ti) + gen_enum("NSFP_"+text_key,len(table_locale[0])) names = [text_key for i in range(locs)] for i in range(locs): name = None @@ -887,6 +889,9 @@ def generate_enums(file_enum,file_data,do_write): gen_data(gen_text_blob,mode=0) gen_line("};",1) gen_break(1); + for i in range(1,locs): + if (len(table_locale[i]) != len(table_locale[0])): + error("Internal error? LOCAL(%s) has mismatched count: %d != %d" % (defs_local[i][0],len(table_locale[i]),len(table_locale[0]))) # # save the data # diff --git a/include/nsfplaycore.h b/include/nsfplaycore.h index 0f50c32..bcbc625 100644 --- a/include/nsfplaycore.h +++ b/include/nsfplaycore.h @@ -114,7 +114,7 @@ typedef struct int32_t group; const char* key; // ini text key const char* name; // localized name, according to current language setting - const char* description; // localized description, according to current language setting + const char* desc; // localized description, according to current language setting bool is_string; int32_t default_int; // 0 if is_string int32_t min_int; @@ -127,11 +127,11 @@ typedef struct { const char* key; // not used by ini, but does give a non-localized permanent string key for this group const char* name; // localized name - const char* description; // localized description + const char* desc; // localized description } NSFSetGroupInfo; -NSFSetInfo nsfplay_set_info(int32_t setenum); -NSFSetGroupInfo nsfplay_set_group_info(int32_t group); +NSFSetInfo nsfplay_set_info(const NSFCore* core, int32_t setenum); +NSFSetGroupInfo nsfplay_set_group_info(const NSFCore* core, int32_t group); int32_t nsfplay_set_enum(const char* key); // -1 if not found int32_t nsfplay_group_enum(const char* key); // -1 if not found @@ -196,8 +196,10 @@ typedef struct int32_t type; } NSFPropInfo; +bool nsfplay_prop_exists(const NSFCore* core, int32_t prop); +bool nsfplay_songprop_exists(const NSFCore* core, int32_t song, int32_t prop); NSFPropInfo nsfplay_prop_info(const NSFCore* core, int32_t prop); // type will be INVALID if not present -NSFPropInfo nsfplay_prop_song_info(const NSFCore* core, int32_t song, int32_t prop); +NSFPropInfo nsfplay_songprop_info(const NSFCore* core, int32_t song, int32_t prop); int32_t nsfplay_prop_int(const NSFCore* core, int32_t prop); int64_t nsfplay_prop_long(const NSFCore* core, int32_t prop); @@ -206,12 +208,12 @@ int32_t nsfplay_prop_lines(const NSFCore* core, int32_t prop); // returns line c const char* nsfplay_prop_line(const NSFCore* core); // returns next line (NULL if no more lines) const void* nsfplay_prop_blob(const NSFCore* core, uint32_t* blob_size); // blob_size written if not NULL -int32_t nsfplay_prop_song_type(const NSFCore* core, int32_t song, int32_t prop); -int32_t nsfplay_prop_song_int(const NSFCore* core, int32_t song, int32_t prop); -int64_t nsfplay_prop_song_long(const NSFCore* core, int32_t song, int32_t prop); -const char* nsfplay_prop_song_str(const NSFCore* core, int32_t song, int32_t prop); -int32_t nsfplay_prop_song_lines(const NSFCore* core, int32_t song, int32_t prop); // prepares nsfplay_prop_line -const void* nsfplay_prop_song_blob(const NSFCore* core, int32_t song, uint32_t* blob_size); +int32_t nsfplay_songprop_type(const NSFCore* core, int32_t song, int32_t prop); +int32_t nsfplay_songprop_int(const NSFCore* core, int32_t song, int32_t prop); +int64_t nsfplay_songprop_long(const NSFCore* core, int32_t song, int32_t prop); +const char* nsfplay_songprop_str(const NSFCore* core, int32_t song, int32_t prop); +int32_t nsfplay_songprop_lines(const NSFCore* core, int32_t song, int32_t prop); // prepares nsfplay_prop_line +const void* nsfplay_songprop_blob(const NSFCore* core, int32_t song, uint32_t* blob_size); // NSFe or NSF2 chunks can be fetched for manual inspection // - fourcc does not need a terminating 0, only the first 4 characters will be used @@ -266,7 +268,7 @@ void nsfplay_cycles_to_time(const NSFCore* core, uint64_t cycles, int32_t* hours // other text strings adapted for the current locale, see: NSFP_TEXT_key // - the returned string pointer is static and has permanent lifetime -const char* nsfplay_local_text(const NSFCore* core, int32_t key); +const char* nsfplay_local_text(const NSFCore* core, int32_t textenum); } // extern "C" diff --git a/include/nsfplayenums.h b/include/nsfplayenums.h index c481e75..9726bb0 100644 --- a/include/nsfplayenums.h +++ b/include/nsfplayenums.h @@ -1,6 +1,6 @@ #pragma once // generated by nsfplayenums.py -// 2024-04-21 23:47:22 +// 2024-04-22 00:45:03 #define NSFP_LIST_COUNT 2 #define NSFP_LIST_ENABLE 0 @@ -61,15 +61,14 @@ #define NSFP_SONGPROP_BLOB 5 #define NSFP_TEXT_COUNT 8 -#define NSFP_TEXT_INDEX 64 -#define NSFP_TEXT_TEXT 0 -#define NSFP_ERROR_SET_INVALID 1 -#define NSFP_ERROR_SET_TYPE 2 -#define NSFP_ERROR_SETINT_RANGE 3 -#define NSFP_ERROR_INI_NO_EQUALS 4 -#define NSFP_ERROR_INI_BAD_KEY 5 -#define NSFP_ERROR_INI_BAD_INT 6 -#define NSFP_ERROR_INI_BAD_RANGE 7 +#define NSFP_TEXT_TEXT 65 +#define NSFP_ERROR_SET_INVALID 66 +#define NSFP_ERROR_SET_TYPE 67 +#define NSFP_ERROR_SETINT_RANGE 68 +#define NSFP_ERROR_INI_NO_EQUALS 69 +#define NSFP_ERROR_INI_BAD_KEY 70 +#define NSFP_ERROR_INI_BAD_INT 71 +#define NSFP_ERROR_INI_BAD_RANGE 72 #define NSFP_LOCALE_COUNT 2 #define NSFP_LOCALE_ENGLISH 0