~ubuntu-branches/ubuntu/utopic/vice/utopic

« back to all changes in this revision

Viewing changes to src/userport/userport_joystick.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2014-05-10 21:08:23 UTC
  • mfrom: (17.2.1 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20140510210823-r7x98jmpl1x7rgop
Tags: 2.4.dfsg+2.4.6-1ubuntu1
Use autotools-dev to update config.{sub,guess} for new arches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * userport_dac.c - Generic userport joystick emulation.
 
2
 * userport_joystick.c - Generic userport joystick emulation.
3
3
 *
4
4
 * Written by
5
5
 *  Marco van den Heuvel <blackystardust68@yahoo.com>
30
30
#include <stdlib.h>
31
31
#include <string.h>
32
32
 
 
33
#include "cmdline.h"
33
34
#include "joystick.h"
 
35
#include "resources.h"
 
36
#include "translate.h"
34
37
#include "types.h"
35
38
#include "userport_joystick.h"
36
39
 
42
45
 
43
46
/* ------------------------------------------------------------------------- */
44
47
 
 
48
static int set_userport_joystick_enable(int val, void *param)
 
49
{
 
50
    userport_joystick_enable = val;
 
51
    return 0;
 
52
}
 
53
 
 
54
static int set_userport_joystick_type(int val, void *param)
 
55
{
 
56
    if (val >= USERPORT_JOYSTICK_NUM) {
 
57
        return -1;
 
58
    }
 
59
    userport_joystick_type = val;
 
60
    return 0;
 
61
}
 
62
 
 
63
static const resource_int_t resources_int[] = {
 
64
    { "UserportJoy", 0, RES_EVENT_NO, NULL,
 
65
      &userport_joystick_enable, set_userport_joystick_enable, NULL },
 
66
    { "UserportJoyType", 0, RES_EVENT_NO, NULL,
 
67
      &userport_joystick_type, set_userport_joystick_type, NULL },
 
68
    { NULL }
 
69
};
 
70
 
 
71
int userport_joystick_resources_init(void)
 
72
{
 
73
    return resources_register_int(resources_int);
 
74
}
 
75
 
 
76
static const cmdline_option_t cmdline_options[] =
 
77
{
 
78
    { "-userportjoy", SET_RESOURCE, 0,
 
79
      NULL, NULL, "UserportJoy", (resource_value_t)1,
 
80
      USE_PARAM_STRING, USE_DESCRIPTION_ID,
 
81
      IDCLS_UNUSED, IDCLS_ENABLE_USERPORT_JOY,
 
82
      NULL, NULL },
 
83
    { "+userportjoy", SET_RESOURCE, 0,
 
84
      NULL, NULL, "UserportJoy", (resource_value_t)0,
 
85
      USE_PARAM_STRING, USE_DESCRIPTION_ID,
 
86
      IDCLS_UNUSED, IDCLS_DISABLE_USERPORT_JOY,
 
87
      NULL, NULL },
 
88
    { "-userportjoytype", SET_RESOURCE, 1,
 
89
      NULL, NULL, "UserportJoyType", (resource_value_t)0,
 
90
      USE_PARAM_ID, USE_DESCRIPTION_ID,
 
91
      IDCLS_P_TYPE, IDCLS_SET_USERPORT_JOY_TYPE,
 
92
      NULL, NULL },
 
93
    { NULL }
 
94
};
 
95
 
 
96
int userport_joystick_cmdline_options_init(void)
 
97
{
 
98
    return cmdline_register_options(cmdline_options);
 
99
}
 
100
 
 
101
/* ------------------------------------------------------------------------- */
 
102
 
45
103
/* FIXME: direction and unused bits are not yet taken into account */
46
104
 
47
105
/* C64/C128 only */
108
166
                retval = (BYTE)~((jv3 & 0xf) | ((jv4 & 0xf) << 4));
109
167
                break;
110
168
            case USERPORT_JOYSTICK_CGA:
111
 
                retval = (BYTE)~((jv3 & 0x10) | ((jv4 & 0x10) << 1)
112
 
                               | (get_joystick_value(userport_joystick_cga_select + 3) & 0xf));
 
169
                retval = (BYTE)~((jv3 & 0x10) | ((jv4 & 0x10) << 1) | (get_joystick_value(userport_joystick_cga_select + 3) & 0xf));
113
170
                break;
114
171
            case USERPORT_JOYSTICK_PET:
115
172
                retval = ((jv3 & 0xf) | ((jv4 & 0xf) << 4));
126
183
                retval |= ((jv3 & 4) << 3);
127
184
                retval |= ((jv3 & 8) << 1);
128
185
                retval |= ((jv3 & 16) >> 1);
129
 
                retval = (BYTE)~!retval;
 
186
                retval = (BYTE)~retval;
130
187
                break;
131
188
            case USERPORT_JOYSTICK_KINGSOFT:
132
189
                retval = ((jv4 >> 3) & 1) << 0;