From ab54161b8d450a77024484d76fbf2c249ee8b65d Mon Sep 17 00:00:00 2001 From: Dagen Brock Date: Mon, 26 Mar 2018 23:31:40 -0500 Subject: [PATCH] cleanup and fixup and full options --- src/adb.c | 9 ++- src/config.c | 70 ++++++++++++++++-- src/config.h | 12 ++-- src/iwm.c | 25 +++---- src/joystick_driver.c | 163 +++++++++++++++++++++++++----------------- src/moremem.c | 6 -- src/options.c | 110 ++++++++++++++++++++++++++-- src/sound.c | 14 ++-- 8 files changed, 290 insertions(+), 119 deletions(-) diff --git a/src/adb.c b/src/adb.c index 6c47a4e..c9dc784 100644 --- a/src/adb.c +++ b/src/adb.c @@ -1691,10 +1691,6 @@ adb_physical_key_update(int a2code, int is_up) a2code = 0x3a; special = 0; break; - case 0x03: /* F3 - remap to escape for OS/2 */ - a2code = 0x35; - special = 0; - break; case 0x0c: /* F12 - remap to reset */ a2code = 0x7f; special = 0; @@ -1719,6 +1715,9 @@ adb_physical_key_update(int a2code, int is_up) if(special && !is_up) { switch(special) { + case 0x03: /* F3 - screenshot */ + g_screenshot_requested = 1; + break; case 0x04: /* F4 - emulator config panel */ if (CMD_DOWN) { glog("Quit!"); @@ -1732,7 +1731,7 @@ adb_physical_key_update(int a2code, int is_up) break; case 0x05: /* F5 - emulator clipboard paste */ if (SHIFT_DOWN) { - g_screenshot_requested = 1; + // reserved } else { clipboard_paste(); } diff --git a/src/config.c b/src/config.c index 991aa92..eac2e34 100644 --- a/src/config.c +++ b/src/config.c @@ -48,6 +48,33 @@ extern int g_fatal_log; extern word32 g_adb_repeat_vbl; +extern int g_audio_enable; +extern int g_preferred_rate; +extern int g_fullscreen; +extern int g_highdpi; +extern int g_borderless; +extern int g_resizeable; +extern int g_screen_redraw_skip_amt; +extern int g_use_dhr140; +extern int g_use_bw_hires; +extern int g_scanline_simulator; +extern int g_startx; +extern int g_starty; +extern int g_joystick_number; +extern int g_joystick_x_axis; +extern int g_joystick_y_axis; +extern int g_joystick_x2_axis; +extern int g_joystick_y2_axis; +extern int g_joystick_button_0; +extern int g_joystick_button_1; +extern int g_joystick_button_2; +extern int g_joystick_button_3; +extern int g_ethernet; +extern int g_halt_on_bad_read; +extern int g_ignore_bad_acc; +extern int g_ignore_halts; +extern int g_dbg_enable_port; + extern int halt_sim; extern int g_limit_speed; extern int g_force_depth; @@ -168,6 +195,37 @@ extern Cfg_menu g_cfg_main_menu[]; #define KNMP(a) &a, #a, 0 +// This first menu is not a menu, but a list of config options that are +// represented here so they will be parsed correctly out of the config files. +Cfg_menu g_cfg_uiless_menu[] = { + { "", KNMP(g_audio_enable), CFGTYPE_INT }, + { "", KNMP(g_preferred_rate), CFGTYPE_INT }, + { "", KNMP(g_fullscreen), CFGTYPE_INT }, + { "", KNMP(g_highdpi), CFGTYPE_INT }, + { "", KNMP(g_borderless), CFGTYPE_INT }, + { "", KNMP(g_resizeable), CFGTYPE_INT }, + { "", KNMP(g_screen_redraw_skip_amt), CFGTYPE_INT }, + { "", KNMP(g_use_dhr140), CFGTYPE_INT }, + { "", KNMP(g_use_bw_hires), CFGTYPE_INT }, + { "", KNMP(g_scanline_simulator), CFGTYPE_INT }, + { "", KNMP(g_startx), CFGTYPE_INT }, + { "", KNMP(g_starty), CFGTYPE_INT }, + { "", KNMP(g_joystick_number), CFGTYPE_INT }, + { "", KNMP(g_joystick_x_axis), CFGTYPE_INT }, + { "", KNMP(g_joystick_y_axis), CFGTYPE_INT }, + { "", KNMP(g_joystick_x2_axis), CFGTYPE_INT }, + { "", KNMP(g_joystick_y2_axis), CFGTYPE_INT }, + { "", KNMP(g_joystick_button_0), CFGTYPE_INT }, + { "", KNMP(g_joystick_button_1), CFGTYPE_INT }, + { "", KNMP(g_joystick_button_2), CFGTYPE_INT }, + { "", KNMP(g_joystick_button_3), CFGTYPE_INT }, + { "", KNMP(g_ethernet), CFGTYPE_INT }, + { "", KNMP(g_halt_on_bad_read), CFGTYPE_INT }, + { "", KNMP(g_ignore_bad_acc), CFGTYPE_INT }, + { "", KNMP(g_ignore_halts), CFGTYPE_INT } +}; + + Cfg_menu g_cfg_disk_menu[] = { { "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU }, { "s5d1 = ", 0, 0, 0, CFGTYPE_DISK + 0x5000 }, @@ -389,10 +447,8 @@ Cfg_menu g_cfg_main_menu[] = { { "Virtual ImageWriter Configuration", g_cfg_imagewriter_menu, 0, 0, CFGTYPE_MENU }, #endif { "Developer Options", g_cfg_devel_menu, 0, 0, CFGTYPE_MENU }, -{ "Auto-update configuration file,0,Manual,1,Immediately", - KNMP(g_config_gsplus_auto_update), CFGTYPE_INT }, -{ "Speed,0,Unlimited,1,1.0MHz,2,2.8MHz,3,8.0MHz (Zip)", - KNMP(g_limit_speed), CFGTYPE_INT }, +{ "Auto-update configuration file,0,Manual,1,Immediately", KNMP(g_config_gsplus_auto_update), CFGTYPE_INT }, +{ "Speed,0,Unlimited,1,1.0MHz,2,2.8MHz,3,8.0MHz (Zip)", KNMP(g_limit_speed), CFGTYPE_INT }, { "Expansion Mem Size,0,0MB,0x100000,1MB,0x200000,2MB,0x300000,3MB," "0x400000,4MB,0x600000,6MB,0x800000,8MB,0xa00000,10MB,0xc00000,12MB," "0xe00000,14MB", KNMP(g_mem_size_exp), CFGTYPE_INT }, @@ -551,6 +607,7 @@ config_init() int can_create; config_init_menus(g_cfg_main_menu); + config_init_menus(g_cfg_uiless_menu); // Find the configuration file g_config_gsplus_name[0] = 0; @@ -1037,8 +1094,7 @@ config_parse_config_gsplus_file() fconf = fopen(g_config_gsplus_name, "r"); if(fconf == 0) { perror("ERROR"); - fatal_printf("Cannot open configuration file at %s! Stopping!\n", - g_config_gsplus_name); + fatal_printf("Cannot open configuration file at %s! Stopping!\n",g_config_gsplus_name); my_exit(3); } @@ -1324,7 +1380,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size, int cmp_o, cmp_p, cmp_dot; int cmp_b, cmp_i, cmp_n; int can_write; - int len; + int len = 0; int nibs; int unix_pos; int name_len; diff --git a/src/config.h b/src/config.h index 9cbb8ae..4a1508b 100644 --- a/src/config.h +++ b/src/config.h @@ -5,16 +5,14 @@ See COPYING.txt for license (GPL v2) */ -#define CONF_BUF_LEN 1024 -#define COPY_BUF_SIZE 4096 +#define CONF_BUF_LEN 1024 +#define COPY_BUF_SIZE 4096 #define CFG_PRINTF_BUFSIZE 2048 - -#define CFG_PATH_MAX 1024 - -#define CFG_NUM_SHOWENTS 16 +#define CFG_PATH_MAX 1024 +#define CFG_NUM_SHOWENTS 16 #define CFGTYPE_MENU 1 -#define CFGTYPE_INT 2 +#define CFGTYPE_INT 2 #define CFGTYPE_DISK 3 #define CFGTYPE_FUNC 4 #define CFGTYPE_FILE 5 diff --git a/src/iwm.c b/src/iwm.c index 51345f3..7cf4a35 100644 --- a/src/iwm.c +++ b/src/iwm.c @@ -263,7 +263,7 @@ iwm_flush_disk_to_unix(Disk *dsk) return; } - printf("Writing disk %s to Unix\n", dsk->name_ptr); + glogf("Writing disk %s to Unix\n", dsk->name_ptr); dsk->disk_dirty = 0; num_dirty = 0; @@ -273,8 +273,7 @@ iwm_flush_disk_to_unix(Disk *dsk) ret = disk_track_to_unix(dsk, j, &(buffer[0])); if(ret != 1 && ret != 0) { - printf("iwm_flush_disk_to_unix ret: %d, cannot write " - "image to unix\n", ret); + glogf("iwm_flush_disk_to_unix ret: %d, cannot write image to unix\n", ret); halt_printf("Adjusting image not to write through!\n"); dsk->write_through_to_unix = 0; break; @@ -307,8 +306,7 @@ iwm_flush_disk_to_unix(Disk *dsk) ret = fwrite(&(buffer[0]), 1, unix_len, dsk->file); if(ret != unix_len) { - printf("fwrite: %08x, errno:%d, qtrk: %02x, disk: %s\n", - ret, errno, j, dsk->name_ptr); + glogf("fwrite: %08x, errno:%d, qtrk: %02x, disk: %s\n", ret, errno, j, dsk->name_ptr); } } @@ -383,17 +381,16 @@ iwm_vbl_update(int doit_3_persec) void iwm_show_stats() { - printf("IWM stats: q7,q6: %d, %d, reset,enable2: %d,%d, mode: %02x\n", + glogf("IWM stats: q7,q6: %d, %d, reset,enable2: %d,%d, mode: %02x\n", iwm.q7, iwm.q6, iwm.reset, iwm.enable2, iwm.iwm_mode); - printf("motor: %d,%d, motor35:%d drive: %d, c031:%02x " - "phs: %d %d %d %d\n", + glogf("motor: %d,%d, motor35:%d drive: %d, c031:%02x phs: %d %d %d %d\n", iwm.motor_on, iwm.motor_off, g_iwm_motor_on, iwm.drive_select, g_c031_disk35, iwm.iwm_phase[0], iwm.iwm_phase[1], iwm.iwm_phase[2], iwm.iwm_phase[3]); - printf("iwm.drive525[0].file: %p, [1].file: %p\n", + glogf("iwm.drive525[0].file: %p, [1].file: %p\n", iwm.drive525[0].file, iwm.drive525[1].file); - printf("iwm.drive525[0].last_phase: %d, [1].last_phase: %d\n", + glogf("iwm.drive525[0].last_phase: %d, [1].last_phase: %d\n", iwm.drive525[0].last_phase, iwm.drive525[1].last_phase); } @@ -574,11 +571,15 @@ iwm525_phase_change(int drive, int phase) qtr_track += delta; if(qtr_track < 0) { - printf("GRIND..."); +#if 1 + printf("💾 "); +#else + printf("GRIND..."); +#endif qtr_track = 0; } if(qtr_track > 4*34) { - printf("Disk arm moved past track 34, moving it back\n"); + glogf("Disk arm moved past track 34, moving it back\n"); qtr_track = 4*34; } diff --git a/src/joystick_driver.c b/src/joystick_driver.c index a3d6ce1..7676050 100644 --- a/src/joystick_driver.c +++ b/src/joystick_driver.c @@ -7,6 +7,7 @@ #include "defc.h" #include "glog.h" + #ifdef __linux__ # include # include @@ -25,6 +26,8 @@ SDL_Joystick *gGameController = NULL; #endif + + extern int g_joystick_native_type1; /* in paddles.c */ extern int g_joystick_native_type2; /* in paddles.c */ extern int g_joystick_native_type; /* in paddles.c */ @@ -39,6 +42,99 @@ const char *g_joystick_dev = "/dev/input/js0"; /* default joystick dev file */ int g_joystick_native_fd = -1; int g_joystick_num_axes = 0; int g_joystick_num_buttons = 0; +int g_joystick_number = 0; // SDL2 +int g_joystick_x_axis = 0; // SDL2 +int g_joystick_y_axis = 1; // SDL2 +int g_joystick_button_0 = 0; // SDL2 +int g_joystick_button_1 = 1; // SDL2 + +int g_joystick_x2_axis = 2; // SDL2 +int g_joystick_y2_axis = 3; // SDL2 +int g_joystick_button_2 = 2; // SDL2 +int g_joystick_button_3 = 3; // SDL2 +#define JOY2SUPPORT + + +#if defined(HAVE_SDL) && !defined(JOYSTICK_DEFINED) +# define JOYSTICK_DEFINED +void +joystick_init() +{ + int i; + if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) { + glogf( "SDL could not initialize joystick! SDL Error: %s", SDL_GetError() ); + } else { + glog("SDL2 joystick initialized"); + } + if (SDL_NumJoysticks()<1) { + glog("No joysticks detected"); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } else { + // @todo: make controller configurable + // @todo: add multiple controller support + gGameController = SDL_JoystickOpen( g_joystick_number ); + if( gGameController == NULL ) { + glogf( "Warning: Unable to open game controller! SDL Error: %s", SDL_GetError() ); + } + } + g_joystick_native_type = 2; + g_joystick_native_type1 = 2; + g_joystick_native_type2 = -1; + for(i = 0; i < 4; i++) { + g_paddle_val[i] = 180; + } + g_joystick_type = JOYSTICK_TYPE_NATIVE_1; + SDL_JoystickUpdate(); + joystick_update(0.0); +} + +void +joystick_update(double dcycs) +{ + if (gGameController) { + SDL_JoystickUpdate(); + g_paddle_val[0] = (int)SDL_JoystickGetAxis(gGameController, g_joystick_x_axis); // default is 0 + g_paddle_val[1] = (int)SDL_JoystickGetAxis(gGameController, g_joystick_y_axis); // default is 1 + g_paddle_val[2] = (int)SDL_JoystickGetAxis(gGameController, g_joystick_x2_axis); // default is 2 + g_paddle_val[3] = (int)SDL_JoystickGetAxis(gGameController, g_joystick_y2_axis); // default is 3 + + if (SDL_JoystickGetButton(gGameController, g_joystick_button_0)) { + g_paddle_buttons = g_paddle_buttons | 1; + } else { + g_paddle_buttons = g_paddle_buttons & (~1); + } + if (SDL_JoystickGetButton(gGameController, g_joystick_button_1)) { + g_paddle_buttons = g_paddle_buttons | 2; + } else { + g_paddle_buttons = g_paddle_buttons & (~2); + } + if (SDL_JoystickGetButton(gGameController, g_joystick_button_2)) { + g_paddle_buttons = g_paddle_buttons | 4; + } else { + g_paddle_buttons = g_paddle_buttons & (~4); + } + if (SDL_JoystickGetButton(gGameController, g_joystick_button_3)) { + g_paddle_buttons = g_paddle_buttons | 8; + } else { + g_paddle_buttons = g_paddle_buttons & (~8); + } + paddle_update_trigger_dcycs(dcycs); + } +} + +void +joystick_update_buttons() +{ +} + +void joystick_shut() { + SDL_JoystickClose( gGameController ); + gGameController = NULL; +} +#endif + + + #if defined(__linux__) && !defined(JOYSTICK_DEFINED) @@ -243,72 +339,6 @@ joystick_update_buttons() #endif -#if defined(HAVE_SDL) && !defined(JOYSTICK_DEFINED) -# define JOYSTICK_DEFINED -void -joystick_init() -{ - int i; - if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) { - glogf( "SDL could not initialize joystick! SDL Error: %s", SDL_GetError() ); - } else { - glog("SDL2 joystick initialized"); - } - if (SDL_NumJoysticks()<1) { - glog("No joysticks detected"); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } else { - // @todo: make controller configurable - // @todo: add multiple controller support - gGameController = SDL_JoystickOpen( 0 ); - if( gGameController == NULL ) { - glogf( "Warning: Unable to open game controller! SDL Error: %s", SDL_GetError() ); - } - } - g_joystick_native_type = 2; - g_joystick_native_type1 = 2; - g_joystick_native_type2 = -1; - for(i = 0; i < 4; i++) { - g_paddle_val[i] = 180; - } - g_joystick_type = JOYSTICK_TYPE_NATIVE_1; - SDL_JoystickUpdate(); - joystick_update(0.0); -} - -void -joystick_update(double dcycs) -{ - if (gGameController) { - SDL_JoystickUpdate(); - g_paddle_val[0] = (int)SDL_JoystickGetAxis(gGameController, 0); - g_paddle_val[1] = (int)SDL_JoystickGetAxis(gGameController, 1); - if (SDL_JoystickGetButton(gGameController, 0)) { - g_paddle_buttons = g_paddle_buttons | 1; - } else { - g_paddle_buttons = g_paddle_buttons & (~1); - } - if (SDL_JoystickGetButton(gGameController, 1)) { - g_paddle_buttons = g_paddle_buttons | 2; - } else { - g_paddle_buttons = g_paddle_buttons & (~2); - } - paddle_update_trigger_dcycs(dcycs); - } - -} - -void -joystick_update_buttons() -{ -} - -void joystick_shut() { - SDL_JoystickClose( gGameController ); - gGameController = NULL; -} -#endif - @@ -338,7 +368,6 @@ joystick_update_buttons() { } -// OG void joystick_shut() { } diff --git a/src/moremem.c b/src/moremem.c index 00dab68..fe0b40f 100644 --- a/src/moremem.c +++ b/src/moremem.c @@ -1231,9 +1231,6 @@ io_read(word32 loc, double *cyc_ptr) { double dcycs; word64 word64_tmp; -#if 0 - double fcyc, new_fcyc; -#endif word32 mask; int new_lcbank2; int new_wrdefram; @@ -1746,9 +1743,6 @@ void io_write(word32 loc, int val, double *cyc_ptr) { double dcycs; -#if 0 - double fcyc, new_fcyc; -#endif int new_tmp; int new_lcbank2; int new_wrdefram; diff --git a/src/options.c b/src/options.c index ab74bd5..75b863e 100644 --- a/src/options.c +++ b/src/options.c @@ -4,9 +4,11 @@ #include #include "options.h" #include "glog.h" - #include "defc.h" +// config is parsed in config.c :: config_parse_config_gsplus_file() +// cli is parsed here. would be nice to reuse some code + // Halts on bad reads. Sets flags via engine_s.s:set_halt_act() function extern int g_halt_on_bad_read; // defined in sim65816.c // Ignore bad memory accesses. @@ -44,6 +46,18 @@ extern int g_audio_enable; // defined in sound.c // Start in fullscreen mode extern int g_fullscreen; // defined in adb.c, because weird driver writing for x +// Specify the joystick - SDL2 +extern int g_joystick_number; // defined in joystick_driver.c +extern int g_joystick_x_axis; // defined in joystick_driver.c +extern int g_joystick_y_axis; // defined in joystick_driver.c +extern int g_joystick_x2_axis; // defined in joystick_driver.c +extern int g_joystick_y2_axis; // defined in joystick_driver.c +extern int g_joystick_button_0; // defined in joystick_driver.c +extern int g_joystick_button_1; // defined in joystick_driver.c +extern int g_joystick_button_2; // defined in joystick_driver.c +extern int g_joystick_button_3; // defined in joystick_driver.c + + // DEPRECATED: force bit depth (15/16/24) for X-Windows, might still work. extern int g_force_depth; // defined in sim65816.c // DEPRECATED: Use X shared memory (MIT-SHM) @@ -79,6 +93,15 @@ extern int g_cur_a2_stat; void help_exit(); // displays the cli help text and exits with 1 +int parse_int(const char *str1, int min, int max) +{ + int tmp; + tmp = strtol(str1, 0, 0); + if (tmp > max) { tmp = max; } + if (tmp < min) { tmp = min; } + printf ( "TMP %d\n", tmp); + return tmp; +} int parse_cli_options(int argc, char **argv) { int i; int tmp1; @@ -167,7 +190,86 @@ int parse_cli_options(int argc, char **argv) { glogf("%s Not using X shared memory", parse_log_prefix); g_use_shmem = 0; } else if(!strcmp("-joystick", argv[i])) { - glogf("%s Ignoring -joystick option", parse_log_prefix); + if((i+1) >= argc) { + glogf("%s Error, option '-joy' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick number %d", parse_log_prefix, tmp1); + g_joystick_number = tmp1; + i++; + } else if(!strcmp("-joy_x", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_x' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick X axis %d", parse_log_prefix, tmp1); + g_joystick_x_axis = tmp1; + i++; + } else if(!strcmp("-joy_y", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_y' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Y axis %d", parse_log_prefix, tmp1); + g_joystick_y_axis = tmp1; + i++; + } else if(!strcmp("-joy_x2", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_x2' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick X2 axis %d", parse_log_prefix, tmp1); + g_joystick_x2_axis = tmp1; + i++; + } else if(!strcmp("-joy_y2", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_y2' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Y2 axis %d", parse_log_prefix, tmp1); + g_joystick_y2_axis = tmp1; + i++; + } else if(!strcmp("-joy_b0", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_b0' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Button 0 to Gamepad %d", parse_log_prefix, tmp1); + g_joystick_button_0 = tmp1; + i++; + } else if(!strcmp("-joy_b1", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_b1' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Button 1 to Gamepad %d", parse_log_prefix, tmp1); + g_joystick_button_1 = tmp1; + i++; + } else if(!strcmp("-joy_b2", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_b2' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Button 2 to Gamepad %d", parse_log_prefix, tmp1); + g_joystick_button_2 = tmp1; + i++; + } else if(!strcmp("-joy_b3", argv[i])) { + if((i+1) >= argc) { + glogf("%s Error, option '-joy_b3' missing argument", parse_log_prefix); + exit(1); + } + tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get + glogf("%s Setting joystick Button 3 to Gamepad %d", parse_log_prefix, tmp1); + g_joystick_button_3 = tmp1; + i++; } else if(!strcmp("-dhr140", argv[i])) { glogf("%s Using simple dhires color map", parse_log_prefix); g_use_dhr140 = 1; @@ -181,9 +283,7 @@ int parse_cli_options(int argc, char **argv) { glogf("%s Error, option '-scanline' missing argument", parse_log_prefix); exit(1); } - tmp1 = strtol(argv[i+1], 0, 0); - if (tmp1 > 100) { tmp1 = 100; } - if (tmp1 < 0) { tmp1 = 0; } + tmp1 = parse_int(argv[i+1], 0, 100); glogf("%s Setting scanline simulator darkness to %d%%", parse_log_prefix, tmp1); g_scanline_simulator = tmp1; i++; diff --git a/src/sound.c b/src/sound.c index 31682e7..cd9b7d9 100644 --- a/src/sound.c +++ b/src/sound.c @@ -252,7 +252,7 @@ sound_init_general() { /* Workaround - gcc in cygwin wasn't defining _WIN32 */ -#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__OS2__) && !defined(HAVE_SDL) +#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL) int pid; int shmid; int tmp; @@ -264,7 +264,7 @@ sound_init_general() int ret; /* Workaround - gcc in cygwin wasn't defining _WIN32 */ -#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__OS2__) && !defined(HAVE_SDL) +#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL) if(!g_use_shmem) { if(g_audio_enable < 0) { printf("Defaulting audio off for slow X display\n"); @@ -282,7 +282,7 @@ sound_init_general() size = SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE; /* Workaround - gcc in cygwin wasn't defining _WIN32 */ -#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__OS2__) && !defined(HAVE_SDL) +#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL) shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); if(shmid < 0) { printf("sound_init: shmget ret: %d, errno: %d\n", shmid, errno); @@ -312,7 +312,7 @@ sound_init_general() fflush(stdout); /* Workaround - gcc in cygwin wasn't defining _WIN32 */ -#if !defined(MAC) && !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(__OS2__) && !defined(HAVE_SDL) +#if !defined(MAC) && !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(HAVE_SDL) /* prepare pipe so parent can signal child each other */ /* pipe[0] = read side, pipe[1] = write end */ ret = pipe(&g_pipe_fd[0]); @@ -368,7 +368,6 @@ sound_init_general() win32snd_init(shmaddr); # elif defined (MAC) && !defined(HAVE_SDL) macsnd_init(shmaddr); -# elif defined (__OS2__) # endif #endif @@ -377,7 +376,6 @@ sound_init_general() void parent_sound_get_sample_rate(int read_fd) { -#ifndef __OS2__ word32 tmp; int ret; @@ -390,7 +388,6 @@ parent_sound_get_sample_rate(int read_fd) close(read_fd); set_audio_rate(tmp); -#endif } void @@ -440,7 +437,6 @@ sound_shutdown() #ifdef WIN_SOUND /* Workaround - gcc in cygwin wasn't defining _WIN32 */ win32snd_shutdown(); -#elif defined(__OS2__) #elif defined(HAVE_SDL) if((g_audio_enable != 0)) { //sdlsnd_shutdown(); @@ -644,8 +640,6 @@ send_sound(int real_samps, int size) child_sound_playit(tmp); #elif defined(HAVE_SDL) sound_write_sdl( real_samps, size); -#elif defined(__OS2__) - #else /* Although this looks like a big/little-endian issue, since the */ /* child is also reading an int, it just works with no byte swap */