From: Timo Korvola Date: Wed, 28 Feb 2018 22:02:20 +0000 (+0200) Subject: Fix SDL stuff to compile. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=188adf53993611aa5658440e7b76827eb3ea5efe;p=liskon_frotz.git Fix SDL stuff to compile. Add a minimal GNU Makefile. A large part of os_process_arguments was replaced from the curses version. Other fixes were minimal. Compiles (with warnings) but haven't tried linking. --- diff --git a/src/sdl/Makefile b/src/sdl/Makefile new file mode 100644 index 0000000..68f26e0 --- /dev/null +++ b/src/sdl/Makefile @@ -0,0 +1,36 @@ +# For GNU Make. + +PKGS = sdl SDL_mixer freetype2 + +CC = gcc +CFLAGS += `pkg-config $(PKGS) --cflags` +ARFLAGS = rvU + +SOURCES = sf_aiffwav.c sf_fonts.c sf_msg_en.c sf_resource.c sf_util.c \ + sf_deffont.c sf_ftype.c sf_osfdlg.c sf_sig.c sf_video.c \ + sf_font3.c sf_images.c sf_resample.c sf_sound.c + +HEADERS = samplerate.h sf_frotz.h + +OBJECTS = $(SOURCES:.c=.o) + +DEPS = $(SOURCES:.c=.d) + +TARGET = frotz_sdl.a + +.PHONY: clean distclean +.DELETE_ON_ERROR: + +$(TARGET): $(TARGET)($(OBJECTS)) + ranlib $@ + +clean: + -rm -f $(TARGET) $(OBJECTS) + +distclean: clean + -rm -f $(DEPS) + +%.d: %.c + gcc -MM $(CFLAGS) $< > $@ + +include $(DEPS) diff --git a/src/sdl/sf_images.c b/src/sdl/sf_images.c index 18b0827..ae044b3 100644 --- a/src/sdl/sf_images.c +++ b/src/sdl/sf_images.c @@ -94,7 +94,7 @@ static int loadpng( byte *data, int length, sf_picture *graphic) return 0; } - if (setjmp(png_ptr->jmpbuf)) + if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr,&info_ptr,&end_info); if (rowPointers) free(rowPointers); diff --git a/src/sdl/sf_resource.c b/src/sdl/sf_resource.c index 856bd27..9908038 100644 --- a/src/sdl/sf_resource.c +++ b/src/sdl/sf_resource.c @@ -1030,7 +1030,6 @@ void os_init_setup(void) f_setup.undo_slots = MAX_UNDO_SLOTS; f_setup.expand_abbreviations = 0; f_setup.script_cols = 80; - f_setup.save_quetzal = 1; f_setup.sound = 1; f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE; f_setup.restore_mode = 0; diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index 383b6a3..4106923 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -124,7 +124,6 @@ static char *infos[] = { "-p alter piracy opcode", "-q quiet (disable sound)", "-r # right margin", - "-R save/restore in old Frotz format", "-s # random number seed value", "-S # transcript width", "-t set Tandy bit", @@ -257,8 +256,6 @@ static void parse_options (int argc, char **argv) f_setup.piracy = 1; if (c == 'r') f_setup.right_margin = num; - if (c == 'R') - f_setup.save_quetzal = 0; if (c == 's') m_random_seed = num; if (c == 'S') @@ -310,8 +307,8 @@ static void parse_options (int argc, char **argv) */ void os_process_arguments (int argc, char *argv[]) - { - const char *p; +{ + char *p; int i; // install signal handlers @@ -330,39 +327,65 @@ void os_process_arguments (int argc, char *argv[]) /* Set the story file name */ - story_name = argv[optind]; + f_setup.story_file = strdup(argv[optind]); // load resources // it's useless to test the retval, as in case of error it does not return - sf_load_resources( story_name); + sf_load_resources( f_setup.story_file); /* Strip path and extension off the story file name */ - p = story_name; + f_setup.story_name = strdup(basename(argv[optind])); + + /* Now strip off the extension. */ + p = strrchr(f_setup.story_name, '.'); + if ((p != NULL) && + ((strcmp(p,EXT_BLORB2) == 0) || + (strcmp(p,EXT_BLORB3) == 0) || + (strcmp(p,EXT_BLORB4) == 0) ) ) { + // blorb_ext = strdup(p); + } + else + // blorb_ext = strdup(EXT_BLORB); + + + /* Get rid of extensions with 1 to 6 character extensions. */ + /* This will take care of an extension like ".zblorb". */ + /* More than that, there might be something weird going on */ + /* which is not our concern. */ + if (p != NULL) { + if (strlen(p) >= 2 && strlen(p) <= 7) { + *p = '\0'; /* extension removed */ + } + } - for (i = 0; story_name[i] != 0; i++) - if (story_name[i] == '\\' || story_name[i] == '/' - || story_name[i] == ':') - p = story_name + i + 1; + f_setup.story_path = strdup(dirname(argv[optind])); - for (i = 0; p[i] != 0 && p[i] != '.'; i++) - stripped_story_name[i] = p[i]; + /* Create nice default file names */ - stripped_story_name[i] = 0; + f_setup.script_name = malloc((strlen(f_setup.story_name) + strlen(EXT_SCRIPT)) * sizeof(char) + 1); + strncpy(f_setup.script_name, f_setup.story_name, strlen(f_setup.story_name) + 1); + strncat(f_setup.script_name, EXT_SCRIPT, strlen(EXT_SCRIPT)); - /* Create nice default file names */ + f_setup.command_name = malloc((strlen(f_setup.story_name) + strlen(EXT_COMMAND)) * sizeof(char) + 1); + strncpy(f_setup.command_name, f_setup.story_name, strlen(f_setup.story_name) + 1); + strncat(f_setup.command_name, EXT_COMMAND, strlen(EXT_COMMAND)); - strcpy (script_name, stripped_story_name); - strcpy (command_name, stripped_story_name); - strcpy (save_name, stripped_story_name); - strcpy (auxilary_name, stripped_story_name); + if (!f_setup.restore_mode) { + f_setup.save_name = malloc(strlen(f_setup.story_name) * sizeof(char) + 5); + strncpy(f_setup.save_name, f_setup.story_name, strlen(f_setup.story_name)); + strncat(f_setup.save_name, EXT_SAVE, strlen(EXT_SAVE)); + } else { /*Set our auto load save as the name_save*/ + f_setup.save_name = malloc(strlen(f_setup.tmp_save_name) * sizeof(char) + 5); + strncpy(f_setup.save_name, f_setup.tmp_save_name, strlen(f_setup.tmp_save_name)); + free(f_setup.tmp_save_name); + } - strcat (script_name, ".scr"); - strcat (command_name, ".rec"); - strcat (save_name, ".sav"); - strcat (auxilary_name, ".aux"); + f_setup.aux_name = malloc((strlen(f_setup.story_name) + strlen(EXT_AUX)) * sizeof(char) + 1); + strncpy(f_setup.aux_name, f_setup.story_name, strlen(f_setup.story_name) + 1); + strncat(f_setup.aux_name, EXT_AUX, strlen(EXT_AUX)); - /* Save the executable file name */ + /* Save the executable file name */ progname = argv[0]; @@ -379,7 +402,7 @@ void os_process_arguments (int argc, char *argv[]) sf_initfonts(); - }/* os_process_arguments */ +}/* os_process_arguments */ #ifdef WIN32 #include