Mini-refactor

This commit is contained in:
Aaron Culliney 2014-10-19 12:54:03 -07:00
parent 21660fdcb9
commit c140c5c7e0
6 changed files with 21 additions and 28 deletions

View File

@ -209,8 +209,7 @@ const char *c_new_diskette_6(int drive, const char * const raw_file_name, int fo
cut_gz(file_name);
}
strcpy(disk6.disk[drive].file_name, file_name);
disk6.disk[drive].file_name[1023]='\0';
strncpy(disk6.disk[drive].file_name, file_name, 1023);
disk6.disk[drive].compressed = true;// always using gz
disk6.disk[drive].nibblized = is_nib(file_name);
free(file_name);

View File

@ -29,7 +29,7 @@ uint8_t joy_button2 = 0; // unused?
#ifdef KEYPAD_JOYSTICK
short joy_step = 1;
uint8_t auto_recenter = 0;
uint8_t joy_auto_recenter = 0;
#endif
#ifdef LINUX_JOYSTICK
@ -384,7 +384,7 @@ static void c_calibrate_keypad_joystick()
snprintf(temp, TEMPSIZE, "%02x", (uint8_t)joy_step);
copy_and_pad_string(&submenu[KEYPAD_SUBMENU_H-4][36], temp, ' ', 3, ' ');
snprintf(temp, TEMPSIZE, "%s", auto_recenter ? " on" : "off" );
snprintf(temp, TEMPSIZE, "%s", joy_auto_recenter ? " on" : "off" );
copy_and_pad_string(&submenu[KEYPAD_SUBMENU_H-6][35], temp, ' ', 4, ' ');
int x_plot = CALIBRATE_TURTLE_KP_X0 + (int)(joy_x * CALIBRATE_TURTLE_KP_STEP_X);
@ -422,8 +422,8 @@ static void c_calibrate_keypad_joystick()
}
else if (ch == '+')
{
auto_recenter = (auto_recenter+1) % 2;
if (auto_recenter)
joy_auto_recenter = (joy_auto_recenter+1) % 2;
if (joy_auto_recenter)
{
joy_x = HALF_JOY_RANGE;
joy_y = HALF_JOY_RANGE;

View File

@ -22,11 +22,16 @@
#define JOY_RANGE 0x100
#define HALF_JOY_RANGE 0x80
uint16_t joy_x;
uint16_t joy_y;
uint8_t joy_button0;
uint8_t joy_button1;
uint8_t joy_button2;
extern uint16_t joy_x;
extern uint16_t joy_y;
extern uint8_t joy_button0;
extern uint8_t joy_button1;
extern uint8_t joy_button2;
#ifdef KEYPAD_JOYSTICK
extern uint8_t joy_auto_recenter;
extern short joy_step;
#endif
void c_open_joystick();
void c_close_joystick();

View File

@ -305,7 +305,7 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
joy_y = HALF_JOY_RANGE;
}
if (auto_recenter) {
if (joy_auto_recenter) {
static int unpressed_count = 0;
if (joy_axis_unpressed) {
++unpressed_count;

View File

@ -36,7 +36,8 @@
char system_path[SYSSIZE];
char disk_path[DISKSIZE];
int apple_mode = IIE_MODE;
#warning FIXME TODO : completely excise deprecated apple_mode stuff
int apple_mode = 2/*IIE_MODE*/;
int sound_volume = 2;
bool is_headless = false;
color_mode_t color_mode = COLOR;
@ -341,7 +342,7 @@ void load_settings(void)
joy_step = 255;
}
auto_recenter = strtol(argument, &argument, 10);
joy_auto_recenter = strtol(argument, &argument, 10);
break;
#endif
@ -431,7 +432,7 @@ bool save_settings(void)
#ifdef KEYPAD_JOYSTICK
err = fprintf(config_file,
"keypad joystick parms = %d %u\n", joy_step, auto_recenter ? 1 : 0);
"keypad joystick parms = %d %u\n", joy_step, joy_auto_recenter ? 1 : 0);
#endif
anErr = anErr || (err < 0);

View File

@ -17,7 +17,7 @@
#ifndef PREFS_H
#define PREFS_H
#ifndef __ASSEMBLER__
#include "common.h"
typedef enum joystick_mode_t {
JOY_OFF = 0,
@ -60,11 +60,6 @@ extern a2_video_mode_t a2_video_mode;
/* generic joystick settings */
extern joystick_mode_t joy_mode;
#ifdef KEYPAD_JOYSTICK
extern short joy_step;
extern uint8_t auto_recenter;
#endif
#ifdef LINUX_JOYSTICK
/* real joystick settings */
extern int js_center_x;
@ -79,11 +74,4 @@ extern int js_min_y;
extern void load_settings(void);
extern bool save_settings(void);
#endif /* !__ASSEMBLER__ */
/* values for apple_mode */
#define IIE_MODE 2
#define IIU_MODE 1
#define II_MODE 0
#endif /* PREFS_H */