moar ifdefs for various macro conditional codepaths

* INTERFACE_CLASSIC : specifies the "classic" (current) menuing system
    * AUDIO_ENABLED : specifies whether audio code is enabled
This commit is contained in:
Aaron Culliney 2014-03-23 14:25:28 -07:00
parent a1e952984f
commit e57f332ff6
9 changed files with 54 additions and 18 deletions

View File

@ -17,7 +17,9 @@
#ifndef _A2_H_
#define _A2_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define BANK2 0x10000

View File

@ -179,9 +179,11 @@ E(read_random)
ret
E(read_speaker_toggle_pc)
#ifdef AUDIO_ENABLED
pushal
call SN(SpkrToggle)
popal // FIXME, do we need to set %al to something here?
#endif
ret
E(read_switch_primary_page)

View File

@ -106,9 +106,14 @@ void c_eject_6(int drive) {
const char* const err = def(disk6.disk[drive].file_name);
if (err)
{
ERRLOG("OOPS: An error occurred when attempting to compress a disk image : %s", err);
#ifdef INTERFACE_CLASSIC
snprintf(&zlibmenu[4][2], 37, "%s", err);
c_interface_print_submenu_centered(zlibmenu[0], ZLIB_SUBMENU_W, ZLIB_SUBMENU_H);
while ((ch = c_mygetch(1)) == -1) { }
while ((ch = c_mygetch(1)) == -1) {
// ...
}
#endif
}
else
{
@ -158,14 +163,12 @@ int c_new_diskette_6(int drive, char *file_name, int cmpr, int nib, int force) {
if (!force)
{
/* Open read only */
disk6.disk[drive].fp = fopen(disk6.disk[drive].file_name, "r+");
disk6.disk[drive].is_protected = 0;
}
if ((disk6.disk[drive].fp == NULL) || (force))
{
/* Open for read AND write */
disk6.disk[drive].fp = fopen(disk6.disk[drive].file_name, "r");
disk6.disk[drive].is_protected = 1; /* disk is write protected! */
}

View File

@ -121,6 +121,7 @@ static void c_calculate_pc_joystick_parms()
js_adjusthigh_y = (float)HALF_JOY_RANGE / (float)js_upperrange_y;
}
#ifdef INTERFACE_CLASSIC
/* -------------------------------------------------------------------------
c_calibrate_pc_joystick() - calibrates joystick. determines extreme
and center coordinates. assumes that it can write to the interface
@ -143,10 +144,6 @@ static void c_calibrate_pc_joystick()
"| Is the proper kernel module loaded? |",
"| |",
"||||||||||||||||||||||||||||||||||||||||" };
#define JOYERR_SHOWERR(ERR) \
copy_and_pad_string(&errmenu[3][2], ERR, ' ', JOYERR_PAD, ' '); \
c_interface_print_submenu_centered(errmenu[0], JOYERR_SUBMENU_W, JOYERR_SUBMENU_H); \
while (c_mygetch(1) == -1) { }
/* reset all the extremes */
js_max_x = INT_MIN;
@ -159,7 +156,15 @@ static void c_calibrate_pc_joystick()
{
if (c_open_pc_joystick())
{
JOYERR_SHOWERR(strerror(errno));
const char *err = strerror(errno);
ERRLOG("OOPS, cannot open pc joystick : %s", err);
#ifdef INTERFACE_CLASSIC
copy_and_pad_string(&errmenu[3][2], err, ' ', JOYERR_PAD, ' ');
c_interface_print_submenu_centered(errmenu[0], JOYERR_SUBMENU_W, JOYERR_SUBMENU_H);
while (c_mygetch(1) == -1) {
// ...
}
#endif
return;
}
}
@ -317,9 +322,10 @@ static void c_calibrate_pc_joystick()
nanosleep(&ts, NULL);
}
}
#endif // INTERFACE_CLASSIC
#endif // LINUX_JOYSTICK
#ifdef KEYPAD_JOYSTICK
#if defined(KEYPAD_JOYSTICK) && defined(INTERFACE_CLASSIC)
static void c_calibrate_keypad_joystick()
{
@ -426,7 +432,7 @@ static void c_calibrate_keypad_joystick()
nanosleep(&ts, NULL);
}
}
#endif // KEYPAD_JOYSTICK
#endif // KEYPAD_JOYSTICK && INTERFACE_CLASSIC
#ifdef TOUCH_JOYSTICK
// TBD ...
@ -465,6 +471,7 @@ void c_close_joystick()
#endif
}
#ifdef INTERFACE_CLASSIC
void c_calibrate_joystick()
{
#ifdef LINUX_JOYSTICK
@ -481,6 +488,7 @@ void c_calibrate_joystick()
}
#endif
}
#endif // INTERFACE_CLASSIC
void c_joystick_reset()
{

View File

@ -241,11 +241,14 @@ void c_handle_input(int scancode, int pressed)
}
pthread_mutex_lock(&interface_mutex);
#ifdef AUDIO_ENABLED
SoundSystemPause();
#endif
in_interface = true;
switch (current_key)
{
#ifdef INTERFACE_CLASSIC
case kF1:
c_interface_select_diskette( 0 );
break;
@ -253,6 +256,7 @@ void c_handle_input(int scancode, int pressed)
case kF2:
c_interface_select_diskette( 1 );
break;
#endif
case kPAUSE:
while (c_mygetch(1) == -1)
@ -262,6 +266,7 @@ void c_handle_input(int scancode, int pressed)
}
break;
#ifdef INTERFACE_CLASSIC
case kF5:
c_interface_keyboard_layout();
break;
@ -279,12 +284,15 @@ void c_handle_input(int scancode, int pressed)
case kF10:
c_interface_parameters();
break;
#endif
default:
break;
}
#ifdef AUDIO_ENABLED
SoundSystemUnpause();
#endif
c_joystick_reset();
pthread_mutex_unlock(&interface_mutex);
in_interface = false;

View File

@ -1284,6 +1284,7 @@ void do_debug_command() {
main debugging console
------------------------------------------------------------------------- */
#ifdef INTERFACE_CLASSIC
void c_interface_debugging() {
static char lex_initted = 0;
@ -1371,4 +1372,5 @@ void c_interface_debugging() {
}
return;
}
#endif

View File

@ -744,8 +744,10 @@ void reinitialize(void)
void c_initialize_firsttime()
{
#ifdef INTERFACE_CLASSIC
/* read in system files and calculate system defaults */
c_load_interface_font();
#endif
/* initialize the video system */
video_init();

View File

@ -209,11 +209,11 @@ void load_settings(void)
config_file = fopen(config_filename, "r");
if (config_file == NULL)
{
printf(
ERRLOG(
"Warning. Cannot open the .apple2 system defaults file.\n"
"Make sure it's readable in your home directory.");
printf("Press RETURN to continue...");
getchar();
ERRLOG("Press RETURN to continue...");
getchar(); // HACK FIXME -- this needs to be decoupled from both testing and mobile targets
return;
}
@ -236,7 +236,7 @@ void load_settings(void)
switch (main_match)
{
case PRM_NONE:
fprintf(stderr, "Unrecognized config parameter `%s'", parameter);
ERRLOG("Unrecognized config parameter `%s'", parameter);
break;
case PRM_SPEED:
@ -352,6 +352,11 @@ bool save_settings(void)
LOG("Saving preferences...");
#define PREFS_ERRPRINT() \
ERRLOG( \
"Cannot open the .apple2/apple2.cfg system defaults file for writing.\n" \
"Make sure it has rw permission in your home directory.")
#define ERROR_SUBMENU_H 9
#define ERROR_SUBMENU_W 40
int ch = -1;
@ -370,14 +375,13 @@ bool save_settings(void)
config_file = fopen(config_filename, "w");
if (config_file == NULL)
{
printf(
"Cannot open the .apple2/apple2.cfg system defaults file for writing.\n"
"Make sure it has rw permission in your home directory.");
PREFS_ERRPRINT();
#ifdef INTERFACE_CLASSIC
c_interface_print_submenu_centered(submenu[0], ERROR_SUBMENU_W, ERROR_SUBMENU_H);
while ((ch = c_mygetch(1)) == -1)
{
}
#endif
return false;
}
@ -417,10 +421,13 @@ bool save_settings(void)
if (anErr)
{
PREFS_ERRPRINT();
#ifdef INTERFACE_CLASSIC
c_interface_print_submenu_centered(submenu[0], ERROR_SUBMENU_W, ERROR_SUBMENU_H);
while ((ch = c_mygetch(1)) == -1)
{
}
#endif
return false;
}

View File

@ -95,10 +95,12 @@ static void _timing_initialize(double scale)
g_fCurrentCLK6502 = CLK_6502 * scale;
// this is extracted out of SetClksPerSpkrSample -- speaker.c
#ifdef AUDIO_ENABLED
g_fClksPerSpkrSample = (double) (UINT) (g_fCurrentCLK6502 / (double)SPKR_SAMPLE_RATE);
SpkrReinitialize();
LOG("timing_initialize() ... ClockRate:%0.2lf ClockCyclesPerSpeakerSample:%0.2lf", g_fCurrentCLK6502, g_fClksPerSpkrSample);
#endif
}
static void _switch_to_fullspeed(double scale)