~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/machine/dc-ctrl.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "emu.h"
2
 
#include "dc-ctrl.h"
3
 
 
4
 
const device_type DC_CONTROLLER = &device_creator<dc_controller_device>;
5
 
 
6
 
void dc_controller_device::static_set_port_tag(device_t &device, int port, const char *tag)
7
 
{
8
 
        dc_controller_device &ctrl = downcast<dc_controller_device &>(device);
9
 
        ctrl.port_tag[port] = tag;
10
 
}
11
 
 
12
 
void dc_controller_device::static_set_id(device_t &device, const char *id)
13
 
{
14
 
        dc_controller_device &ctrl = downcast<dc_controller_device &>(device);
15
 
        ctrl.id = id;
16
 
}
17
 
 
18
 
void dc_controller_device::static_set_license(device_t &device, const char *license)
19
 
{
20
 
        dc_controller_device &ctrl = downcast<dc_controller_device &>(device);
21
 
        ctrl.license = license;
22
 
}
23
 
 
24
 
void dc_controller_device::static_set_versions(device_t &device, const char *versions)
25
 
{
26
 
        dc_controller_device &ctrl = downcast<dc_controller_device &>(device);
27
 
        ctrl.versions = versions;
28
 
}
29
 
 
30
 
dc_controller_device::dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
31
 
        maple_device(mconfig, DC_CONTROLLER, "DC_CONTROLLER", tag, owner, clock)
32
 
{
33
 
        memset(port_tag, 0, sizeof(port_tag));
34
 
 
35
 
        id = "Dreamcast Controller";
36
 
        license = "Produced By or Under License From SEGA ENTERPRISES,LTD.";
37
 
        versions = "Version 1.010,1998/09/28,315-6211-AB   ,Analog Module : The 4th Edition.5/8  +DF";
38
 
}
39
 
 
40
 
void dc_controller_device::maple_w(const UINT32 *data, UINT32 in_size)
41
 
{
42
 
        switch(data[0] & 0xff) {
43
 
        case 0x01: // Device request
44
 
                reply_start(5, 0x20, 29);
45
 
                fixed_status(reply_buffer+1);
46
 
                reply_ready_with_delay();
47
 
                break;
48
 
 
49
 
        case 0x02: // All status request
50
 
                reply_start(6, 0x20, 49);
51
 
                fixed_status(reply_buffer+1);
52
 
                free_status(reply_buffer+29);
53
 
                reply_ready_with_delay();
54
 
                break;
55
 
 
56
 
        case 0x03: // reset - we're stateless where it matters
57
 
                reply_start(7, 0x20, 0);
58
 
                reply_ready_with_delay();
59
 
                break;
60
 
 
61
 
        case 0x09: // get condition
62
 
                if(1 || (in_size >= 2 && data[1] == 0x01000000)) {
63
 
                        reply_start(8, 0x20, 4);
64
 
                        read(reply_buffer+1);
65
 
                        reply_ready_with_delay();
66
 
                }
67
 
                break;
68
 
        }
69
 
}
70
 
 
71
 
void dc_controller_device::fixed_status(UINT32 *dest)
72
 
{
73
 
        dest[0] = 0x20000000; // Controller
74
 
        dest[1] =
75
 
                (input_port_exists(machine(), port_tag[2]) ? 0x010000 : 0) |
76
 
                (input_port_exists(machine(), port_tag[3]) ? 0x020000 : 0) |
77
 
                (input_port_exists(machine(), port_tag[4]) ? 0x040000 : 0) |
78
 
                (input_port_exists(machine(), port_tag[5]) ? 0x080000 : 0) |
79
 
                (input_port_exists(machine(), port_tag[6]) ? 0x100000 : 0) |
80
 
                (input_port_exists(machine(), port_tag[7]) ? 0x200000 : 0) |
81
 
                (input_port_active_safe(machine(), port_tag[0], 0) << 8) |
82
 
                input_port_active_safe(machine(), port_tag[1], 0); // 1st function - controller
83
 
        dest[2] = 0; // No 2nd function
84
 
        dest[3] = 0; // No 3rd function
85
 
        dest[4] = 0x00ff; // Every region, no expansion
86
 
        copy_with_spaces(((UINT8 *)dest) + 18, id, 30);
87
 
        copy_with_spaces(((UINT8 *)dest) + 48, license, 60);
88
 
        dest[27] = 0x01f401ae; // standby 43mA, max 50mA
89
 
}
90
 
 
91
 
void dc_controller_device::free_status(UINT32 *dest)
92
 
{
93
 
        copy_with_spaces((UINT8 *)dest, versions, 80);
94
 
}
95
 
 
96
 
void dc_controller_device::read(UINT32 *dest)
97
 
{
98
 
        dest[0] = 0x21000000; // Controller
99
 
        dest[1] =
100
 
                input_port_read_safe(machine(), port_tag[0], 0xff) |
101
 
                (input_port_read_safe(machine(), port_tag[1], 0xff) << 8) |
102
 
                (input_port_read_safe(machine(), port_tag[2], 0x00) << 16) |
103
 
                (input_port_read_safe(machine(), port_tag[3], 0x00) << 24);
104
 
        dest[2] =
105
 
                input_port_read_safe(machine(), port_tag[4], 0x80) |
106
 
                (input_port_read_safe(machine(), port_tag[5], 0x80) << 8) |
107
 
                (input_port_read_safe(machine(), port_tag[6], 0x80) << 16) |
108
 
                (input_port_read_safe(machine(), port_tag[7], 0x80) << 24);
109
 
}
110