Previous 15994 Revisions Next

r6977 Friday 8th January, 2010 at 19:33:02 UTC by Wilbert Pol
Added uPD1771 skeleton.
[src/mess]mess.mak
[src/mess/audio]upd1771.c* upd1771.h*
[src/mess/drivers]scv.c

src/mess/audio/upd1771.c
r0r6977
1/**********************************************************************
2
3    NEC uPD1771
4
5**********************************************************************/
6
7#include "sndintrf.h"
8#include "streams.h"
9#include "upd1771.h"
10
11
12#define LOG 1
13
14#define MAX_PACKET_SIZE 10
15
16
17typedef struct _upd1771_state upd1771_state;
18struct _upd1771_state
19{
20   sound_stream *channel;
21   devcb_resolved_write_line ack_out_func;
22   emu_timer *timer;
23
24   UINT8   packet[MAX_PACKET_SIZE];
25   UINT8   index;
26   UINT8   expected_bytes;
27};
28
29
30INLINE upd1771_state *get_safe_token(const device_config *device)
31{
32   assert(device != NULL);
33   assert(device->token != NULL);
34   assert(device->type == SOUND);
35   assert(sound_get_type(device) == SOUND_UPD1771C);
36   return (upd1771_state *)device->token;
37}
38
39
40WRITE8_DEVICE_HANDLER( upd1771_w )
41{
42   upd1771_state *state = get_safe_token( device );
43
44   if (LOG)
45      logerror( "upd1771_w: received byte 0x%02x\n", data );
46
47   state->packet[ state->index ] = data;
48   state->index = ( state->index + 1 ) % MAX_PACKET_SIZE;
49
50   devcb_call_write_line( &state->ack_out_func, 0 );
51
52   /* Trigger ACK after 512??? cycles */
53   timer_adjust_oneshot( state->timer, ticks_to_attotime( 512, device->clock ), 0 );
54}
55
56
57static STREAM_UPDATE( upd1771c_update )
58{
59//   upd1771_state *state = (upd1771_state *)param;
60   stream_sample_t *buffer = outputs[0];
61
62   while ( samples > 0 )
63   {
64      *buffer = 0;
65      buffer++;
66      samples--;
67   }
68}
69
70
71static TIMER_CALLBACK( upd1771c_callback )
72{
73   const device_config *device = (const device_config *)ptr;
74   upd1771_state *state = get_safe_token( device );
75
76   devcb_call_write_line( &state->ack_out_func, 1 );
77}
78
79
80static DEVICE_START( upd1771c )
81{
82   const upd1771_interface *intf = (const upd1771_interface *)device->static_config;
83   upd1771_state *state = get_safe_token( device );
84   int sample_rate = device->clock / 4;
85
86   /* resolve callbacks */
87   devcb_resolve_write_line( &state->ack_out_func, &intf->ack_callback, device );
88
89   state->timer = timer_alloc( device->machine, upd1771c_callback, (void *)device );
90
91   state->channel = stream_create( device, 0, 1, sample_rate, state, upd1771c_update );
92
93   state_save_register_device_item_array( device, 0, state->packet );
94   state_save_register_device_item(device, 0, state->index );
95   state_save_register_device_item(device, 0, state->expected_bytes );
96}
97
98
99static DEVICE_RESET( upd1771c )
100{
101   upd1771_state *state = get_safe_token( device );
102
103   state->index = 0;
104   state->expected_bytes = 0;
105}
106
107
108DEVICE_GET_INFO( upd1771c )
109{
110   switch (state)
111   {
112      /* --- the following bits of info are returned as 64-bit signed integers --- */
113      case DEVINFO_INT_TOKEN_BYTES:            info->i = sizeof(upd1771_state);            break;
114
115      /* --- the following bits of info are returned as pointers to functions --- */
116      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME( upd1771c );   break;
117      case DEVINFO_FCT_RESET:                  info->reset = DEVICE_RESET_NAME( upd1771c );   break;
118
119      /* --- the following bits of info are returned as NULL-terminated strings --- */
120      case DEVINFO_STR_NAME:                  strcpy(info->s, "NEC uPD1771C");            break;
121      case DEVINFO_STR_FAMILY:               strcpy(info->s, "NEC uPD1771");               break;
122      case DEVINFO_STR_VERSION:               strcpy(info->s, "1.0");                     break;
123      case DEVINFO_STR_SOURCE_FILE:            strcpy(info->s, __FILE__);                  break;
124      case DEVINFO_STR_CREDITS:               strcpy(info->s, "Copyright the MAME & MESS Teams"); break;
125   }
126}
127
src/mess/audio/upd1771.h
r0r6977
1/**********************************************************************
2
3    NEC uPD1771
4
5**********************************************************************/
6
7#ifndef __UPD1771_H__
8#define __UPD1771_H__
9
10#include "devcb.h"
11
12/***************************************************************************
13    TYPE DEFINITIONS
14***************************************************************************/
15
16typedef struct _upd1771_interface upd1771_interface;
17struct _upd1771_interface
18{
19   devcb_write_line   ack_callback;
20};
21
22
23/***************************************************************************
24    MACROS / CONSTANTS
25***************************************************************************/
26
27#define SOUND_UPD1771C DEVICE_GET_INFO_NAME(upd1771c)
28
29
30/***************************************************************************
31    PROTOTYPES
32***************************************************************************/
33
34DEVICE_GET_INFO( upd1771c );
35WRITE8_DEVICE_HANDLER( upd1771_w );
36
37#endif /* __UPD1771_H__ */
src/mess/mess.mak
r6976r6977
843843   $(MESS_DRIVERS)/gamepock.o   \
844844   $(MESS_MACHINE)/gamepock.o   \
845845   $(MESS_DRIVERS)/scv.o      \
846   $(MESS_AUDIO)/upd1771.o      \
846847
847848$(MESSOBJ)/epson.a:            \
848849   $(MESS_DRIVERS)/ex800.o      \
src/mess/drivers/scv.c
r6976r6977
66***************************************************************************/
77
88#include "driver.h"
9#include "devcb.h"
910#include "cpu/upd7810/upd7810.h"
1011#include "devices/cartslot.h"
12#include "audio/upd1771.h"
1113
1214
1315static WRITE8_HANDLER( scv_porta_w );
r6976r6977
2729
2830   AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_BASE( &scv_vram )   /* VRAM + 4 registers */
2931
32   AM_RANGE( 0x3600, 0x37ff ) AM_DEVWRITE( "upd1771c", upd1771_w )
33
3034   AM_RANGE( 0x8000, 0xff7f ) AM_ROM AM_REGION("cart", 0)
3135   AM_RANGE( 0xff80, 0xffff ) AM_RAM      /* upd7801 internal RAM */
3236ADDRESS_MAP_END
r6976r6977
522526}
523527
524528
529static WRITE_LINE_DEVICE_HANDLER( scv_upd1771_ack_w )
530{
531   cputag_set_input_line(device->machine, "maincpu", UPD7810_INTF1, (state) ? ASSERT_LINE : CLEAR_LINE);
532}
533
534
525535static MACHINE_START( scv )
526536{
527537   scv_vb_timer = timer_alloc( machine, scv_vb_callback, NULL );
r6976r6977
554564
555565
556566static const UPD7810_CONFIG scv_cpu_config = { TYPE_7801, NULL };
567static const upd1771_interface scv_upd1771c_config = { DEVCB_LINE( scv_upd1771_ack_w ) };
557568
558569
559570static MACHINE_DRIVER_START( scv )
r6976r6977
577588   MDRV_VIDEO_UPDATE( scv )
578589
579590   /* Sound is generated by UPD1771C clocked at XTAL_6MHz */
591   MDRV_SOUND_ADD( "upd1771c", UPD1771C, XTAL_6MHz )
592   MDRV_SOUND_CONFIG( scv_upd1771c_config )
580593
581594   MDRV_CARTSLOT_ADD( "cart" )
582595   MDRV_CARTSLOT_EXTENSION_LIST( "bin" )
r6976r6977
606619   MDRV_VIDEO_UPDATE( scv )
607620
608621   /* Sound is generated by UPD1771C clocked at XTAL_6MHz */
622   MDRV_SOUND_ADD( "upd1771c", UPD1771C, XTAL_6MHz )
623   MDRV_SOUND_CONFIG( scv_upd1771c_config )
624
609625   MDRV_CARTSLOT_ADD( "cart" )
610626   MDRV_CARTSLOT_EXTENSION_LIST( "bin" )
611627   MDRV_CARTSLOT_NOT_MANDATORY

Previous 15994 Revisions Next


© 1998-2018 The MESS Team