diff --git a/src/interface.c b/src/interface.c index 52c4d8bf..55c8b923 100644 --- a/src/interface.c +++ b/src/interface.c @@ -774,9 +774,6 @@ typedef enum interface_enum_t { OPT_VOLUME, OPT_JOYSTICK, OPT_CALIBRATE, - OPT_JS_RANGE, - OPT_ORIGIN_X, - OPT_ORIGIN_Y, OPT_JS_SENSE, OPT_JS_SAMPLE, OPT_SAVE, @@ -795,9 +792,6 @@ static const char *options[] = " Volume : ", " Joystick : ", " Calibrate ", - " JS Range : ", - " Origin X : ", - " Origin Y : ", " JS Sens. : ", " JS Sample: ", " Save Prefs ", @@ -926,18 +920,6 @@ void c_interface_parameters() strncpy( temp, "", TEMPSIZE ); break; - case OPT_JS_RANGE: - sprintf(temp, "%02x", joy_range); - break; - - case OPT_ORIGIN_X: - sprintf(temp, "%02x", joy_center_x); - break; - - case OPT_ORIGIN_Y: - sprintf(temp, "%02x", joy_center_y); - break; - case OPT_JS_SENSE: sprintf(temp, "%03d%%", joy_step ); break; @@ -1131,30 +1113,6 @@ void c_interface_parameters() case OPT_CALIBRATE: break; - case OPT_JS_RANGE: - if (joy_range > 10) - { - --joy_range; - joy_center_x = joy_range>>1; - joy_center_y = joy_range>>1; - half_joy_range = joy_range>>1; - } - break; - - case OPT_ORIGIN_X: - if (joy_center_x > 0) - { - joy_center_x--; - } - break; - - case OPT_ORIGIN_Y: - if (joy_center_y > 0) - { - joy_center_y--; - } - break; - case OPT_JS_SENSE: if (joy_step > 1) { @@ -1266,30 +1224,6 @@ void c_interface_parameters() case OPT_CALIBRATE: break; - case OPT_JS_RANGE: - if (joy_range < 256) - { - ++joy_range; - joy_center_x = joy_range>>1; - joy_center_y = joy_range>>1; - half_joy_range = joy_range>>1; - } - break; - - case OPT_ORIGIN_X: - if (joy_center_x < joy_range-1) - { - joy_center_x++; - } - break; - - case OPT_ORIGIN_Y: - if (joy_center_y < joy_range-1) - { - joy_center_y++; - } - break; - case OPT_JS_SENSE: if (joy_step < 100) { diff --git a/src/joystick.c b/src/joystick.c index d03e4641..dba66f7b 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -77,7 +77,6 @@ int c_open_pc_joystick() } } - half_joy_range = joy_range/2; c_calculate_pc_joystick_parms(); return 0; /* no problem */ @@ -113,10 +112,10 @@ static void c_calculate_pc_joystick_parms() js_offset_x = js_min_x; js_offset_y = js_min_y; - js_adjustlow_x = (float)half_joy_range / (float)js_lowerrange_x; - js_adjustlow_y = (float)half_joy_range / (float)js_lowerrange_y; - js_adjusthigh_x = (float)half_joy_range / (float)js_upperrange_x; - js_adjusthigh_y = (float)half_joy_range / (float)js_upperrange_y; + js_adjustlow_x = (float)HALF_JOY_RANGE / (float)js_lowerrange_x; + js_adjustlow_y = (float)HALF_JOY_RANGE / (float)js_lowerrange_y; + js_adjusthigh_x = (float)HALF_JOY_RANGE / (float)js_upperrange_x; + js_adjusthigh_y = (float)HALF_JOY_RANGE / (float)js_upperrange_y; } /* ------------------------------------------------------------------------- @@ -236,12 +235,12 @@ static void c_calibrate_pc_joystick() x_val = (js.x < js_center_x) ? (js.x - js_offset_x) * js_adjustlow_x : (js.x - (js_center_x /*+js_offset_x*/)) * js_adjusthigh_x + - half_joy_range; + HALF_JOY_RANGE; y_val = (js.y < js_center_y) ? (js.y - js_offset_y) * js_adjustlow_y : (js.y - (js_center_y /*+js_offset_y*/)) * js_adjusthigh_y + - half_joy_range; + HALF_JOY_RANGE; sprintf(temp, " x = %02x, y = %02x", x_val, y_val); c_interface_print(1, 22, 0, temp); video_sync(0); diff --git a/src/joystick.h b/src/joystick.h index 3d597523..1d084060 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -19,6 +19,9 @@ #ifndef _JOYSTICK_H_ #define _JOYSTICK_H_ +#define JOY_RANGE 0x100 +#define HALF_JOY_RANGE 0x80 + void c_open_joystick(); void c_close_joystick(); void c_calibrate_joystick(); diff --git a/src/keys.c b/src/keys.c index 561b07f2..8778b951 100644 --- a/src/keys.c +++ b/src/keys.c @@ -27,6 +27,7 @@ #include "prefs.h" #include "timing.h" #include "soundcore.h" +#include "joystick.h" /* from misc.c */ extern uid_t user, privileged; @@ -242,8 +243,8 @@ void c_periodic_update(int dummysig) { break; case J_C: - joy_x = joy_center_x; - joy_y = joy_center_y; + joy_x = HALF_JOY_RANGE; + joy_y = HALF_JOY_RANGE; break; case kF1: @@ -330,13 +331,13 @@ void c_periodic_update(int dummysig) { if (key_pressed[ SCODE_J_D ]) { - if (joy_y < joy_range - joy_step) + if (joy_y < JOY_RANGE - joy_step) { joy_y += joy_step; } else { - joy_y = joy_range-1; + joy_y = JOY_RANGE-1; } } @@ -354,13 +355,13 @@ void c_periodic_update(int dummysig) { if (key_pressed[ SCODE_J_R ]) { - if (joy_x < joy_range - joy_step) + if (joy_x < JOY_RANGE - joy_step) { joy_x += joy_step; } else { - joy_x = joy_range-1; + joy_x = JOY_RANGE-1; } } } @@ -375,11 +376,11 @@ void c_periodic_update(int dummysig) { x_val = (js.x < js_center_x) ? (js.x - js_offset_x) * js_adjustlow_x - : (js.x - js_center_x) * js_adjusthigh_x + half_joy_range; + : (js.x - js_center_x) * js_adjusthigh_x + HALF_JOY_RANGE; y_val = (js.y < js_center_y) ? (js.y - js_offset_y) * js_adjustlow_y - : (js.y - js_center_y) * js_adjusthigh_y + half_joy_range; + : (js.y - js_center_y) * js_adjusthigh_y + HALF_JOY_RANGE; joy_y = (y_val > 0xff) ? 0xff : (y_val < 0) ? 0 : y_val; joy_x = (x_val > 0xff) ? 0xff : (x_val < 0) ? 0 : x_val; diff --git a/src/prefs.c b/src/prefs.c index d91fa0b1..0eff27ed 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -37,9 +37,6 @@ #define PRM_HIRES_COLOR 4 #define PRM_VOLUME 5 #define PRM_JOY_INPUT 6 -#define PRM_JOY_RANGE 7 -#define PRM_JOY_OX 8 -#define PRM_JOY_OY 9 #define PRM_JOY_PC_CALIBRATE 10 #define PRM_JOY_KPAD_SENSITIVITY 11 #define PRM_ROM_PATH 12 @@ -53,10 +50,6 @@ int sound_volume; color_mode_t color_mode; joystick_mode_t joy_mode; short joy_step; -short joy_center_x; -short joy_center_y; -short joy_range; -short half_joy_range; #ifdef PC_JOYSTICK int js_center_x; @@ -88,11 +81,6 @@ static const struct match_table prefs_table[] = { "color", PRM_HIRES_COLOR }, { "volume", PRM_VOLUME }, { "joystick", PRM_JOY_INPUT }, - { "joy range", PRM_JOY_RANGE }, - { "joystick range", PRM_JOY_RANGE }, - { "joy_range", PRM_JOY_RANGE }, - { "origin_x", PRM_JOY_OX }, - { "origin_y", PRM_JOY_OY }, { "pc joystick parms", PRM_JOY_PC_CALIBRATE }, { "pc_joystick_parms", PRM_JOY_PC_CALIBRATE }, { "sensitivity", PRM_JOY_KPAD_SENSITIVITY }, @@ -304,70 +292,6 @@ void load_settings(void) joy_mode = match(joy_input_table, argument); break; - case PRM_JOY_RANGE: - joy_range = strtol(argument, 0, 0); - if (joy_range < 10) - { - joy_range = 10; - } - else - if (joy_range > 256) - { - joy_range = 256; - } - - half_joy_range = joy_range / 2; - - if (joy_center_x > joy_range) - { - joy_center_x = half_joy_range; - } - - if (joy_center_y > joy_range) - { - joy_center_y = half_joy_range; - } - - break; - - case PRM_JOY_OX: - joy_center_x = strtol(argument, 0, 0); - if (joy_center_x < 0) - { - joy_center_x = 0; - } - else - if (joy_center_x > 255) - { - joy_center_x = 255; - } - - if (joy_center_x > joy_range) - { - joy_center_x = half_joy_range; - } - - break; - - case PRM_JOY_OY: - joy_center_y = strtol(argument, 0, 0); - if (joy_center_y < 0) - { - joy_center_y = 0; - } - else - if (joy_center_y > 255) - { - joy_center_y = 255; - } - - if (joy_center_y > joy_range) - { - joy_center_y = half_joy_range; - } - - break; - case PRM_JOY_PC_CALIBRATE: #ifdef PC_JOYSTICK /* pc joystick parms generated by the calibration routine @@ -475,9 +399,6 @@ bool save_settings(void) "color = %s\n" "volume = %s\n" "joystick = %s\n" - "joystick range = %d\n" - "origin_x = %d\n" - "origin_y = %d\n" "sensitivity = %d%%\n" "system path = %s\n", cpu_scale_factor, @@ -487,9 +408,6 @@ bool save_settings(void) reverse_match(color_table, color_mode), reverse_match(volume_table, sound_volume), reverse_match(joy_input_table, joy_mode), - joy_range, - joy_center_x, - joy_center_y, joy_step, system_path); diff --git a/src/prefs.h b/src/prefs.h index 073d5df0..37c6f1a1 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -53,10 +53,6 @@ extern color_mode_t color_mode; /* generic joystick settings */ extern joystick_mode_t joy_mode; extern short joy_step; -extern short joy_center_x; -extern short joy_center_y; -extern short joy_range; -extern short half_joy_range; #ifdef PC_JOYSTICK /* real joystick settings */