mirror of
https://github.com/holub/mame
synced 2025-05-17 19:24:59 +03:00
added device support to the input system. internally this replaces PORT_CUSTOM/PORT_CHANGED, backward compatibility is achieved with an internal dummy device.
added output lines (IPT_OUTPUT), which can be written using new input_port_write* functions or directly from a memory map using AM_WRITE_PORT converted adc083x to use io lines. adc08x chips are all hooked up using input/output ports reversed racing force steering wheel input and gas pedal, which is enough to get the game to boot. reversed steering wheel input on winding heat, the usa cabinets are however hooked up the other way. renamed adc0831_interface to adc083x_interface. fixed adc083x gnd input removed stray call logerror from adc083x.c fixed default adc083x sars value adc083x reset only affects outputs
This commit is contained in:
parent
bcd6cff1fe
commit
dd1d8777a9
@ -196,12 +196,13 @@ struct _digital_joystick_state
|
||||
};
|
||||
|
||||
|
||||
/* live custom/changed field information */
|
||||
typedef struct _callback_field_info callback_field_info;
|
||||
struct _callback_field_info
|
||||
/* live device field information */
|
||||
typedef struct _device_field_info device_field_info;
|
||||
struct _device_field_info
|
||||
{
|
||||
callback_field_info * next; /* linked list of info for this port */
|
||||
device_field_info * next; /* linked list of info for this port */
|
||||
const input_field_config * field; /* pointer to the input field referenced */
|
||||
const device_config * device; /* device */
|
||||
UINT8 shift; /* shift to apply to the final result */
|
||||
};
|
||||
|
||||
@ -224,12 +225,13 @@ struct _input_field_state
|
||||
struct _input_port_state
|
||||
{
|
||||
analog_field_state * analoglist; /* pointer to list of analog port info */
|
||||
callback_field_info * customlist; /* pointer to list of custom port info */
|
||||
callback_field_info * changedlist; /* pointer to list of changed port info */
|
||||
device_field_info * readdevicelist; /* pointer to list of input device info */
|
||||
device_field_info * writedevicelist; /* pointer to list of output device info */
|
||||
input_port_value defvalue; /* combined default value across the port */
|
||||
input_port_value digital; /* current value from all digital inputs */
|
||||
input_port_value vblank; /* value of all IPT_VBLANK bits */
|
||||
input_port_value lastvalue; /* last value of the port, to detect changes */
|
||||
input_port_value lastwrite; /* last value written to the port, to detect changes */
|
||||
};
|
||||
|
||||
|
||||
@ -442,7 +444,7 @@ static INT32 apply_analog_settings(INT32 current, analog_field_state *analog);
|
||||
static void init_port_types(running_machine *machine);
|
||||
static void init_port_state(running_machine *machine);
|
||||
static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame);
|
||||
static callback_field_info *init_field_callback_info(const input_field_config *field);
|
||||
static device_field_info *init_field_device_info(const input_field_config *field,const char *device_name);
|
||||
static analog_field_state *init_field_analog_state(const input_field_config *field);
|
||||
|
||||
/* once-per-frame updates */
|
||||
@ -621,6 +623,29 @@ INLINE int condition_equal(const input_condition *cond1, const input_condition *
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
CUSTOM DEVICE I/O
|
||||
***************************************************************************/
|
||||
static READ_LINE_DEVICE_HANDLER( custom_read_line_device )
|
||||
{
|
||||
const device_field_info *device_field = (const device_field_info *) device;
|
||||
|
||||
return (*device_field->field->custom)(device_field->field, device_field->field->custom_param);
|
||||
}
|
||||
|
||||
static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device )
|
||||
{
|
||||
const device_field_info *device_field = (const device_field_info *) device;
|
||||
|
||||
/* recalculate 'oldval' as it cannot be passed directly */
|
||||
input_port_value last = (device_field->field->type == IPT_OUTPUT) ? device_field->field->port->state->lastwrite : device_field->field->port->state->lastvalue;
|
||||
input_port_value oldval = (last & device_field->field->mask) >> device_field->shift;
|
||||
|
||||
(*device_field->field->changed)(device_field->field, device_field->field->changed_param, oldval, state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
CORE SYSTEM MANAGEMENT
|
||||
***************************************************************************/
|
||||
@ -1203,7 +1228,7 @@ input_port_value input_port_read_direct(const input_port_config *port)
|
||||
{
|
||||
input_port_private *portdata = port->machine->input_port_data;
|
||||
analog_field_state *analog;
|
||||
callback_field_info *custom;
|
||||
device_field_info *device_field;
|
||||
input_port_value result;
|
||||
|
||||
assert_always(portdata->safe_to_read, "Input ports cannot be read at init time!");
|
||||
@ -1212,12 +1237,12 @@ input_port_value input_port_read_direct(const input_port_config *port)
|
||||
result = port->state->digital;
|
||||
|
||||
/* update custom values */
|
||||
for (custom = port->state->customlist; custom != NULL; custom = custom->next)
|
||||
if (input_condition_true(port->machine, &custom->field->condition))
|
||||
for (device_field = port->state->readdevicelist; device_field != NULL; device_field = device_field->next)
|
||||
if (input_condition_true(port->machine, &device_field->field->condition))
|
||||
{
|
||||
/* replace the bits with bits from the custom routine */
|
||||
input_port_value newbits = (*custom->field->custom)(custom->field, custom->field->custom_param);
|
||||
result = (result & ~custom->field->mask) | ((newbits << custom->shift) & custom->field->mask);
|
||||
/* replace the bits with bits from the device */
|
||||
input_port_value newval = (*device_field->field->read_line_device)(device_field->device);
|
||||
result = (result & ~device_field->field->mask) | ((newval << device_field->shift) & device_field->field->mask);
|
||||
}
|
||||
|
||||
/* update VBLANK bits */
|
||||
@ -1422,6 +1447,65 @@ static INT32 apply_analog_settings(INT32 value, analog_field_state *analog)
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
PORT WRITING
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
input_port_write_direct - write a value
|
||||
to a port
|
||||
-------------------------------------------------*/
|
||||
|
||||
void input_port_write_direct(const input_port_config *port, input_port_value data, input_port_value mem_mask)
|
||||
{
|
||||
/* call device line changed handlers */
|
||||
device_field_info *device_field;
|
||||
input_port_value newvalue = port->state->lastwrite;
|
||||
|
||||
COMBINE_DATA(&newvalue);
|
||||
|
||||
for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next)
|
||||
if (device_field->field->type == IPT_OUTPUT && input_condition_true(port->machine, &device_field->field->condition))
|
||||
{
|
||||
input_port_value oldval = (port->state->lastwrite & device_field->field->mask) >> device_field->shift;
|
||||
input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift;
|
||||
|
||||
/* if the bits have changed, call the handler */
|
||||
if (oldval != newval)
|
||||
(*device_field->field->write_line_device)(device_field->device, newval);
|
||||
}
|
||||
|
||||
/* remember the last value */
|
||||
port->state->lastwrite = newvalue;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
input_port_write - write a value to a
|
||||
port specified by tag
|
||||
-------------------------------------------------*/
|
||||
|
||||
void input_port_write(running_machine *machine, const char *tag, input_port_value value, input_port_value mask)
|
||||
{
|
||||
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
||||
if (port == NULL)
|
||||
fatalerror("Unable to locate input port '%s'", tag);
|
||||
input_port_write_direct(port, value, mask);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
input_port_read_safe - write a value to
|
||||
a port, ignore if the port does not exist
|
||||
-------------------------------------------------*/
|
||||
|
||||
void input_port_write_safe(running_machine *machine, const char *tag, input_port_value value, input_port_value mask)
|
||||
{
|
||||
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
||||
if (port != NULL)
|
||||
input_port_write_direct(port, value, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
MISC HELPER FUNCTIONS
|
||||
***************************************************************************/
|
||||
@ -1560,8 +1644,8 @@ static void init_port_state(running_machine *machine)
|
||||
for (port = machine->portconfig; port != NULL; port = port->next)
|
||||
{
|
||||
analog_field_state **analogstatetail;
|
||||
callback_field_info **custominfotail;
|
||||
callback_field_info **changedinfotail;
|
||||
device_field_info **readdevicetail;
|
||||
device_field_info **writedevicetail;
|
||||
input_port_state *portstate;
|
||||
|
||||
/* allocate a new input_port_info structure */
|
||||
@ -1571,8 +1655,8 @@ static void init_port_state(running_machine *machine)
|
||||
|
||||
/* start with tail pointers to all the data */
|
||||
analogstatetail = &portstate->analoglist;
|
||||
custominfotail = &portstate->customlist;
|
||||
changedinfotail = &portstate->changedlist;
|
||||
readdevicetail = &portstate->readdevicelist;
|
||||
writedevicetail = &portstate->writedevicelist;
|
||||
|
||||
/* iterate over fields */
|
||||
for (field = port->fieldlist; field != NULL; field = field->next)
|
||||
@ -1605,18 +1689,18 @@ static void init_port_state(running_machine *machine)
|
||||
fieldstate->joystick->inuse = TRUE;
|
||||
}
|
||||
|
||||
/* if this entry has custom callback, allocate memory for the tracking structure */
|
||||
if (field->custom != NULL)
|
||||
/* if this entry has device input, allocate memory for the tracking structure */
|
||||
if (field->read_line_device != NULL)
|
||||
{
|
||||
*custominfotail = init_field_callback_info(field);
|
||||
custominfotail = &(*custominfotail)->next;
|
||||
*readdevicetail = init_field_device_info(field,field->read_device_name);
|
||||
readdevicetail = &(*readdevicetail)->next;
|
||||
}
|
||||
|
||||
/* if this entry has changed callback, allocate memory for the tracking structure */
|
||||
if (field->changed != NULL)
|
||||
/* if this entry has device output, allocate memory for the tracking structure */
|
||||
if (field->write_line_device != NULL)
|
||||
{
|
||||
*changedinfotail = init_field_callback_info(field);
|
||||
changedinfotail = &(*changedinfotail)->next;
|
||||
*writedevicetail = init_field_device_info(field,field->write_device_name);
|
||||
writedevicetail = &(*writedevicetail)->next;
|
||||
}
|
||||
|
||||
#ifdef MESS
|
||||
@ -1716,24 +1800,28 @@ static void init_autoselect_devices(const input_port_config *portlist, int type1
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
init_field_callback_info - allocate and populate
|
||||
information about a changed or custom
|
||||
callback
|
||||
init_field_device_info - allocate and populate
|
||||
information about a device callback
|
||||
-------------------------------------------------*/
|
||||
|
||||
static callback_field_info *init_field_callback_info(const input_field_config *field)
|
||||
static device_field_info *init_field_device_info(const input_field_config *field, const char *device_name)
|
||||
{
|
||||
callback_field_info *info;
|
||||
device_field_info *info;
|
||||
input_port_value mask;
|
||||
|
||||
/* allocate memory */
|
||||
info = auto_alloc_clear(field->port->machine, callback_field_info);
|
||||
info = auto_alloc_clear(field->port->machine, device_field_info);
|
||||
|
||||
/* fill in the data */
|
||||
info->field = field;
|
||||
for (mask = field->mask; !(mask & 1); mask >>= 1)
|
||||
info->shift++;
|
||||
|
||||
if (device_name != NULL)
|
||||
info->device = devtag_get_device(field->port->machine, device_name);
|
||||
else
|
||||
info->device = (const device_config *) info;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -1975,7 +2063,7 @@ profiler_mark_start(PROFILER_INPUT);
|
||||
for (port = machine->portconfig; port != NULL; port = port->next)
|
||||
{
|
||||
const input_field_config *field;
|
||||
callback_field_info *changed;
|
||||
device_field_info *device_field;
|
||||
input_port_value newvalue;
|
||||
|
||||
/* start with 0 values for the digital and VBLANK bits */
|
||||
@ -2004,17 +2092,17 @@ profiler_mark_start(PROFILER_INPUT);
|
||||
mess_input_port_update_hook(machine, port, &port->state->digital);
|
||||
#endif /* MESS */
|
||||
|
||||
/* call changed handlers */
|
||||
/* call device line changed handlers */
|
||||
newvalue = input_port_read_direct(port);
|
||||
for (changed = port->state->changedlist; changed; changed = changed->next)
|
||||
if (input_condition_true(port->machine, &changed->field->condition))
|
||||
for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next)
|
||||
if (device_field->field->type != IPT_OUTPUT && input_condition_true(port->machine, &device_field->field->condition))
|
||||
{
|
||||
input_port_value oldbits = (port->state->lastvalue & changed->field->mask) >> changed->shift;
|
||||
input_port_value newbits = (newvalue & changed->field->mask) >> changed->shift;
|
||||
input_port_value oldval = (port->state->lastvalue & device_field->field->mask) >> device_field->shift;
|
||||
input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift;
|
||||
|
||||
/* if the bits have changed, call the handler */
|
||||
if (oldbits != newbits)
|
||||
(*changed->field->changed)(changed->field, changed->field->changed_param, oldbits, newbits);
|
||||
if (oldval != newval)
|
||||
(*device_field->field->write_line_device)(device_field->device, newval);
|
||||
}
|
||||
|
||||
/* remember the last value */
|
||||
@ -2553,6 +2641,8 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
|
||||
TOKEN_SKIP_PTR(ipt);
|
||||
break;
|
||||
}
|
||||
curfield->read_line_device = custom_read_line_device;
|
||||
curfield->read_device_name = NULL;
|
||||
curfield->custom = TOKEN_GET_PTR(ipt, customptr);
|
||||
curfield->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
|
||||
break;
|
||||
@ -2566,6 +2656,8 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
|
||||
TOKEN_SKIP_PTR(ipt);
|
||||
break;
|
||||
}
|
||||
curfield->write_line_device = changed_write_line_device;
|
||||
curfield->write_device_name = NULL;
|
||||
curfield->changed = TOKEN_GET_PTR(ipt, changedptr);
|
||||
curfield->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
|
||||
break;
|
||||
@ -2948,6 +3040,32 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
|
||||
curfield->name = TOKEN_GET_STRING(ipt);
|
||||
break;
|
||||
|
||||
/* input device handler */
|
||||
case INPUT_TOKEN_READ_LINE_DEVICE:
|
||||
if (curfield == NULL)
|
||||
{
|
||||
error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_READ_LINE_DEVICE encountered with no active field\n");
|
||||
TOKEN_SKIP_STRING(ipt);
|
||||
TOKEN_SKIP_PTR(ipt);
|
||||
break;
|
||||
}
|
||||
curfield->read_device_name = TOKEN_GET_STRING(ipt);
|
||||
curfield->read_line_device = TOKEN_GET_PTR(ipt, read_line_device);
|
||||
break;
|
||||
|
||||
/* output device handler */
|
||||
case INPUT_TOKEN_WRITE_LINE_DEVICE:
|
||||
if (curfield == NULL)
|
||||
{
|
||||
error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_WRITE_LINE_DEVICE encountered with no active field\n");
|
||||
TOKEN_SKIP_STRING(ipt);
|
||||
TOKEN_SKIP_PTR(ipt);
|
||||
break;
|
||||
}
|
||||
curfield->write_device_name = TOKEN_GET_STRING(ipt);
|
||||
curfield->write_line_device = TOKEN_GET_PTR(ipt, write_line_device);
|
||||
break;
|
||||
|
||||
default:
|
||||
error_buf_append(errorbuf, errorbuflen, "Invalid token %d in input ports\n", entrytype);
|
||||
break;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "devcb.h"
|
||||
#include "memory.h"
|
||||
#include "inputseq.h"
|
||||
#include "tokenize.h"
|
||||
@ -357,6 +358,7 @@ enum
|
||||
|
||||
/* special meaning handled by custom code */
|
||||
IPT_SPECIAL,
|
||||
IPT_OUTPUT,
|
||||
|
||||
__ipt_max
|
||||
};
|
||||
@ -418,7 +420,9 @@ enum
|
||||
INPUT_TOKEN_CHAR,
|
||||
INPUT_TOKEN_CATEGORY,
|
||||
INPUT_TOKEN_CATEGORY_NAME,
|
||||
INPUT_TOKEN_CATEGORY_SETTING
|
||||
INPUT_TOKEN_CATEGORY_SETTING,
|
||||
INPUT_TOKEN_READ_LINE_DEVICE,
|
||||
INPUT_TOKEN_WRITE_LINE_DEVICE,
|
||||
};
|
||||
|
||||
|
||||
@ -583,6 +587,8 @@ union _input_port_token
|
||||
input_field_custom_func customptr;
|
||||
input_field_changed_func changedptr;
|
||||
input_field_crossmap_func crossmapptr;
|
||||
read_line_device_func read_line_device;
|
||||
write_line_device_func write_line_device;
|
||||
};
|
||||
|
||||
|
||||
@ -637,6 +643,10 @@ struct _input_field_config
|
||||
UINT8 impulse; /* number of frames before reverting to defvalue */
|
||||
const char * name; /* user-friendly name to display */
|
||||
input_seq seq[SEQ_TYPE_TOTAL];/* sequences of all types */
|
||||
read_line_device_func read_line_device; /* input device handler */
|
||||
const char * read_device_name; /* input device name */
|
||||
write_line_device_func write_line_device; /* output device handler */
|
||||
const char * write_device_name; /* input device name */
|
||||
input_field_custom_func custom; /* custom callback routine */
|
||||
void * custom_param; /* parameter for custom callback routine */
|
||||
input_field_changed_func changed; /* changed callback routine */
|
||||
@ -903,6 +913,18 @@ struct _inp_header
|
||||
TOKEN_PTR(changedptr, _callback), \
|
||||
TOKEN_PTR(voidptr, _param),
|
||||
|
||||
/* input device handler */
|
||||
#define PORT_READ_LINE_DEVICE(_device, _read_line_device) \
|
||||
TOKEN_UINT32_PACK1(INPUT_TOKEN_READ_LINE_DEVICE, 8), \
|
||||
TOKEN_STRING(_device), \
|
||||
TOKEN_PTR(read_line_device, _read_line_device),
|
||||
|
||||
/* output device handler */
|
||||
#define PORT_WRITE_LINE_DEVICE(_device, _write_line_device) \
|
||||
TOKEN_UINT32_PACK1(INPUT_TOKEN_WRITE_LINE_DEVICE, 8), \
|
||||
TOKEN_STRING(_device), \
|
||||
TOKEN_PTR(write_line_device, _write_line_device),
|
||||
|
||||
/* dip switch definition */
|
||||
#define PORT_DIPNAME(_mask, _default, _name) \
|
||||
TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPNAME, 8), \
|
||||
@ -1092,6 +1114,19 @@ void input_port_update_defaults(running_machine *machine);
|
||||
|
||||
|
||||
|
||||
/* ----- port writing ----- */
|
||||
|
||||
/* write a value to a port */
|
||||
void input_port_write_direct(const input_port_config *port, input_port_value value, input_port_value mask);
|
||||
|
||||
/* write a value to a port specified by tag */
|
||||
void input_port_write(running_machine *machine, const char *tag, input_port_value value, input_port_value mask);
|
||||
|
||||
/* write a value to a port, ignore if the port does not exist */
|
||||
void input_port_write_safe(running_machine *machine, const char *tag, input_port_value value, input_port_value mask);
|
||||
|
||||
|
||||
|
||||
/* ----- misc helper functions ----- */
|
||||
|
||||
/* return the TRUE if the given condition attached is true */
|
||||
|
@ -4,26 +4,23 @@
|
||||
|
||||
8-Bit serial I/O A/D Converters with Muliplexer Options
|
||||
|
||||
|
||||
2009-06 Converted to be a device
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "driver.h"
|
||||
#include "adc083x.h"
|
||||
|
||||
#define VERBOSE_LEVEL (0)
|
||||
#define VERBOSE_LEVEL ( 0 )
|
||||
|
||||
INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
|
||||
INLINE void ATTR_PRINTF( 3, 4 ) verboselog( int n_level, running_machine *machine, const char *s_fmt, ... )
|
||||
{
|
||||
if (VERBOSE_LEVEL >= n_level)
|
||||
if( VERBOSE_LEVEL >= n_level )
|
||||
{
|
||||
va_list v;
|
||||
char buf[ 32768 ];
|
||||
va_start(v, s_fmt);
|
||||
vsprintf(buf, s_fmt, v);
|
||||
va_end(v);
|
||||
logerror("%s: %s", cpuexec_describe_context(machine), buf);
|
||||
va_start( v, s_fmt );
|
||||
vsprintf( buf, s_fmt, v );
|
||||
va_end( v );
|
||||
logerror( "%s: %s", cpuexec_describe_context( machine ), buf );
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,19 +71,19 @@ struct _adc0831_state
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
INLINE adc0831_state *get_safe_token(const device_config *device)
|
||||
INLINE adc0831_state *get_safe_token( const device_config *device )
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->token != NULL);
|
||||
assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
|
||||
return (adc0831_state *)device->token;
|
||||
assert( device != NULL );
|
||||
assert( device->token != NULL );
|
||||
assert( ( device->type == ADC0831 ) || ( device->type == ADC0832 ) || ( device->type == ADC0834 ) || ( device->type == ADC0838 ) );
|
||||
return (adc0831_state *) device->token;
|
||||
}
|
||||
|
||||
INLINE const adc0831_interface *get_interface(const device_config *device)
|
||||
INLINE const adc083x_interface *get_interface( const device_config *device )
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
|
||||
return (const adc0831_interface *) device->static_config;
|
||||
assert( device != NULL );
|
||||
assert( ( device->type == ADC0831 ) || ( device->type == ADC0832 ) || ( device->type == ADC0834 ) || ( device->type == ADC0838 ) );
|
||||
return (const adc083x_interface *) device->static_config;
|
||||
}
|
||||
|
||||
|
||||
@ -95,30 +92,44 @@ INLINE const adc0831_interface *get_interface(const device_config *device)
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
adc083x_cs_write
|
||||
adc083x_clear_sars
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
static void adc083x_clear_sars( const device_config *device, adc0831_state *adc083x )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
if (adc083x->cs != data)
|
||||
{
|
||||
verboselog(device->machine, 2, "adc083x_cs_write( %s, %d )\n", device->tag, data);
|
||||
}
|
||||
|
||||
if (adc083x->cs == 0 && data != 0)
|
||||
{
|
||||
adc083x->state = STATE_IDLE;
|
||||
if (device->type == ADC0834 || device->type == ADC0838)
|
||||
if( device->type == ADC0834 ||device->type == ADC0838 )
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
adc083x->sars = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
adc083x_cs_write
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( adc083x_cs_write )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
if( adc083x->cs != state )
|
||||
{
|
||||
verboselog( 2, device->machine, "adc083x_cs_write( %s, %d )\n", device->tag, state );
|
||||
}
|
||||
|
||||
if( adc083x->cs == 0 && state != 0 )
|
||||
{
|
||||
adc083x->state = STATE_IDLE;
|
||||
adc083x_clear_sars( device, adc083x );
|
||||
adc083x->_do = 1;
|
||||
}
|
||||
if (adc083x->cs != 0 && data == 0)
|
||||
|
||||
if( adc083x->cs != 0 && state == 0 )
|
||||
{
|
||||
if (device->type == ADC0831)
|
||||
if( device->type == ADC0831 )
|
||||
{
|
||||
adc083x->state = STATE_MUX_SETTLE;
|
||||
}
|
||||
@ -127,14 +138,11 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
adc083x->state = STATE_WAIT_FOR_START;
|
||||
}
|
||||
|
||||
if (device->type == ADC0834 || device->type == ADC0838)
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
adc083x_clear_sars( device, adc083x );
|
||||
adc083x->_do = 1;
|
||||
}
|
||||
|
||||
adc083x->cs = data;
|
||||
adc083x->cs = state;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -143,25 +151,24 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
|
||||
static UINT8 adc083x_conversion( const device_config *device )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
int result;
|
||||
int positive_channel = ADC083X_AGND;
|
||||
int negative_channel = ADC083X_AGND;
|
||||
double positive = 0;
|
||||
double negative = 0;
|
||||
double vref = adc083x->input_callback_r(device, ADC083X_VREF);
|
||||
double gnd = adc083x->input_callback_r(device, ADC083X_VREF);
|
||||
double gnd = adc083x->input_callback_r( device, ADC083X_AGND );
|
||||
double vref = adc083x->input_callback_r( device, ADC083X_VREF );
|
||||
|
||||
if (device->type == ADC0831)
|
||||
if( device->type == ADC0831 )
|
||||
{
|
||||
positive_channel = ADC083X_CH0;
|
||||
negative_channel = ADC083X_CH1;
|
||||
}
|
||||
|
||||
else if (device->type == ADC0832)
|
||||
else if( device->type == ADC0832 )
|
||||
{
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd;
|
||||
if (adc083x->sgl == 0)
|
||||
if( adc083x->sgl == 0 )
|
||||
{
|
||||
negative_channel = positive_channel ^ 1;
|
||||
}
|
||||
@ -170,10 +177,10 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
negative_channel = ADC083X_AGND;
|
||||
}
|
||||
}
|
||||
else if (device->type == ADC0834)
|
||||
else if( device->type == ADC0834 )
|
||||
{
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel1 * 2);
|
||||
if (adc083x->sgl == 0)
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + ( adc083x->sel1 * 2 );
|
||||
if( adc083x->sgl == 0 )
|
||||
{
|
||||
negative_channel = positive_channel ^ 1;
|
||||
}
|
||||
@ -182,10 +189,10 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
negative_channel = ADC083X_AGND;
|
||||
}
|
||||
}
|
||||
else if (device->type == ADC0838)
|
||||
else if( device->type == ADC0838 )
|
||||
{
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel0 * 2) + (adc083x->sel1 * 4);
|
||||
if (adc083x->sgl == 0)
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + ( adc083x->sel0 * 2 ) + ( adc083x->sel1 * 4 );
|
||||
if( adc083x->sgl == 0 )
|
||||
{
|
||||
negative_channel = positive_channel ^ 1;
|
||||
}
|
||||
@ -195,22 +202,22 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
}
|
||||
}
|
||||
|
||||
if (positive_channel != ADC083X_AGND)
|
||||
if( positive_channel != ADC083X_AGND )
|
||||
{
|
||||
positive = adc083x->input_callback_r(device, positive_channel) - gnd;
|
||||
}
|
||||
if (negative_channel != ADC083X_AGND)
|
||||
{
|
||||
negative = adc083x->input_callback_r(device, negative_channel) - gnd;
|
||||
positive = adc083x->input_callback_r( device, positive_channel ) - gnd;
|
||||
}
|
||||
|
||||
result = (int)(((positive - negative) * 255) / vref);
|
||||
logerror("%d", result);
|
||||
if (result < 0)
|
||||
if( negative_channel != ADC083X_AGND )
|
||||
{
|
||||
negative = adc083x->input_callback_r( device, negative_channel ) - gnd;
|
||||
}
|
||||
|
||||
result = (int) ( ( ( positive - negative ) * 255 ) / vref );
|
||||
if( result < 0 )
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else if (result > 255)
|
||||
else if( result > 255 )
|
||||
{
|
||||
result = 255;
|
||||
}
|
||||
@ -222,25 +229,25 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
adc083x_clk_write
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
WRITE_LINE_DEVICE_HANDLER( adc083x_clk_write )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
if (adc083x->clk != data)
|
||||
if( adc083x->clk != state )
|
||||
{
|
||||
verboselog(device->machine, 2, "adc083x_clk_write( %s, %d )\n", device->tag, data);
|
||||
verboselog( 2, device->machine, "adc083x_clk_write( %s, %d )\n", device->tag, state );
|
||||
}
|
||||
|
||||
if (adc083x->cs == 0)
|
||||
if( adc083x->cs == 0 )
|
||||
{
|
||||
if (adc083x->clk == 0 && data != 0)
|
||||
if( adc083x->clk == 0 && state != 0 )
|
||||
{
|
||||
switch (adc083x->state)
|
||||
switch( adc083x->state )
|
||||
{
|
||||
case STATE_WAIT_FOR_START:
|
||||
if (adc083x->di != 0)
|
||||
if( adc083x->di != 0 )
|
||||
{
|
||||
verboselog(device->machine, 1, "adc083x %s got start bit\n", device->tag);
|
||||
verboselog( 1, device->machine, "adc083x %s got start bit\n", device->tag );
|
||||
adc083x->state = STATE_SHIFT_MUX;
|
||||
adc083x->sars = 0;
|
||||
adc083x->sgl = 0;
|
||||
@ -251,84 +258,91 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
}
|
||||
else
|
||||
{
|
||||
verboselog(device->machine, 1, "adc083x %s not start bit\n", device->tag);
|
||||
verboselog( 1, device->machine, "adc083x %s not start bit\n", device->tag );
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SHIFT_MUX:
|
||||
switch (adc083x->bit)
|
||||
switch( adc083x->bit )
|
||||
{
|
||||
case 0:
|
||||
if (adc083x->di != 0)
|
||||
if( adc083x->di != 0 )
|
||||
{
|
||||
adc083x->sgl = 1;
|
||||
}
|
||||
verboselog(device->machine, 1, "adc083x %s sgl <- %d\n", device->tag, adc083x->sgl);
|
||||
verboselog( 1, device->machine, "adc083x %s sgl <- %d\n", device->tag, adc083x->sgl );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (adc083x->di != 0)
|
||||
if( adc083x->di != 0 )
|
||||
{
|
||||
adc083x->odd = 1;
|
||||
}
|
||||
verboselog(device->machine, 1, "adc083x %s odd <- %d\n", device->tag, adc083x->odd);
|
||||
verboselog( 1, device->machine, "adc083x %s odd <- %d\n", device->tag, adc083x->odd );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (adc083x->di != 0)
|
||||
if( adc083x->di != 0 )
|
||||
{
|
||||
adc083x->sel1 = 1;
|
||||
}
|
||||
verboselog(device->machine, 1, "adc083x %s sel1 <- %d\n", device->tag, adc083x->sel1);
|
||||
verboselog( 1, device->machine, "adc083x %s sel1 <- %d\n", device->tag, adc083x->sel1 );
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (adc083x->di != 0)
|
||||
if( adc083x->di != 0 )
|
||||
{
|
||||
adc083x->sel0 = 1;
|
||||
}
|
||||
verboselog(device->machine, 1, "adc083x %s sel0 <- %d\n", device->tag, adc083x->sel0);
|
||||
verboselog( 1, device->machine, "adc083x %s sel0 <- %d\n", device->tag, adc083x->sel0 );
|
||||
break;
|
||||
}
|
||||
|
||||
adc083x->bit++;
|
||||
if (adc083x->bit == adc083x->mux_bits)
|
||||
if( adc083x->bit == adc083x->mux_bits )
|
||||
{
|
||||
adc083x->state = STATE_MUX_SETTLE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STATE_WAIT_FOR_SE:
|
||||
adc083x->sars = 0;
|
||||
if (device->type == ADC0838 && adc083x->se != 0)
|
||||
if( device->type == ADC0838 && adc083x->se != 0 )
|
||||
{
|
||||
verboselog(device->machine, 1, "adc083x %s not se\n", device->tag);
|
||||
verboselog( 1, device->machine, "adc083x %s not se\n", device->tag );
|
||||
}
|
||||
else
|
||||
{
|
||||
verboselog(device->machine, 1, "adc083x %s got se\n", device->tag);
|
||||
verboselog( 1, device->machine, "adc083x %s got se\n", device->tag );
|
||||
adc083x->state = STATE_OUTPUT_LSB_FIRST;
|
||||
adc083x->bit = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (adc083x->clk != 0 && data == 0)
|
||||
|
||||
if( adc083x->clk != 0 && state == 0 )
|
||||
{
|
||||
switch (adc083x->state)
|
||||
switch( adc083x->state )
|
||||
{
|
||||
case STATE_MUX_SETTLE:
|
||||
verboselog(device->machine, 1, "adc083x %s mux settle\n", device->tag);
|
||||
adc083x->output = adc083x_conversion(device);
|
||||
verboselog( 1, device->machine, "adc083x %s mux settle\n", device->tag );
|
||||
adc083x->output = adc083x_conversion( device );
|
||||
adc083x->state = STATE_OUTPUT_MSB_FIRST;
|
||||
adc083x->bit = 7;
|
||||
if (device->type == ADC0834 || device->type == ADC0838)
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
adc083x_clear_sars( device, adc083x );
|
||||
adc083x->_do = 0;
|
||||
break;
|
||||
|
||||
case STATE_OUTPUT_MSB_FIRST:
|
||||
adc083x->_do = (adc083x->output >> adc083x->bit) & 1;
|
||||
verboselog(device->machine, 1, "adc083x %s msb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do);
|
||||
adc083x->_do = ( adc083x->output >> adc083x->bit ) & 1;
|
||||
verboselog( 1, device->machine, "adc083x %s msb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do );
|
||||
|
||||
adc083x->bit--;
|
||||
if (adc083x->bit < 0)
|
||||
if( adc083x->bit < 0 )
|
||||
{
|
||||
if (device->type == ADC0831)
|
||||
if( device->type == ADC0831 )
|
||||
{
|
||||
adc083x->state = STATE_FINISHED;
|
||||
}
|
||||
@ -338,15 +352,18 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_OUTPUT_LSB_FIRST:
|
||||
adc083x->_do = (adc083x->output >> adc083x->bit) & 1;
|
||||
verboselog(device->machine, 1, "adc083x %s lsb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do);
|
||||
adc083x->_do = ( adc083x->output >> adc083x->bit ) & 1;
|
||||
verboselog( 1, device->machine, "adc083x %s lsb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do );
|
||||
|
||||
adc083x->bit++;
|
||||
if (adc083x->bit == 8)
|
||||
if( adc083x->bit == 8 )
|
||||
{
|
||||
adc083x->state = STATE_FINISHED;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_FINISHED:
|
||||
adc083x->state = STATE_IDLE;
|
||||
adc083x->_do = 0;
|
||||
@ -355,50 +372,50 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
}
|
||||
}
|
||||
|
||||
adc083x->clk = data;
|
||||
adc083x->clk = state;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
adc083x_di_write
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_di_write )
|
||||
WRITE_LINE_DEVICE_HANDLER( adc083x_di_write )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
if (adc083x->di != data)
|
||||
if( adc083x->di != state )
|
||||
{
|
||||
verboselog(device->machine, 2, "adc083x_di_write( %s, %d )\n", device->tag, data);
|
||||
verboselog( 2, device->machine, "adc083x_di_write( %s, %d )\n", device->tag, state );
|
||||
}
|
||||
|
||||
adc083x->di = data;
|
||||
adc083x->di = state;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
adc083x_se_write
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_se_write )
|
||||
WRITE_LINE_DEVICE_HANDLER( adc083x_se_write )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
if (adc083x->se != data)
|
||||
if( adc083x->se != state )
|
||||
{
|
||||
verboselog(device->machine, 2, "adc083x_se_write( %s, %d )\n", device->tag, data);
|
||||
verboselog( 2, device->machine, "adc083x_se_write( %s, %d )\n", device->tag, state );
|
||||
}
|
||||
|
||||
adc083x->se = data;
|
||||
adc083x->se = state;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
adc083x_sars_read
|
||||
-------------------------------------------------*/
|
||||
|
||||
READ8_DEVICE_HANDLER( adc083x_sars_read )
|
||||
READ_LINE_DEVICE_HANDLER( adc083x_sars_read )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->sars);
|
||||
verboselog( 1, device->machine, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->sars );
|
||||
return adc083x->sars;
|
||||
}
|
||||
|
||||
@ -406,11 +423,11 @@ READ8_DEVICE_HANDLER( adc083x_sars_read )
|
||||
adc083x_do_read
|
||||
-------------------------------------------------*/
|
||||
|
||||
READ8_DEVICE_HANDLER( adc083x_do_read )
|
||||
READ_LINE_DEVICE_HANDLER( adc083x_do_read )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->_do);
|
||||
verboselog( 1, device->machine, "adc083x_do_read( %s ) %d\n", device->tag, adc083x->_do );
|
||||
return adc083x->_do;
|
||||
}
|
||||
|
||||
@ -421,27 +438,37 @@ READ8_DEVICE_HANDLER( adc083x_do_read )
|
||||
|
||||
static DEVICE_START( adc0831 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
const adc0831_interface *intf = get_interface(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
const adc083x_interface *intf = get_interface( device );
|
||||
|
||||
if (device->type == ADC0831)
|
||||
adc083x->cs = 0;
|
||||
adc083x->clk = 0;
|
||||
adc083x->di = 0;
|
||||
adc083x->se = 0;
|
||||
adc083x_clear_sars( device, adc083x );
|
||||
adc083x->_do = 1;
|
||||
adc083x->sgl = 0;
|
||||
adc083x->odd = 0;
|
||||
adc083x->sel1 = 0;
|
||||
adc083x->sel0 = 0;
|
||||
adc083x->state = STATE_IDLE;
|
||||
adc083x->bit = 0;
|
||||
adc083x->output = 0;
|
||||
|
||||
if( device->type == ADC0831 )
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
adc083x->mux_bits = 0;
|
||||
}
|
||||
else if (device->type == ADC0832)
|
||||
else if( device->type == ADC0832 )
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
adc083x->mux_bits = 2;
|
||||
}
|
||||
else if (device->type == ADC0834)
|
||||
else if( device->type == ADC0834 )
|
||||
{
|
||||
adc083x->sars = 0;
|
||||
adc083x->mux_bits = 3;
|
||||
}
|
||||
else if (device->type == ADC0838)
|
||||
else if( device->type == ADC0838 )
|
||||
{
|
||||
adc083x->sars = 0;
|
||||
adc083x->mux_bits = 4;
|
||||
}
|
||||
|
||||
@ -449,20 +476,20 @@ static DEVICE_START( adc0831 )
|
||||
adc083x->input_callback_r = intf->input_callback_r;
|
||||
|
||||
/* register for state saving */
|
||||
state_save_register_device_item(device, 0, adc083x->cs);
|
||||
state_save_register_device_item(device, 0, adc083x->clk);
|
||||
state_save_register_device_item(device, 0, adc083x->di);
|
||||
state_save_register_device_item(device, 0, adc083x->se);
|
||||
state_save_register_device_item(device, 0, adc083x->sars);
|
||||
state_save_register_device_item(device, 0, adc083x->_do);
|
||||
state_save_register_device_item(device, 0, adc083x->sgl);
|
||||
state_save_register_device_item(device, 0, adc083x->odd);
|
||||
state_save_register_device_item(device, 0, adc083x->sel1);
|
||||
state_save_register_device_item(device, 0, adc083x->sel0);
|
||||
state_save_register_device_item(device, 0, adc083x->state);
|
||||
state_save_register_device_item(device, 0, adc083x->bit);
|
||||
state_save_register_device_item(device, 0, adc083x->output);
|
||||
state_save_register_device_item(device, 0, adc083x->mux_bits);
|
||||
state_save_register_device_item( device, 0, adc083x->cs );
|
||||
state_save_register_device_item( device, 0, adc083x->clk );
|
||||
state_save_register_device_item( device, 0, adc083x->di );
|
||||
state_save_register_device_item( device, 0, adc083x->se );
|
||||
state_save_register_device_item( device, 0, adc083x->sars );
|
||||
state_save_register_device_item( device, 0, adc083x->_do );
|
||||
state_save_register_device_item( device, 0, adc083x->sgl );
|
||||
state_save_register_device_item( device, 0, adc083x->odd );
|
||||
state_save_register_device_item( device, 0, adc083x->sel1 );
|
||||
state_save_register_device_item( device, 0, adc083x->sel0 );
|
||||
state_save_register_device_item( device, 0, adc083x->state );
|
||||
state_save_register_device_item( device, 0, adc083x->bit );
|
||||
state_save_register_device_item( device, 0, adc083x->output );
|
||||
state_save_register_device_item( device, 0, adc083x->mux_bits );
|
||||
}
|
||||
|
||||
|
||||
@ -472,20 +499,11 @@ static DEVICE_START( adc0831 )
|
||||
|
||||
static DEVICE_RESET( adc0831 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token( device );
|
||||
|
||||
adc083x->cs = 0;
|
||||
adc083x->clk = 0;
|
||||
adc083x->di = 0;
|
||||
adc083x->se = 0;
|
||||
adc083x_clear_sars( device, adc083x );
|
||||
adc083x->_do = 1;
|
||||
adc083x->sgl = 0;
|
||||
adc083x->odd = 0;
|
||||
adc083x->sel1 = 0;
|
||||
adc083x->sel0 = 0;
|
||||
adc083x->state = STATE_IDLE;
|
||||
adc083x->bit = 0;
|
||||
adc083x->output = 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -494,24 +512,24 @@ static DEVICE_RESET( adc0831 )
|
||||
|
||||
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
|
||||
|
||||
#define DEVTEMPLATE_ID(p,s) p##adc0831##s
|
||||
#define DEVTEMPLATE_ID( p, s ) p##adc0831##s
|
||||
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
|
||||
#define DEVTEMPLATE_NAME "A/D Converters 0831"
|
||||
#define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 083x"
|
||||
#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0832##s
|
||||
#define DEVTEMPLATE_DERIVED_ID( p, s ) p##adc0832##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES 0
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0832"
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0834##s
|
||||
#define DEVTEMPLATE_DERIVED_ID( p, s ) p##adc0834##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES 0
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0834"
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0838##s
|
||||
#define DEVTEMPLATE_DERIVED_ID( p, s ) p##adc0838##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES 0
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0838"
|
||||
#include "devtempl.h"
|
||||
|
@ -59,8 +59,8 @@
|
||||
|
||||
typedef double (*adc083x_input_convert_func)(const device_config *device, UINT8 input);
|
||||
|
||||
typedef struct _adc0831_interface adc0831_interface;
|
||||
struct _adc0831_interface
|
||||
typedef struct _adc083x_interface adc083x_interface;
|
||||
struct _adc083x_interface
|
||||
{
|
||||
adc083x_input_convert_func input_callback_r;
|
||||
};
|
||||
@ -76,11 +76,11 @@ DEVICE_GET_INFO( adc0832 );
|
||||
DEVICE_GET_INFO( adc0834 );
|
||||
DEVICE_GET_INFO( adc0838 );
|
||||
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_cs_write );
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_clk_write );
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_di_write );
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_se_write );
|
||||
extern READ8_DEVICE_HANDLER( adc083x_sars_read );
|
||||
extern READ8_DEVICE_HANDLER( adc083x_do_read );
|
||||
extern WRITE_LINE_DEVICE_HANDLER( adc083x_cs_write );
|
||||
extern WRITE_LINE_DEVICE_HANDLER( adc083x_clk_write );
|
||||
extern WRITE_LINE_DEVICE_HANDLER( adc083x_di_write );
|
||||
extern WRITE_LINE_DEVICE_HANDLER( adc083x_se_write );
|
||||
extern READ_LINE_DEVICE_HANDLER( adc083x_sars_read );
|
||||
extern READ_LINE_DEVICE_HANDLER( adc083x_do_read );
|
||||
|
||||
#endif /* __ADC083X_H__ */
|
||||
|
@ -368,6 +368,12 @@ static UINT16 input_port_read16(const input_port_config *port, offs_t offset, UI
|
||||
static UINT32 input_port_read32(const input_port_config *port, offs_t offset, UINT32 mem_mask);
|
||||
static UINT64 input_port_read64(const input_port_config *port, offs_t offset, UINT64 mem_mask);
|
||||
|
||||
/* output port handlers */
|
||||
static void input_port_write8(const input_port_config *port, offs_t offset, UINT8 data);
|
||||
static void input_port_write16(const input_port_config *port, offs_t offset, UINT16 data, UINT16 mem_mask);
|
||||
static void input_port_write32(const input_port_config *port, offs_t offset, UINT32 data, UINT32 mem_mask);
|
||||
static void input_port_write64(const input_port_config *port, offs_t offset, UINT64 data, UINT64 mem_mask);
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -1372,6 +1378,32 @@ void memory_install_read_port_handler(const address_space *space, offs_t addrsta
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memory_install_write_port_handler - install a
|
||||
new 8-bit input port handler into the given
|
||||
address space
|
||||
-------------------------------------------------*/
|
||||
|
||||
void memory_install_write_port_handler(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag)
|
||||
{
|
||||
const input_port_config *port = input_port_by_tag(space->machine->portconfig, tag);
|
||||
address_space *spacerw = (address_space *)space;
|
||||
genf *handler = NULL;
|
||||
|
||||
if (port == NULL)
|
||||
fatalerror("Non-existent port referenced: '%s'\n", tag);
|
||||
switch (space->dbits)
|
||||
{
|
||||
case 8: handler = (genf *)input_port_write8; break;
|
||||
case 16: handler = (genf *)input_port_write16; break;
|
||||
case 32: handler = (genf *)input_port_write32; break;
|
||||
case 64: handler = (genf *)input_port_write64; break;
|
||||
}
|
||||
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, (void *)port, tag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEBUGGER HELPERS
|
||||
***************************************************************************/
|
||||
@ -1744,6 +1776,25 @@ static void memory_init_populate(running_machine *machine)
|
||||
space_map_range_private(space, ROW_READ, bits, entry->read_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, handler, (void *)port, entry->read_porttag);
|
||||
}
|
||||
|
||||
/* if we have a write port tag, look it up */
|
||||
if (entry->write_porttag != NULL)
|
||||
{
|
||||
const input_port_config *port = input_port_by_tag(machine->portconfig, entry->write_porttag);
|
||||
int bits = (entry->write_bits == 0) ? space->dbits : entry->write_bits;
|
||||
genf *handler = NULL;
|
||||
|
||||
if (port == NULL)
|
||||
fatalerror("Non-existent port referenced: '%s'\n", entry->write_porttag);
|
||||
switch (bits)
|
||||
{
|
||||
case 8: handler = (genf *)input_port_write8; break;
|
||||
case 16: handler = (genf *)input_port_write16; break;
|
||||
case 32: handler = (genf *)input_port_write32; break;
|
||||
case 64: handler = (genf *)input_port_write64; break;
|
||||
}
|
||||
space_map_range_private(space, ROW_WRITE, bits, entry->write_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, handler, (void *)port, entry->write_porttag);
|
||||
}
|
||||
|
||||
/* install the read handler if present */
|
||||
if (rhandler.generic != NULL)
|
||||
{
|
||||
@ -2134,6 +2185,11 @@ static void map_detokenize(address_map *map, const game_driver *driver, const ch
|
||||
entry->read_porttag = TOKEN_GET_STRING(tokens);
|
||||
break;
|
||||
|
||||
case ADDRMAP_TOKEN_WRITE_PORT:
|
||||
check_entry_field(write_porttag);
|
||||
entry->write_porttag = TOKEN_GET_STRING(tokens);
|
||||
break;
|
||||
|
||||
case ADDRMAP_TOKEN_REGION:
|
||||
check_entry_field(region);
|
||||
TOKEN_UNGET_UINT32(tokens);
|
||||
@ -3540,6 +3596,32 @@ static UINT64 input_port_read64(const input_port_config *port, offs_t offset, UI
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
output port handlers
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void input_port_write8(const input_port_config *port, offs_t offset, UINT8 data)
|
||||
{
|
||||
input_port_write_direct(port, data, 0xff);
|
||||
}
|
||||
|
||||
static void input_port_write16(const input_port_config *port, offs_t offset, UINT16 data, UINT16 mem_mask)
|
||||
{
|
||||
input_port_write_direct(port, data, mem_mask);
|
||||
}
|
||||
|
||||
static void input_port_write32(const input_port_config *port, offs_t offset, UINT32 data, UINT32 mem_mask)
|
||||
{
|
||||
input_port_write_direct(port, data, mem_mask);
|
||||
}
|
||||
|
||||
static void input_port_write64(const input_port_config *port, offs_t offset, UINT64 data, UINT64 mem_mask)
|
||||
{
|
||||
input_port_write_direct(port, data, mem_mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
STUB HANDLERS THAT MAP TO BYTE READS
|
||||
***************************************************************************/
|
||||
|
@ -72,6 +72,7 @@ enum
|
||||
ADDRMAP_TOKEN_DEVICE_READ,
|
||||
ADDRMAP_TOKEN_DEVICE_WRITE,
|
||||
ADDRMAP_TOKEN_READ_PORT,
|
||||
ADDRMAP_TOKEN_WRITE_PORT,
|
||||
ADDRMAP_TOKEN_REGION,
|
||||
ADDRMAP_TOKEN_SHARE,
|
||||
ADDRMAP_TOKEN_BASEPTR,
|
||||
@ -225,6 +226,7 @@ struct _address_map_entry
|
||||
const char * read_name; /* read handler callback name */
|
||||
const char * read_devtag; /* read tag for the relevant device */
|
||||
const char * read_porttag; /* tag for input port reading */
|
||||
const char * write_porttag; /* tag for output port writing */
|
||||
write_handler write; /* write handler callback */
|
||||
UINT8 write_bits; /* bits for the write handler callback (0=default, 1=8, 2=16, 3=32) */
|
||||
UINT8 write_mask; /* mask bits indicating which subunits to process */
|
||||
@ -738,6 +740,10 @@ union _addrmap64_token
|
||||
TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ_PORT, 8, 0, 8, 0, 8), \
|
||||
TOKEN_STRING(_tag),
|
||||
|
||||
#define AM_WRITE_PORT(_tag) \
|
||||
TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_WRITE_PORT, 8, 0, 8, 0, 8), \
|
||||
TOKEN_STRING(_tag),
|
||||
|
||||
#define AM_REGION(_tag, _offs) \
|
||||
TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_REGION, 8, _offs, 32), \
|
||||
TOKEN_STRING(_tag),
|
||||
|
@ -1586,6 +1586,13 @@ static int validate_devices(int drivnum, const machine_config *config, const inp
|
||||
mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->read_porttag);
|
||||
error = TRUE;
|
||||
}
|
||||
|
||||
/* make sure ports exist */
|
||||
if (entry->write_porttag != NULL && input_port_by_tag(portlist, entry->write_porttag) == NULL)
|
||||
{
|
||||
mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->write_porttag);
|
||||
error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* release the address map */
|
||||
|
@ -896,20 +896,6 @@ static WRITE32_HANDLER( sound020_w )
|
||||
|
||||
/* National Semiconductor ADC0834 4-channel serial ADC emulation */
|
||||
|
||||
static READ32_HANDLER( adc0834_r )
|
||||
{
|
||||
const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
|
||||
return adc083x_do_read(adc0834, 0) << 24;
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER( adc0834_w )
|
||||
{
|
||||
const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
|
||||
adc083x_clk_write(adc0834, 0, (data >> 24) & 1);
|
||||
adc083x_di_write(adc0834, 0, (data >> 25) & 1);
|
||||
adc083x_cs_write(adc0834, 0, (data >> 26) & 1);
|
||||
}
|
||||
|
||||
static double adc0834_callback( const device_config *device, UINT8 input )
|
||||
{
|
||||
switch (input)
|
||||
@ -924,7 +910,7 @@ static double adc0834_callback( const device_config *device, UINT8 input )
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const adc0831_interface konamigx_adc_interface = {
|
||||
static const adc083x_interface konamigx_adc_interface = {
|
||||
adc0834_callback
|
||||
};
|
||||
|
||||
@ -1235,8 +1221,8 @@ static ADDRESS_MAP_START( gx_type1_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0xd90000, 0xd97fff) AM_RAM_WRITE(konamigx_palette_w) AM_BASE(&paletteram32)
|
||||
AM_RANGE(0xdc0000, 0xdc1fff) AM_RAM // LAN RAM? (Racin' Force has, Open Golf doesn't)
|
||||
AM_RANGE(0xdd0000, 0xdd00ff) AM_READNOP AM_WRITENOP // LAN board
|
||||
AM_RANGE(0xdda000, 0xddafff) AM_WRITE(adc0834_w)
|
||||
AM_RANGE(0xddc000, 0xddcfff) AM_READ(adc0834_r)
|
||||
AM_RANGE(0xdda000, 0xddafff) AM_WRITE_PORT("ADC-WRPORT")
|
||||
AM_RANGE(0xddc000, 0xddcfff) AM_READ_PORT("ADC-RDPORT")
|
||||
AM_RANGE(0xdde000, 0xdde003) AM_WRITE(type1_cablamps_w)
|
||||
AM_RANGE(0xe00000, 0xe0001f) AM_RAM AM_BASE((UINT32**)&K053936_0_ctrl)
|
||||
AM_RANGE(0xe20000, 0xe2000f) AM_WRITENOP
|
||||
@ -1515,8 +1501,6 @@ static MACHINE_DRIVER_START( konamigx )
|
||||
MDRV_SOUND_CONFIG(k054539_config)
|
||||
MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
|
||||
MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
|
||||
|
||||
MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( dragoonj )
|
||||
@ -1552,6 +1536,8 @@ static MACHINE_DRIVER_START( opengolf )
|
||||
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(gx_type1_map)
|
||||
|
||||
MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( racinfrc )
|
||||
@ -1564,6 +1550,8 @@ static MACHINE_DRIVER_START( racinfrc )
|
||||
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(gx_type1_map)
|
||||
|
||||
MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( gxtype3 )
|
||||
@ -1778,11 +1766,19 @@ static INPUT_PORTS_START( racinfrc )
|
||||
/* racin force needs Player 2 Button 1 ("IN3" & 0x10) set to get past the calibration screen */
|
||||
PORT_INCLUDE( konamigx )
|
||||
|
||||
PORT_START("ADC-WRPORT")
|
||||
PORT_BIT( 0x1000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_clk_write)
|
||||
PORT_BIT( 0x2000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_di_write)
|
||||
PORT_BIT( 0x4000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_cs_write)
|
||||
|
||||
PORT_START("ADC-RDPORT")
|
||||
PORT_BIT( 0x1000000, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("adc0834", adc083x_do_read)
|
||||
|
||||
PORT_START("AN0") /* mask default type sens delta min max */
|
||||
PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x38,0xc8) PORT_SENSITIVITY(35) PORT_KEYDELTA(5)
|
||||
PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x38,0xc8) PORT_SENSITIVITY(35) PORT_KEYDELTA(5) PORT_REVERSE
|
||||
|
||||
PORT_START("AN1")
|
||||
PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_MINMAX(0,0x68) PORT_SENSITIVITY(35) PORT_KEYDELTA(5) PORT_CODE_INC(KEYCODE_LCONTROL)
|
||||
PORT_BIT( 0xff, 0xf0, IPT_PEDAL ) PORT_MINMAX(0x90,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(5) PORT_CODE_INC(KEYCODE_LCONTROL) PORT_REVERSE
|
||||
INPUT_PORTS_END
|
||||
|
||||
static INPUT_PORTS_START( le2 )
|
||||
|
@ -419,17 +419,7 @@ static READ32_HANDLER( mb89371_r )
|
||||
static READ32_HANDLER( jamma_r )
|
||||
{
|
||||
running_machine *machine = space->machine;
|
||||
const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
|
||||
UINT32 data = 0;
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
case 0:
|
||||
data = input_port_read(machine, "IN0");
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
data = input_port_read(machine, "IN1");
|
||||
UINT32 data = input_port_read(machine, "IN1");
|
||||
data |= 0x000000c0;
|
||||
|
||||
if( has_ds2401[ security_cart_number ] )
|
||||
@ -437,8 +427,6 @@ static READ32_HANDLER( jamma_r )
|
||||
data |= ds2401_read( machine, security_cart_number ) << 14;
|
||||
}
|
||||
|
||||
data |= adc083x_do_read(adc0834, 0) << 16;
|
||||
|
||||
switch( chiptype[ security_cart_number ] )
|
||||
{
|
||||
case 1:
|
||||
@ -462,42 +450,12 @@ static READ32_HANDLER( jamma_r )
|
||||
{
|
||||
data |= ( 1 << 27 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
data = input_port_read(machine, "IN2");
|
||||
break;
|
||||
case 3:
|
||||
data = input_port_read(machine, "IN3");
|
||||
break;
|
||||
}
|
||||
|
||||
verboselog( machine, 2, "jamma_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER( jamma_w )
|
||||
{
|
||||
running_machine *machine = space->machine;
|
||||
const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
|
||||
verboselog( machine, 2, "jamma_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
|
||||
|
||||
switch( offset )
|
||||
{
|
||||
case 0:
|
||||
adc083x_cs_write(adc0834, 0, (data >> 1) & 1);
|
||||
adc083x_clk_write(adc0834, 0, (data >> 2) & 1);
|
||||
adc083x_di_write(adc0834, 0, (data >> 0) & 1);
|
||||
adc083x_se_write(adc0834, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
verboselog( machine, 0, "jamma_w: unhandled offset %08x %08x %08x\n", offset, mem_mask, data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 control;
|
||||
|
||||
static READ32_HANDLER( control_r )
|
||||
@ -1409,7 +1367,10 @@ static READ32_HANDLER( k573_counter_r )
|
||||
static ADDRESS_MAP_START( konami573_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_SHARE(1) AM_BASE(&g_p_n_psxram) AM_SIZE(&g_n_psxramsize) /* ram */
|
||||
AM_RANGE(0x1f000000, 0x1f3fffff) AM_READWRITE( flash_r, flash_w )
|
||||
AM_RANGE(0x1f400000, 0x1f40001f) AM_READWRITE( jamma_r, jamma_w )
|
||||
AM_RANGE(0x1f400000, 0x1f400003) AM_READ_PORT( "IN0" ) AM_WRITE_PORT( "OUT0" )
|
||||
AM_RANGE(0x1f400004, 0x1f400007) AM_READ( jamma_r )
|
||||
AM_RANGE(0x1f400008, 0x1f40000b) AM_READ_PORT( "IN2" )
|
||||
AM_RANGE(0x1f40000c, 0x1f40000f) AM_READ_PORT( "IN3" )
|
||||
AM_RANGE(0x1f480000, 0x1f48000f) AM_READWRITE( atapi_r, atapi_w ) // IDE controller, used mostly in ATAPI mode (only 3 pure IDE commands seen so far)
|
||||
AM_RANGE(0x1f500000, 0x1f500003) AM_READWRITE( control_r, control_w ) // Konami can't make a game without a "control" register.
|
||||
AM_RANGE(0x1f560000, 0x1f560003) AM_WRITE( atapi_reset_w )
|
||||
@ -2876,7 +2837,7 @@ static double analogue_inputs_callback( const device_config *device, UINT8 input
|
||||
}
|
||||
|
||||
|
||||
static const adc0831_interface konami573_adc_interface = {
|
||||
static const adc083x_interface konami573_adc_interface = {
|
||||
analogue_inputs_callback
|
||||
};
|
||||
|
||||
@ -2932,6 +2893,11 @@ static INPUT_PORTS_START( konami573 )
|
||||
PORT_START("IN0")
|
||||
PORT_BIT( 0xffffffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("OUT0")
|
||||
PORT_BIT( 0x00000002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_cs_write)
|
||||
PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_clk_write)
|
||||
PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0834", adc083x_di_write)
|
||||
|
||||
PORT_START("IN1")
|
||||
PORT_DIPNAME( 0x00000001, 0x00000001, "Unused 1" ) PORT_DIPLOCATION( "DIP SW:1" )
|
||||
PORT_DIPSETTING( 0x00000001, DEF_STR( Off ) )
|
||||
@ -2956,7 +2922,7 @@ static INPUT_PORTS_START( konami573 )
|
||||
// PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
// PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
// PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x00010000, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* adc0834 d0 */
|
||||
PORT_BIT( 0x00010000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("adc0834", adc083x_do_read)
|
||||
// PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x00040000, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* x76f041/zs01 sda */
|
||||
PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
@ -280,17 +280,10 @@ static VIDEO_UPDATE( zr107 )
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static CUSTOM_INPUT( adcdo_r )
|
||||
{
|
||||
const device_config *adc0838 = devtag_get_device(field->port->machine, "adc0838");
|
||||
return adc083x_do_read(adc0838, 0);
|
||||
}
|
||||
|
||||
static READ8_HANDLER( sysreg_r )
|
||||
{
|
||||
UINT32 r = 0;
|
||||
const device_config *adc0838 = devtag_get_device(space->machine, "adc0838");
|
||||
static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" };
|
||||
static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3", "IN4" };
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
@ -298,17 +291,8 @@ static READ8_HANDLER( sysreg_r )
|
||||
case 1: /* I/O port 1 */
|
||||
case 2: /* I/O port 2 */
|
||||
case 3: /* System Port 0 */
|
||||
r = input_port_read(space->machine, portnames[offset]);
|
||||
break;
|
||||
|
||||
case 4: /* System Port 1 */
|
||||
/*
|
||||
0x80 = PARAACK
|
||||
0x40 = unused
|
||||
0x20 = SARS (A/D busy flag)
|
||||
0x10 = EEPDO (EEPROM DO)
|
||||
*/
|
||||
r = (adc083x_sars_read(adc0838, 0) << 5) | (eeprom_read_bit() << 4);
|
||||
r = input_port_read(space->machine, portnames[offset]);
|
||||
break;
|
||||
|
||||
case 5: /* Parallel data port */
|
||||
@ -319,8 +303,6 @@ static READ8_HANDLER( sysreg_r )
|
||||
|
||||
static WRITE8_HANDLER( sysreg_w )
|
||||
{
|
||||
const device_config *adc0838 = devtag_get_device(space->machine, "adc0838");
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
case 0: /* LED Register 0 */
|
||||
@ -369,9 +351,7 @@ static WRITE8_HANDLER( sysreg_w )
|
||||
if (data & 0x40) /* CG Board 0 IRQ Ack */
|
||||
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_IRQ0, CLEAR_LINE);
|
||||
set_cgboard_id((data >> 4) & 3);
|
||||
adc083x_cs_write(adc0838, 0, (data >> 2) & 1);
|
||||
adc083x_di_write(adc0838, 0, (data >> 1) & 1);
|
||||
adc083x_clk_write(adc0838, 0, (data >> 0) & 1);
|
||||
input_port_write(space->machine, "OUT4", data, 0xff);
|
||||
mame_printf_debug("System register 1 = %02X\n", data);
|
||||
break;
|
||||
|
||||
@ -541,7 +521,7 @@ ADDRESS_MAP_END
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
static INPUT_PORTS_START( midnrun )
|
||||
static INPUT_PORTS_START( zr107 )
|
||||
PORT_START("IN0")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) // View switch
|
||||
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) // Shift up
|
||||
@ -555,7 +535,22 @@ static INPUT_PORTS_START( midnrun )
|
||||
|
||||
PORT_START("IN2")
|
||||
PORT_BIT( 0x7f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(adcdo_r, NULL)
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("adc0838", adc083x_do_read)
|
||||
|
||||
PORT_START("IN4")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* PARAACK */
|
||||
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
|
||||
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("adc0838",adc083x_sars_read)
|
||||
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
|
||||
|
||||
PORT_START("OUT4")
|
||||
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0838", adc083x_cs_write)
|
||||
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0838", adc083x_di_write)
|
||||
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("adc0838", adc083x_clk_write)
|
||||
INPUT_PORTS_END
|
||||
|
||||
static INPUT_PORTS_START( midnrun )
|
||||
PORT_INCLUDE( zr107 )
|
||||
|
||||
PORT_START("IN3")
|
||||
PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
|
||||
@ -586,20 +581,7 @@ static INPUT_PORTS_START( midnrun )
|
||||
INPUT_PORTS_END
|
||||
|
||||
static INPUT_PORTS_START( windheat )
|
||||
PORT_START("IN0")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) // View switch
|
||||
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) // Shift up
|
||||
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) // Shift down
|
||||
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_TOGGLE // AT/MT switch
|
||||
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Service Button") PORT_CODE(KEYCODE_8)
|
||||
PORT_BIT( 0x0b, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("IN1")
|
||||
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("IN2")
|
||||
PORT_BIT( 0x7f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(adcdo_r, NULL)
|
||||
PORT_INCLUDE( zr107 )
|
||||
|
||||
PORT_START("IN3")
|
||||
PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
|
||||
@ -619,7 +601,7 @@ static INPUT_PORTS_START( windheat )
|
||||
PORT_DIPSETTING( 0x00, "Twin" )
|
||||
|
||||
PORT_START("ANALOG1") // Steering wheel
|
||||
PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(5) PORT_REVERSE
|
||||
PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(5)
|
||||
|
||||
PORT_START("ANALOG2") // Acceleration pedal
|
||||
PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(5)
|
||||
@ -630,20 +612,7 @@ static INPUT_PORTS_START( windheat )
|
||||
INPUT_PORTS_END
|
||||
|
||||
static INPUT_PORTS_START( jetwave )
|
||||
PORT_START("IN0")
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
|
||||
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
|
||||
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 )
|
||||
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 )
|
||||
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Service Button") PORT_CODE(KEYCODE_8)
|
||||
PORT_BIT( 0x0b, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("IN1")
|
||||
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("IN2")
|
||||
PORT_BIT( 0x7f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
|
||||
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(adcdo_r, NULL)
|
||||
PORT_INCLUDE( zr107 )
|
||||
|
||||
PORT_START("IN3")
|
||||
PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
|
||||
@ -705,7 +674,7 @@ static double adc0838_callback( const device_config *device, UINT8 input )
|
||||
}
|
||||
|
||||
|
||||
static const adc0831_interface zr107_adc_interface = {
|
||||
static const adc083x_interface zr107_adc_interface = {
|
||||
adc0838_callback
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user