diff --git a/skeleton/BASE/Shaders/real-gameboy.cfg b/skeleton/BASE/Shaders/real-gameboy.cfg index 7bdac9a3f..0e3fbc33c 100644 --- a/skeleton/BASE/Shaders/real-gameboy.cfg +++ b/skeleton/BASE/Shaders/real-gameboy.cfg @@ -10,6 +10,7 @@ minarch_shader2_srctype = source minarch_shader2_scaletype = source minarch_shader2_upscale = screen minarch_scale_filter = NEAREST +gambatte_gb_internal_palette = TWB64 - Pack 2 gambatte_gb_palette_twb64_2 = TWB64 163 - Classic LCD gambatte_gb_colorization = internal gambatte_gbc_color_correction = always diff --git a/workspace/all/minarch/minarch.c b/workspace/all/minarch/minarch.c index 5c99c3645..d13fb10f6 100644 --- a/workspace/all/minarch/minarch.c +++ b/workspace/all/minarch/minarch.c @@ -1858,7 +1858,7 @@ static void Config_syncFrontend(char* key, int value) { option->value = value; } -char** list_files_in_folder(const char* folderPath, int* fileCount) { +char** list_files_in_folder(const char* folderPath, int* fileCount, const char* extensionFilter) { DIR* dir = opendir(folderPath); if (!dir) { perror("opendir"); @@ -1875,10 +1875,16 @@ char** list_files_in_folder(const char* folderPath, int* fileCount) { snprintf(fullPath, sizeof(fullPath), "%s/%s", folderPath, entry->d_name); if (stat(fullPath, &fileStat) == 0 && S_ISREG(fileStat.st_mode)) { - char** temp = realloc(fileList, sizeof(char*) * (*fileCount + 2)); // +1 for new file, +1 for NULL + if (extensionFilter) { + const char* ext = strrchr(entry->d_name, '.'); + if (!ext || strcmp(ext, extensionFilter) != 0) { + continue; + } + } + + char** temp = realloc(fileList, sizeof(char*) * (*fileCount + 2)); if (!temp) { perror("realloc"); - // free previously allocated strings for (int i = 0; i < *fileCount; ++i) { free(fileList[i]); } @@ -1888,14 +1894,14 @@ char** list_files_in_folder(const char* folderPath, int* fileCount) { } fileList = temp; fileList[*fileCount] = strdup(entry->d_name); - fileList[*fileCount + 1] = NULL; // maintain NULL-termination + fileList[*fileCount + 1] = NULL; (*fileCount)++; } } closedir(dir); - // Inline alphabetical sort + // Alphabetical sort for (int i = 0; i < *fileCount - 1; ++i) { for (int j = i + 1; j < *fileCount; ++j) { if (strcmp(fileList[i], fileList[j]) > 0) { @@ -1990,9 +1996,9 @@ static void Config_init(void) { // populate shader options int filecount; - char** filelist = list_files_in_folder(SHADERS_FOLDER "/glsl", &filecount); + char** filelist = list_files_in_folder(SHADERS_FOLDER "/glsl", &filecount,NULL); int preset_filecount; - char** preset_filelist = list_files_in_folder(SHADERS_FOLDER, &preset_filecount); + char** preset_filelist = list_files_in_folder(SHADERS_FOLDER, &preset_filecount,".cfg"); config.shaders.options[SH_SHADER1].values = filelist; config.shaders.options[SH_SHADER2].values = filelist; @@ -2011,7 +2017,7 @@ static void Config_init(void) { char overlaypath[255]; snprintf(overlaypath, sizeof(overlaypath), "%s/%s", OVERLAYS_FOLDER, core.tag); - char** overlaylist = list_files_in_folder(overlaypath, &filecount); + char** overlaylist = list_files_in_folder(overlaypath, &filecount,NULL); if (overlaylist) { int newcount = filecount + 1; @@ -5321,7 +5327,7 @@ static int OptionShaders_openMenu(MenuList* list, int i) { int filecount; - char** filelist = list_files_in_folder(SHADERS_FOLDER "/glsl", &filecount); + char** filelist = list_files_in_folder(SHADERS_FOLDER "/glsl", &filecount,NULL); // Check if folder read failed or no files found if (!filelist || filecount == 0) { diff --git a/workspace/macos/platform/platform.c b/workspace/macos/platform/platform.c index 0e0ee123c..a934daa60 100644 --- a/workspace/macos/platform/platform.c +++ b/workspace/macos/platform/platform.c @@ -401,6 +401,7 @@ static char* overlay_path = NULL; GLuint link_program(GLuint vertex_shader, GLuint fragment_shader, const char* cache_key) { char cache_path[512]; snprintf(cache_path, sizeof(cache_path), "/mnt/SDCARD/.shadercache/%s.bin", cache_key); + GLuint program = glCreateProgram(); GLint success; @@ -496,7 +497,7 @@ char* load_shader_source(const char* filename) { GLuint load_shader_from_file(GLenum type, const char* filename, const char* path) { char filepath[256]; - snprintf(filepath, sizeof(filepath), "%s/glsl/%s", path,filename); + snprintf(filepath, sizeof(filepath), "%s/%s", path,filename); char* source = load_shader_source(filepath); if (!source) return 0; @@ -807,8 +808,8 @@ void PLAT_updateShader(int i, const char *filename, int *scale, int *filter, int if (filename != NULL) { SDL_GL_MakeCurrent(vid.window, vid.gl_context); LOG_info("loading shader \n"); - GLuint vertex_shader1 = load_shader_from_file(GL_VERTEX_SHADER, filename,SHADERS_FOLDER); - GLuint fragment_shader1 = load_shader_from_file(GL_FRAGMENT_SHADER, filename,SHADERS_FOLDER); + GLuint vertex_shader1 = load_shader_from_file(GL_VERTEX_SHADER, filename,SHADERS_FOLDER "/glsl"); + GLuint fragment_shader1 = load_shader_from_file(GL_FRAGMENT_SHADER, filename,SHADERS_FOLDER "/glsl"); // Link the shader program if (shader->shader_p != 0) { diff --git a/workspace/tg5040/platform/platform.c b/workspace/tg5040/platform/platform.c index 338169e7f..806309543 100644 --- a/workspace/tg5040/platform/platform.c +++ b/workspace/tg5040/platform/platform.c @@ -211,7 +211,7 @@ char* load_shader_source(const char* filename) { GLuint load_shader_from_file(GLenum type, const char* filename, const char* path) { char filepath[256]; - snprintf(filepath, sizeof(filepath), "%s/glsl/%s", path,filename); + snprintf(filepath, sizeof(filepath), "%s/%s", path,filename); char* source = load_shader_source(filepath); if (!source) return 0; @@ -522,8 +522,8 @@ void PLAT_updateShader(int i, const char *filename, int *scale, int *filter, int if (filename != NULL) { SDL_GL_MakeCurrent(vid.window, vid.gl_context); LOG_info("loading shader \n"); - GLuint vertex_shader1 = load_shader_from_file(GL_VERTEX_SHADER, filename,SHADERS_FOLDER); - GLuint fragment_shader1 = load_shader_from_file(GL_FRAGMENT_SHADER, filename,SHADERS_FOLDER); + GLuint vertex_shader1 = load_shader_from_file(GL_VERTEX_SHADER, filename,SHADERS_FOLDER "/glsl"); + GLuint fragment_shader1 = load_shader_from_file(GL_FRAGMENT_SHADER, filename,SHADERS_FOLDER "/glsl"); // Link the shader program if (shader->shader_p != 0) {