diff --git a/src/asm386/memory.S b/src/asm386/memory.S index 5f100fd8..a8383046 100644 --- a/src/asm386/memory.S +++ b/src/asm386/memory.S @@ -149,27 +149,6 @@ enabled. ----------------------------------------------------------------- */ -E(read_button0) - movb SN(joy_button0), %al - ret - -E(read_button1) - movb SN(joy_button1), %al - ret - -E(read_button2) - movb SN(joy_button2), %al - ret - -/* NOTE : Game Controller axis 2 & 3 is not hooked up on a normal //e */ -E(iie_read_gc2) - movb $0, %al - ret - -E(iie_read_gc3) - movb $0, %al - ret - E(iie_c080) testl $SS_ALTZP, SN(softswitches) jz lc_c080 diff --git a/src/interface.c b/src/interface.c index f77e9029..b6fa7898 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1280,7 +1280,6 @@ void c_interface_parameters() { timing_initialize(); video_set(0); - extern unsigned char joy_button0; joy_button0 = 0xff; // OpenApple cpu65_interrupt(ResetSig); c_initialize_sound_hooks(); diff --git a/src/joystick.c b/src/joystick.c index 88151cea..347bba61 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -21,11 +21,11 @@ #endif /* parameters for generic and keyboard-simulated joysticks */ -short joy_x = HALF_JOY_RANGE; -short joy_y = HALF_JOY_RANGE; -unsigned char joy_button0 = 0; -unsigned char joy_button1 = 0; -unsigned char joy_button2 = 0; // unused? +uint16_t joy_x = HALF_JOY_RANGE; +uint16_t joy_y = HALF_JOY_RANGE; +uint8_t joy_button0 = 0; +uint8_t joy_button1 = 0; +uint8_t joy_button2 = 0; // unused? #ifdef KEYPAD_JOYSTICK short joy_step = 1; diff --git a/src/joystick.h b/src/joystick.h index a65a5239..529cc8a4 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -22,6 +22,12 @@ #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; + void c_open_joystick(); void c_close_joystick(); void c_calibrate_joystick(); diff --git a/src/keys.c b/src/keys.c index 61fe48be..3effe33c 100644 --- a/src/keys.c +++ b/src/keys.c @@ -19,12 +19,6 @@ /* from misc.c */ extern uid_t user, privileged; -/* parameters for generic and keyboard-simulated joysticks */ -extern short joy_x; -extern short joy_y; -extern unsigned char joy_button0; -extern unsigned char joy_button1; - /* mutex used to synchronize between cpu and main threads */ pthread_mutex_t interface_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t ui_thread_cond = PTHREAD_COND_INITIALIZER; diff --git a/src/misc.c b/src/misc.c index c1095eaa..fa272c94 100644 --- a/src/misc.c +++ b/src/misc.c @@ -654,50 +654,6 @@ void c_initialize_firsttime() reinitialize(); } -// Read Game Controller (paddle) strobe ... -// From _Understanding the Apple IIe_ : -// * 7-29, discussing PREAD : "The timer duration will vary between 2 and 3302 usecs" -// * 7-30, timer reset : "But the timer pulse may still be high from the previous [strobe access] and the timers are -// not retriggered by C07X' if they have not yet reset from the previous trigger" -#define JOY_STEP_USEC (3300.0 / 256.0) -#define CYCLES_PER_USEC (CLK_6502 / 1000000) -#define JOY_STEP_CYCLES (JOY_STEP_USEC / CYCLES_PER_USEC) -extern short joy_x; -extern short joy_y; -GLUE_C_READ(read_gc_strobe) -{ - if (gc_cycles_timer_0 <= 0) - { - gc_cycles_timer_0 = (int)(joy_x * JOY_STEP_CYCLES) + 2; - } - if (gc_cycles_timer_1 <= 0) - { - gc_cycles_timer_1 = (int)(joy_y * JOY_STEP_CYCLES) + 2; - } - // NOTE: unimplemented GC2 and GC3 timers since they were not wired on the //e ... - return 0; -} - -GLUE_C_READ(read_gc0) -{ - if (gc_cycles_timer_0 <= 0) - { - gc_cycles_timer_0 = 0; - return 0; - } - return 0xFF; -} - -GLUE_C_READ(read_gc1) -{ - if (gc_cycles_timer_1 <= 0) - { - gc_cycles_timer_1 = 0; - return 0; - } - return 0xFF; -} - #if !defined(TESTING) static void main_thread(void *dummyptr) { struct timespec sleeptime = { .tv_sec=0, .tv_nsec=8333333 }; // 120Hz diff --git a/src/test/testcommon.h b/src/test/testcommon.h index 0ba8fc5e..6484d414 100644 --- a/src/test/testcommon.h +++ b/src/test/testcommon.h @@ -16,9 +16,9 @@ #include "greatest.h" #define TEST_FINISHED 0xff -#define MIXSWITCH_ADDR 0x1f32 // PEEK(7986) -#define WATCHPOINT_ADDR 0x1f33 // PEEK(7987) -#define TESTOUT_ADDR 0x1f43 // PEEK(8003) +#define MIXSWITCH_ADDR 0x1f32 // PEEK(7986) -- NOTE : value is hardcoded in various places +#define WATCHPOINT_ADDR 0x1f33 // PEEK(7987) -- NOTE : value is hardcoded in various places +#define TESTOUT_ADDR 0x1f43 // PEEK(8003) -- NOTE : value is hardcoded in various places #define BLANK_SCREEN "6C8ABA272F220F00BE0E76A8659A1E30C2D3CDBE" #define BOOT_SCREEN "F8D6C781E0BB7B3DDBECD69B25E429D845506594" diff --git a/src/test/testdisplay.c b/src/test/testdisplay.c index ac641fd3..57dc678c 100644 --- a/src/test/testdisplay.c +++ b/src/test/testdisplay.c @@ -19,8 +19,6 @@ static bool test_do_reboot = true; -extern unsigned char joy_button0; - static void testdisplay_setup(void *arg) { test_common_setup(); apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00; diff --git a/src/test/testvm.c b/src/test/testvm.c index 368774f1..825716f5 100644 --- a/src/test/testvm.c +++ b/src/test/testvm.c @@ -21,8 +21,6 @@ static bool test_do_reboot = true; -extern unsigned char joy_button0; - static void testvm_setup(void *arg) { RESET_INPUT(); apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00; diff --git a/src/vm.c b/src/vm.c index 2c33e9e6..5f220e5c 100644 --- a/src/vm.c +++ b/src/vm.c @@ -62,7 +62,7 @@ GLUE_C_READ(speaker_toggle) } // ---------------------------------------------------------------------------- -// Softswitches +// graphics softswitches GLUE_C_READ(iie_page2_off) { @@ -197,3 +197,74 @@ GLUE_C_READ(iie_hires_on) return 0x0; } +// ---------------------------------------------------------------------------- +// GC softswitches : Game Controller (joystick/paddles) +#define JOY_STEP_USEC (3300.0 / 256.0) +#define CYCLES_PER_USEC (CLK_6502 / 1000000) +#define JOY_STEP_CYCLES (JOY_STEP_USEC / CYCLES_PER_USEC) + +GLUE_C_READ(read_button0) +{ + return joy_button0; +} + +GLUE_C_READ(read_button1) +{ + return joy_button1; +} + +GLUE_C_READ(read_button2) +{ + return joy_button2; +} + +GLUE_C_READ(read_gc_strobe) +{ + // Read Game Controller (paddle) strobe ... + // From _Understanding the Apple IIe_ : + // * 7-29, discussing PREAD : "The timer duration will vary between 2 and 3302 usecs" + // * 7-30, timer reset : "But the timer pulse may still be high from the previous [strobe access] and the timers are + // not retriggered by C07X' if they have not yet reset from the previous trigger" + if (gc_cycles_timer_0 <= 0) + { + gc_cycles_timer_0 = (int)(joy_x * JOY_STEP_CYCLES) + 2; + } + if (gc_cycles_timer_1 <= 0) + { + gc_cycles_timer_1 = (int)(joy_y * JOY_STEP_CYCLES) + 2; + } + + // NOTE (possible TODO FIXME): unimplemented GC2 and GC3 timers since they were not wired on the //e ... + return 0x0; +} + +GLUE_C_READ(read_gc0) +{ + if (gc_cycles_timer_0 <= 0) + { + gc_cycles_timer_0 = 0; + return 0; + } + return 0xFF; +} + +GLUE_C_READ(read_gc1) +{ + if (gc_cycles_timer_1 <= 0) + { + gc_cycles_timer_1 = 0; + return 0; + } + return 0xFF; +} + +GLUE_C_READ(iie_read_gc2) +{ + return 0x0; +} + +GLUE_C_READ(iie_read_gc3) +{ + return 0x0; +} +