mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-28 13:29:29 +00:00
refactor game controller switches to C
This commit is contained in:
parent
ebde9266e3
commit
1c3fc78838
|
@ -149,27 +149,6 @@
|
||||||
enabled.
|
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)
|
E(iie_c080)
|
||||||
testl $SS_ALTZP, SN(softswitches)
|
testl $SS_ALTZP, SN(softswitches)
|
||||||
jz lc_c080
|
jz lc_c080
|
||||||
|
|
|
@ -1280,7 +1280,6 @@ void c_interface_parameters()
|
||||||
{
|
{
|
||||||
timing_initialize();
|
timing_initialize();
|
||||||
video_set(0);
|
video_set(0);
|
||||||
extern unsigned char joy_button0;
|
|
||||||
joy_button0 = 0xff; // OpenApple
|
joy_button0 = 0xff; // OpenApple
|
||||||
cpu65_interrupt(ResetSig);
|
cpu65_interrupt(ResetSig);
|
||||||
c_initialize_sound_hooks();
|
c_initialize_sound_hooks();
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* parameters for generic and keyboard-simulated joysticks */
|
/* parameters for generic and keyboard-simulated joysticks */
|
||||||
short joy_x = HALF_JOY_RANGE;
|
uint16_t joy_x = HALF_JOY_RANGE;
|
||||||
short joy_y = HALF_JOY_RANGE;
|
uint16_t joy_y = HALF_JOY_RANGE;
|
||||||
unsigned char joy_button0 = 0;
|
uint8_t joy_button0 = 0;
|
||||||
unsigned char joy_button1 = 0;
|
uint8_t joy_button1 = 0;
|
||||||
unsigned char joy_button2 = 0; // unused?
|
uint8_t joy_button2 = 0; // unused?
|
||||||
|
|
||||||
#ifdef KEYPAD_JOYSTICK
|
#ifdef KEYPAD_JOYSTICK
|
||||||
short joy_step = 1;
|
short joy_step = 1;
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
#define JOY_RANGE 0x100
|
#define JOY_RANGE 0x100
|
||||||
#define HALF_JOY_RANGE 0x80
|
#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_open_joystick();
|
||||||
void c_close_joystick();
|
void c_close_joystick();
|
||||||
void c_calibrate_joystick();
|
void c_calibrate_joystick();
|
||||||
|
|
|
@ -19,12 +19,6 @@
|
||||||
/* from misc.c */
|
/* from misc.c */
|
||||||
extern uid_t user, privileged;
|
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 */
|
/* mutex used to synchronize between cpu and main threads */
|
||||||
pthread_mutex_t interface_mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t interface_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
pthread_cond_t ui_thread_cond = PTHREAD_COND_INITIALIZER;
|
pthread_cond_t ui_thread_cond = PTHREAD_COND_INITIALIZER;
|
||||||
|
|
44
src/misc.c
44
src/misc.c
|
@ -654,50 +654,6 @@ void c_initialize_firsttime()
|
||||||
reinitialize();
|
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)
|
#if !defined(TESTING)
|
||||||
static void main_thread(void *dummyptr) {
|
static void main_thread(void *dummyptr) {
|
||||||
struct timespec sleeptime = { .tv_sec=0, .tv_nsec=8333333 }; // 120Hz
|
struct timespec sleeptime = { .tv_sec=0, .tv_nsec=8333333 }; // 120Hz
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
#include "greatest.h"
|
#include "greatest.h"
|
||||||
|
|
||||||
#define TEST_FINISHED 0xff
|
#define TEST_FINISHED 0xff
|
||||||
#define MIXSWITCH_ADDR 0x1f32 // PEEK(7986)
|
#define MIXSWITCH_ADDR 0x1f32 // PEEK(7986) -- NOTE : value is hardcoded in various places
|
||||||
#define WATCHPOINT_ADDR 0x1f33 // PEEK(7987)
|
#define WATCHPOINT_ADDR 0x1f33 // PEEK(7987) -- NOTE : value is hardcoded in various places
|
||||||
#define TESTOUT_ADDR 0x1f43 // PEEK(8003)
|
#define TESTOUT_ADDR 0x1f43 // PEEK(8003) -- NOTE : value is hardcoded in various places
|
||||||
|
|
||||||
#define BLANK_SCREEN "6C8ABA272F220F00BE0E76A8659A1E30C2D3CDBE"
|
#define BLANK_SCREEN "6C8ABA272F220F00BE0E76A8659A1E30C2D3CDBE"
|
||||||
#define BOOT_SCREEN "F8D6C781E0BB7B3DDBECD69B25E429D845506594"
|
#define BOOT_SCREEN "F8D6C781E0BB7B3DDBECD69B25E429D845506594"
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
static bool test_do_reboot = true;
|
static bool test_do_reboot = true;
|
||||||
|
|
||||||
extern unsigned char joy_button0;
|
|
||||||
|
|
||||||
static void testdisplay_setup(void *arg) {
|
static void testdisplay_setup(void *arg) {
|
||||||
test_common_setup();
|
test_common_setup();
|
||||||
apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00;
|
apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00;
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
static bool test_do_reboot = true;
|
static bool test_do_reboot = true;
|
||||||
|
|
||||||
extern unsigned char joy_button0;
|
|
||||||
|
|
||||||
static void testvm_setup(void *arg) {
|
static void testvm_setup(void *arg) {
|
||||||
RESET_INPUT();
|
RESET_INPUT();
|
||||||
apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00;
|
apple_ii_64k[0][MIXSWITCH_ADDR] = 0x00;
|
||||||
|
|
73
src/vm.c
73
src/vm.c
|
@ -62,7 +62,7 @@ GLUE_C_READ(speaker_toggle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Softswitches
|
// graphics softswitches
|
||||||
|
|
||||||
GLUE_C_READ(iie_page2_off)
|
GLUE_C_READ(iie_page2_off)
|
||||||
{
|
{
|
||||||
|
@ -197,3 +197,74 @@ GLUE_C_READ(iie_hires_on)
|
||||||
return 0x0;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user