Previous 15994 Revisions Next

r4358 Friday 27th February, 2009 at 10:16:56 UTC by Dirk Best
Updated the TTL74145 device to use devcb
[src/mess/drivers]acrnsys1.c mz700.c sym1.c
[src/mess/layout]acrnsys1.lay
[src/mess/machine]74145.c 74145.h sym1.c

src/mess/machine/74145.c
r4357r4358
5353typedef struct _ttl74145_t ttl74145_t;
5454struct _ttl74145_t
5555{
56   devcb_resolved_write_line output_line_0;
57   devcb_resolved_write_line output_line_1;
58   devcb_resolved_write_line output_line_2;
59   devcb_resolved_write_line output_line_3;
60   devcb_resolved_write_line output_line_4;
61   devcb_resolved_write_line output_line_5;
62   devcb_resolved_write_line output_line_6;
63   devcb_resolved_write_line output_line_7;
64   devcb_resolved_write_line output_line_8;
65   devcb_resolved_write_line output_line_9;
66
5667   /* decoded number */
5768   int number;
5869};
5970
6071
72/*****************************************************************************
73    GLOBAL VARIABLES
74*****************************************************************************/
75
76const ttl74145_interface default_ttl74145 =
77{
78   DEVCB_NULL,
79   DEVCB_NULL,
80   DEVCB_NULL,
81   DEVCB_NULL,
82   DEVCB_NULL,
83   DEVCB_NULL,
84   DEVCB_NULL,
85   DEVCB_NULL,
86   DEVCB_NULL,
87   DEVCB_NULL
88};
89
90
6191/***************************************************************************
6292    IMPLEMENTATION
6393***************************************************************************/
r4357r4358
6696{
6797   assert(device != NULL);
6898   assert(device->token != NULL);
99   assert(device->type == TTL74145);
69100
70101   return (ttl74145_t *)device->token;
71102}
r4357r4358
81112   /* call output callbacks if the number changed */
82113   if (new_number != ttl74145->number)
83114   {
84      const ttl74145_interface *i = device->static_config;
85
86      if (i != NULL)
87      {
88         if (i->output_line_0) i->output_line_0(device, new_number == 0);
89         if (i->output_line_1) i->output_line_1(device, new_number == 1);
90         if (i->output_line_2) i->output_line_2(device, new_number == 2);
91         if (i->output_line_3) i->output_line_3(device, new_number == 3);
92         if (i->output_line_4) i->output_line_4(device, new_number == 4);
93         if (i->output_line_5) i->output_line_5(device, new_number == 5);
94         if (i->output_line_6) i->output_line_6(device, new_number == 6);
95         if (i->output_line_7) i->output_line_7(device, new_number == 7);
96         if (i->output_line_8) i->output_line_8(device, new_number == 8);
97         if (i->output_line_9) i->output_line_9(device, new_number == 9);
98      }
115      devcb_call_write_line(&ttl74145->output_line_0, new_number == 0);
116      devcb_call_write_line(&ttl74145->output_line_1, new_number == 1);
117      devcb_call_write_line(&ttl74145->output_line_2, new_number == 2);
118      devcb_call_write_line(&ttl74145->output_line_3, new_number == 3);
119      devcb_call_write_line(&ttl74145->output_line_4, new_number == 4);
120      devcb_call_write_line(&ttl74145->output_line_5, new_number == 5);
121      devcb_call_write_line(&ttl74145->output_line_6, new_number == 6);
122      devcb_call_write_line(&ttl74145->output_line_7, new_number == 7);
123      devcb_call_write_line(&ttl74145->output_line_8, new_number == 8);
124      devcb_call_write_line(&ttl74145->output_line_9, new_number == 9);
99125   }
100126
101127   /* update state */
r4357r4358
117143
118144static DEVICE_START( ttl74145 )
119145{
146   const ttl74145_interface *intf = device->static_config;
120147   ttl74145_t *ttl74145 = get_safe_token(device);
121148
122149   /* validate arguments */
123   assert(device != NULL);
124   assert(device->tag != NULL);
150   assert(device->static_config != NULL);
125151
126152   /* initialize with 0 */
127153   ttl74145->number = 0;
128154
155   /* resolve callbacks */
156   devcb_resolve_write_line(&ttl74145->output_line_0, &intf->output_line_0, device);
157   devcb_resolve_write_line(&ttl74145->output_line_1, &intf->output_line_1, device);
158   devcb_resolve_write_line(&ttl74145->output_line_2, &intf->output_line_2, device);
159   devcb_resolve_write_line(&ttl74145->output_line_3, &intf->output_line_3, device);
160   devcb_resolve_write_line(&ttl74145->output_line_4, &intf->output_line_4, device);
161   devcb_resolve_write_line(&ttl74145->output_line_5, &intf->output_line_5, device);
162   devcb_resolve_write_line(&ttl74145->output_line_6, &intf->output_line_6, device);
163   devcb_resolve_write_line(&ttl74145->output_line_7, &intf->output_line_7, device);
164   devcb_resolve_write_line(&ttl74145->output_line_8, &intf->output_line_8, device);
165   devcb_resolve_write_line(&ttl74145->output_line_9, &intf->output_line_9, device);
166
129167   /* register for state saving */
130168   state_save_register_item(device->machine, "ttl74145", device->tag, 0, ttl74145->number);
131169}
r4357r4358
165203      /* --- the following bits of info are returned as NULL-terminated strings --- */
166204      case DEVINFO_STR_NAME:               strcpy(info->s, "TTL74145");            break;
167205      case DEVINFO_STR_FAMILY:            strcpy(info->s, "TTL74145");            break;
168      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.1");                  break;
206      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.2");                  break;
169207      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);               break;
170208      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");      break;
171209   }
src/mess/machine/74145.h
r4357r4358
1/*****************************************************************************
2 *
3 * machine/74145.h
4 *
5 ****************************************************************************/
1/***************************************************************************
62
7#ifndef __TTL74145_H__
8#define __TTL74145_H__
3    TTL74145
94
5    BCD-to-Decimal decoder
106
11/***************************************************************************
12    MACROS
137***************************************************************************/
148
15#define TTL74145      DEVICE_GET_INFO_NAME(ttl74145)
9#ifndef __TTL74145_H__
10#define __TTL74145_H__
1611
12#include "devcb.h"
1713
14
1815/***************************************************************************
1916    TYPE DEFINITIONS
2017***************************************************************************/
2118
22typedef void (*ttl74145_output_line_func)(const device_config *device, int state);
23#define TTL74145_OUTPUT_LINE(name)   void name(const device_config *device, int state )
24
25
26/* interface */
2719typedef struct _ttl74145_interface ttl74145_interface;
2820struct _ttl74145_interface
2921{
30   /* outputs */
31   ttl74145_output_line_func output_line_0;
32   ttl74145_output_line_func output_line_1;
33   ttl74145_output_line_func output_line_2;
34   ttl74145_output_line_func output_line_3;
35   ttl74145_output_line_func output_line_4;
36   ttl74145_output_line_func output_line_5;
37   ttl74145_output_line_func output_line_6;
38   ttl74145_output_line_func output_line_7;
39   ttl74145_output_line_func output_line_8;
40   ttl74145_output_line_func output_line_9;
22   devcb_write_line output_line_0;
23   devcb_write_line output_line_1;
24   devcb_write_line output_line_2;
25   devcb_write_line output_line_3;
26   devcb_write_line output_line_4;
27   devcb_write_line output_line_5;
28   devcb_write_line output_line_6;
29   devcb_write_line output_line_7;
30   devcb_write_line output_line_8;
31   devcb_write_line output_line_9;
4132};
4233
4334
r4357r4358
5748    DEVICE CONFIGURATION MACROS
5849***************************************************************************/
5950
60#define MDRV_TTL74145_ADD(_tag) \
61   MDRV_DEVICE_ADD(_tag, TTL74145, 0)
51#define TTL74145   DEVICE_GET_INFO_NAME(ttl74145)
6252
63#define MDRV_TTL74145_CONFIG(_intrf) \
64   MDRV_DEVICE_CONFIG(_intrf)
53#define MDRV_TTL74145_ADD(_tag, _intf) \
54   MDRV_DEVICE_ADD(_tag, TTL74145, 0) \
55   MDRV_DEVICE_CONFIG(_intf)
6556
6657
58/***************************************************************************
59    DEFAULT INTERFACES
60***************************************************************************/
61
62extern const ttl74145_interface default_ttl74145;
63
64
6765#endif /* __TTL74145_H__ */
src/mess/machine/sym1.c
r4357r4358
3333******************************************************************************/
3434
3535
36static TTL74145_OUTPUT_LINE(sym1_74145_output_0_w)
36static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_0_w )
3737{
3838   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 0);
3939}
4040
4141
42static TTL74145_OUTPUT_LINE(sym1_74145_output_1_w)
42static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_1_w )
4343{
4444   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 1);
4545}
4646
4747
48static TTL74145_OUTPUT_LINE(sym1_74145_output_2_w)
48static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_2_w )
4949{
5050   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 2);
5151}
5252
5353
54static TTL74145_OUTPUT_LINE(sym1_74145_output_3_w)
54static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_3_w )
5555{
5656   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 3);
5757}
5858
5959
60static TTL74145_OUTPUT_LINE(sym1_74145_output_4_w)
60static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_4_w )
6161{
6262   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 4);
6363}
6464
6565
66static TTL74145_OUTPUT_LINE(sym1_74145_output_5_w)
66static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_5_w )
6767{
6868   if (state) timer_adjust_oneshot(led_update, LED_REFRESH_DELAY, 5);
6969}
r4357r4358
7575}
7676
7777
78/* The speaker is connected to output 6 of the 74145 */
79static TTL74145_OUTPUT_LINE(sym1_74145_output_6_w)
80{
81   const device_config *speaker = devtag_get_device(device->machine, SOUND, "speaker");
82   speaker_level_w(speaker, state);
83}
84
85
8678static UINT8 sym1_riot_a_r(const device_config *device, UINT8 olddata)
8779{
8880   int data = 0x7f;
r4357r4358
138130   riot_port_b = data;
139131
140132   /* first 4 pins are connected to the 74145 */
141   ttl74145_w( (device_config*)devtag_get_device(device->machine, TTL74145, "ttl74145"), 0, data & 0x0f);
133   ttl74145_w(devtag_get_device(device->machine, TTL74145, "ttl74145"), 0, data & 0x0f);
142134}
143135
144136
r4357r4358
153145
154146const ttl74145_interface sym1_ttl74145_intf =
155147{
156   sym1_74145_output_0_w,  /* connected to DS0 */
157   sym1_74145_output_1_w,  /* connected to DS1 */
158   sym1_74145_output_2_w,  /* connected to DS2 */
159   sym1_74145_output_3_w,  /* connected to DS3 */
160   sym1_74145_output_4_w,  /* connected to DS4 */
161   sym1_74145_output_5_w,  /* connected to DS5 */
162   sym1_74145_output_6_w,  /* connected to the speaker */
163   NULL,                   /* not connected */
164   NULL,                   /* not connected */
165   NULL                    /* not connected */
148   DEVCB_LINE(sym1_74145_output_0_w),  /* connected to DS0 */
149   DEVCB_LINE(sym1_74145_output_1_w),  /* connected to DS1 */
150   DEVCB_LINE(sym1_74145_output_2_w),  /* connected to DS2 */
151   DEVCB_LINE(sym1_74145_output_3_w),  /* connected to DS3 */
152   DEVCB_LINE(sym1_74145_output_4_w),  /* connected to DS4 */
153   DEVCB_LINE(sym1_74145_output_5_w),  /* connected to DS5 */
154   DEVCB_DEVICE_LINE(SOUND, "speaker", speaker_level_w),
155   DEVCB_NULL,   /* not connected */
156   DEVCB_NULL,   /* not connected */
157   DEVCB_NULL   /* not connected */
166158};
167159
168160
src/mess/layout/acrnsys1.lay
r4357r4358
2525      </backdrop>
2626
2727      <!-- LEDs -->
28      <bezel name="digit0" element="digit">
28      <bezel name="digit1" element="digit">
2929         <bounds left="10" top="10" right="44" bottom="59" />
3030      </bezel>
31      <bezel name="digit1" element="digit">
31      <bezel name="digit2" element="digit">
3232         <bounds left="54" top="10" right="88" bottom="59" />
3333      </bezel>
34      <bezel name="digit2" element="digit">
34      <bezel name="digit4" element="digit">
3535         <bounds left="98" top="10" right="132" bottom="59" />
3636      </bezel>
37      <bezel name="digit3" element="digit">
37      <bezel name="digit8" element="digit">
3838         <bounds left="142" top="10" right="176" bottom="59" />
3939      </bezel>
40      <bezel name="digit4" element="digit">
40      <bezel name="digit16" element="digit">
4141         <bounds left="186" top="10" right="220" bottom="59" />
4242      </bezel>
43      <bezel name="digit5" element="digit">
43      <bezel name="digit32" element="digit">
4444         <bounds left="230" top="10" right="264" bottom="59" />
4545      </bezel>
46      <bezel name="digit6" element="digit">
46      <bezel name="digit64" element="digit">
4747         <bounds left="274" top="10" right="308" bottom="59" />
4848      </bezel>
49      <bezel name="digit7" element="digit">
49      <bezel name="digit128" element="digit">
5050         <bounds left="318" top="10" right="352" bottom="59" />
5151      </bezel>
52      <bezel name="digit8" element="digit">
52      <bezel name="digit256" element="digit">
5353         <bounds left="362" top="10" right="396" bottom="59" />
5454      </bezel>
5555
src/mess/drivers/mz700.c
r4357r4358
313313   /* devices */
314314   MDRV_PIT8253_ADD("pit8253", mz700_pit8253_config)
315315   MDRV_PPI8255_ADD("ppi8255", mz700_ppi8255_interface)
316   MDRV_TTL74145_ADD("ls145")
316   MDRV_TTL74145_ADD("ls145", default_ttl74145)
317317
318318   MDRV_CASSETTE_ADD( "cassette", mz700_cassette_config )
319319MACHINE_DRIVER_END
src/mess/drivers/sym1.c
r4357r4358
135135
136136   /* devices */
137137   MDRV_RIOT6532_ADD("riot", SYM1_CLOCK, sym1_r6532_interface)
138   MDRV_TTL74145_ADD("ttl74145")
139   MDRV_TTL74145_CONFIG(sym1_ttl74145_intf)
138   MDRV_TTL74145_ADD("ttl74145", sym1_ttl74145_intf)
140139   MDRV_VIA6522_ADD("via6522_0", 0, sym1_via0)
141140   MDRV_VIA6522_ADD("via6522_1", 0, sym1_via1)
142141   MDRV_VIA6522_ADD("via6522_2", 0, sym1_via2)
src/mess/drivers/acrnsys1.c
r4357r4358
88
99******************************************************************************/
1010
11/* Core includes */
1211#include "driver.h"
1312#include "cpu/m6502/m6502.h"
14
15/* Components */
1613#include "machine/ins8154.h"
1714#include "machine/74145.h"
18
19/* Layout */
2015#include "acrnsys1.lh"
2116
2217
23static UINT8 key_digit;
18/***************************************************************************
19    KEYBOARD HANDLING
20***************************************************************************/
2421
25
2622static READ8_DEVICE_HANDLER( ins8154_b1_port_a_r )
2723{
28   UINT8 data;
29   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
30                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
24   const device_config *ttl74145 = devtag_get_device(device->machine, TTL74145, "ic8_7445");
25   UINT8 key_line = ttl74145_r(ttl74145, 0, 0);
3126
32   data = input_port_read(device->machine, keynames[key_digit]);
33   logerror("Reading %02x from row %d\n", data, key_digit);
34   return data;
27   switch (key_line)
28   {
29   case 1 << 0: return input_port_read(device->machine, "keyboard_0");
30   case 1 << 1: return input_port_read(device->machine, "keyboard_1");
31   case 1 << 2: return input_port_read(device->machine, "keyboard_2");
32   case 1 << 3: return input_port_read(device->machine, "keyboard_3");
33   case 1 << 4: return input_port_read(device->machine, "keyboard_4");
34   case 1 << 5: return input_port_read(device->machine, "keyboard_5");
35   case 1 << 6: return input_port_read(device->machine, "keyboard_6");
36   case 1 << 7: return input_port_read(device->machine, "keyboard_7");
37   }
38
39   /* should never reach this */
40   return 0xff;
3541}
3642
3743static WRITE8_DEVICE_HANDLER( ins8154_b1_port_a_w )
3844{
39   ttl74145_w((device_config*)devtag_get_device(device->machine, TTL74145, "ttl74145"), 0, data & 0x07);
45   ttl74145_w(devtag_get_device(device->machine, TTL74145, "ic8_7445"), 0, data & 0x07);
4046}
4147
42static WRITE8_DEVICE_HANDLER( acrnsys1_led_segment_w )
43{
44   logerror("led %d segment data: %02x\n", key_digit, data);
4548
46   output_set_digit_value(key_digit + 0, data);
47}
49/***************************************************************************
50    LED DISPLAY
51***************************************************************************/
4852
49static const ins8154_interface ins8154_b1 =
53static WRITE8_DEVICE_HANDLER( acrnsys1_led_segment_w )
5054{
51   ins8154_b1_port_a_r,
52   NULL,
53   ins8154_b1_port_a_w,
54   acrnsys1_led_segment_w,
55   NULL
56};
55   const device_config *ttl74145 = devtag_get_device(device->machine, TTL74145, "ic8_7445");
56   UINT8 key_line = ttl74145_r(ttl74145, 0, 0);
5757
58static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_0_w ) { if (state) key_digit = 0; }
59static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_1_w ) { if (state) key_digit = 1; }
60static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_2_w ) { if (state) key_digit = 2; }
61static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_3_w ) { if (state) key_digit = 3; }
62static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_4_w ) { if (state) key_digit = 4; }
63static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_5_w ) { if (state) key_digit = 5; }
64static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_6_w ) { if (state) key_digit = 6; }
65static TTL74145_OUTPUT_LINE ( acrnsys1_7445_output_7_w ) { if (state) key_digit = 7; }
66
67static const ttl74145_interface ic8_7445 =
68{
69   acrnsys1_7445_output_0_w,  /* digit and keyboard column 0 */
70   acrnsys1_7445_output_1_w,  /* digit and keyboard column 1 */
71   acrnsys1_7445_output_2_w,  /* digit and keyboard column 2 */
72   acrnsys1_7445_output_3_w,  /* digit and keyboard column 3 */
73   acrnsys1_7445_output_4_w,  /* digit and keyboard column 4 */
74   acrnsys1_7445_output_5_w,  /* digit and keyboard column 5 */
75   acrnsys1_7445_output_6_w,  /* digit and keyboard column 6 */
76   acrnsys1_7445_output_7_w,  /* digit and keyboard column 7 */
77   NULL,  /* not connected */
78   NULL,  /* not connected */
79};
80
81static DRIVER_INIT( acrnsys1 )
82{
58   output_set_digit_value(key_line, data);
8359}
8460
85static MACHINE_RESET( acrnsys1 )
86{
87}
8861
62/***************************************************************************
63    ADDRESS MAPS
64***************************************************************************/
8965
90/******************************************************************************
91 Memory Maps
92******************************************************************************/
93
94
9566static ADDRESS_MAP_START( acrnsys1_map, ADDRESS_SPACE_PROGRAM, 8 )
9667   AM_RANGE(0x0000, 0x03ff) AM_RAM
9768   AM_RANGE(0x0e00, 0x0e7f) AM_MIRROR(0x100) AM_DEVREADWRITE(INS8154, "b1", ins8154_r, ins8154_w)
r4357r4358
10071ADDRESS_MAP_END
10172
10273
74/***************************************************************************
75    INPUT PORTS
76***************************************************************************/
10377
104/******************************************************************************
105 Input Ports
106******************************************************************************/
107
108
10978static INPUT_PORTS_START( acrnsys1 )
11079   PORT_START("keyboard_0")
11180   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
r4357r4358
171140INPUT_PORTS_END
172141
173142
143/***************************************************************************
144    MACHINE DRIVERS
145***************************************************************************/
174146
175/******************************************************************************
176 Machine Drivers
177******************************************************************************/
147static const ins8154_interface ins8154_b1 =
148{
149   ins8154_b1_port_a_r,
150   NULL,
151   ins8154_b1_port_a_w,
152   acrnsys1_led_segment_w,
153   NULL
154};
178155
179
180156static MACHINE_DRIVER_START( acrnsys1 )
181157   /* basic machine hardware */
182158   MDRV_CPU_ADD("maincpu", M6502, 1008000)  /* 1.008 MHz */
183159   MDRV_CPU_PROGRAM_MAP(acrnsys1_map, 0)
184160
185   MDRV_MACHINE_RESET(acrnsys1)
186
187161   MDRV_DEFAULT_LAYOUT(layout_acrnsys1)
188162
189163   /* devices */
190164   MDRV_INS8154_ADD("b1", ins8154_b1)
191   MDRV_TTL74145_ADD("ttl74145")
192   MDRV_TTL74145_CONFIG(ic8_7445)
165   MDRV_TTL74145_ADD("ic8_7445", default_ttl74145)
193166MACHINE_DRIVER_END
194167
195168
169/***************************************************************************
170    ROM DEFINITIONS
171***************************************************************************/
196172
197/******************************************************************************
198 ROM Definitions
199******************************************************************************/
200
201
202173ROM_START( acrnsys1 )
203174   ROM_REGION(0x10000, "maincpu", 0)
204175   ROM_LOAD("acrnsys1.bin", 0xfe00, 0x0200, CRC(43dcfc16) SHA1(b987354c55beb5e2ced761970c3339b895a8c09d))
r4357r4358
208179ROM_END
209180
210181
182/***************************************************************************
183    GAME DRIVERS
184***************************************************************************/
211185
212/******************************************************************************
213 System Config
214******************************************************************************/
215
216
217static SYSTEM_CONFIG_START( acrnsys1 )
218SYSTEM_CONFIG_END
219
220
221
222/******************************************************************************
223 Drivers
224******************************************************************************/
225
226
227/*    YEAR  NAME      PARENT COMPAT MACHINE   INPUT     INIT        CONFIG    COMPANY  FULLNAME    FLAGS */
228COMP( 1978, acrnsys1, 0,     0,     acrnsys1, acrnsys1, acrnsys1,   acrnsys1, "Acorn", "System 1", GAME_NOT_WORKING )
186/*    YEAR  NAME      PARENT COMPAT MACHINE   INPUT     INIT  CONFIG  COMPANY  FULLNAME    FLAGS */
187COMP( 1978, acrnsys1, 0,     0,     acrnsys1, acrnsys1, 0,    0,      "Acorn", "System 1", GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team