Previous 15994 Revisions Next

r1765 Monday 25th February, 2008 at 03:10:15 UTC by Dirk Best
Updated DL1416 emulation to use the new style generic device method
[src/mess/drivers]aim65.c
[src/mess/includes]aim65.h
[src/mess/machine]aim65.c
[src/mess/video]dl1416.c dl1416.h

src/mess/includes/aim65.h
r1764r1765
2121
2222/*----------- defined in machine/aim65.c -----------*/
2323
24extern DRIVER_INIT( aim65 );
24void aim65_update_ds1(int digit, int data);
25void aim65_update_ds2(int digit, int data);
26void aim65_update_ds3(int digit, int data);
27void aim65_update_ds4(int digit, int data);
28void aim65_update_ds5(int digit, int data);
2529
30DRIVER_INIT( aim65 );
2631
32
2733/*----------- defined in video/aim65.c -----------*/
2834
2935VIDEO_START( aim65 );
src/mess/video/dl1416.c
r1764r1765
2020 *
2121 * Changes:
2222 *   - 2007-07-30: Initial version.  [Dirk Best]
23 *   - 2008-02-25: Converted to the new device interface.  [Dirk Best]
2324 *
2425 ****************************************************************************/
2526
r1764r1765
2829 Includes
2930*****************************************************************************/
3031
31
3232#include "driver.h"
33#include "deprecat.h"
3433#include "dl1416.h"
3534
3635
3736
3837/*****************************************************************************
39 Macros
38 Constants
4039*****************************************************************************/
4140
42
43#define MAX_DL1416 (5)
44
4541#define SEG_UNDEF  (-1)
4642#define SEG_BLANK  (0)
4743#define SEG_CURSOR (0xffff)
r1764r1765
5248 Type definitions
5349*****************************************************************************/
5450
55/* DL1416 chip state */
56typedef struct _dl1416_state dl1416_state;
57
58struct _dl1416_state
51struct _dl1416_t
5952{
6053   const dl1416_interface *intf;
6154
r1764r1765
123116};
124117
125118
126static dl1416_state dl1416[MAX_DL1416];
127119
128
129
130120/*****************************************************************************
131 Implementation
121 Device interface
132122*****************************************************************************/
133123
134/* Config */
135void dl1416_config(int which, const dl1416_interface *intf)
124static void *dl1416_start(running_machine *machine, const char *tag,
125   const void *static_config, const void *inline_config)
136126{
137   assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, "Can only call dl1416_config at init time!");
138   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
127   dl1416_t *dl1416;
128   char unique_tag[30];
139129
140   dl1416[which].intf = intf;
130   /* validate arguments */
131   assert(tag != NULL);
132   assert(strlen(tag) < 20);
141133
142   state_save_register_item("dl1416", which, dl1416[which].chip_enable);
143   state_save_register_item("dl1416", which, dl1416[which].cursor_enable);
144   state_save_register_item("dl1416", which, dl1416[which].write_enable);
145   state_save_register_item_array("dl1416", which, dl1416[which].cursor_ram);
134   /* allocate the object that holds the state */
135   dl1416 = auto_malloc(sizeof(*dl1416));
136   memset(dl1416, 0, sizeof(*dl1416));
137
138   dl1416->intf = static_config;
139
140   /* register for state saving */
141   state_save_combine_module_and_tag(unique_tag, "dl1416", tag);
142
143   state_save_register_item(unique_tag, 0, dl1416->chip_enable);
144   state_save_register_item(unique_tag, 0, dl1416->cursor_enable);
145   state_save_register_item(unique_tag, 0, dl1416->write_enable);
146   state_save_register_item_array(unique_tag, 0, dl1416->cursor_ram);
147
148   return dl1416;
146149}
147150
148151
149/* Reset */
150void dl1416_reset(int which)
152static void dl1416_reset(running_machine *machine, void *token)
151153{
152154   int i;
155   dl1416_t *chip = token;
153156
154   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
155
156157   /* Disable all lines */
157   dl1416[which].chip_enable = FALSE;
158   dl1416[which].write_enable = FALSE;
159   dl1416[which].cursor_enable = FALSE;
158   chip->chip_enable = FALSE;
159   chip->write_enable = FALSE;
160   chip->cursor_enable = FALSE;
160161
161162   /* Randomize cursor memory */
162163   for (i = 0; i < 4; i++)
163      dl1416[which].cursor_ram[i] = mame_rand(Machine);
164      chip->cursor_ram[i] = mame_rand(machine);
164165}
165166
166167
168static void dl1416_set_info(running_machine *machine, void *token, UINT32 state, const deviceinfo *info)
169{
170   switch (state)
171   {
172      /* no parameters to set */
173   }
174}
175
176
177void dl1416_get_info(running_machine *machine, void *token, UINT32 state, deviceinfo *info)
178{
179   switch (state)
180   {
181      /* --- the following bits of info are returned as 64-bit signed integers --- */
182      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                     break;
183
184      /* --- the following bits of info are returned as pointers to data or functions --- */
185      case DEVINFO_FCT_SET_INFO:                  info->set_info = dl1416_set_info;      break;
186      case DEVINFO_FCT_START:                     info->start = dl1416_start;            break;
187      case DEVINFO_FCT_STOP:                     /* Nothing */                     break;
188      case DEVINFO_FCT_RESET:                     info->reset = dl1416_reset;            break;
189
190      /* --- the following bits of info are returned as NULL-terminated strings --- */
191      case DEVINFO_STR_NAME:                     info->s = "DL1416";                  break;
192      case DEVINFO_STR_FAMILY:                  info->s = "DL1416";                  break;
193      case DEVINFO_STR_VERSION:                  info->s = "1.0";                  break;
194      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                  break;
195      case DEVINFO_STR_CREDITS:                  info->s = "Copyright MESS Team";      break;
196   }
197}
198
199
200
201/*****************************************************************************
202 Implementation
203*****************************************************************************/
204
167205/* Write enable, active low */
168void dl1416_set_input_w(int which, int data)
206void dl1416_set_input_w(dl1416_t *chip, int data)
169207{
170   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
171   dl1416[which].write_enable = !data;
208   chip->write_enable = !data;
172209}
173210
174211
175212/* Chip enable, active low */
176void dl1416_set_input_ce(int which, int data)
213void dl1416_set_input_ce(dl1416_t *chip, int data)
177214{
178   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
179   dl1416[which].chip_enable = !data;
215   chip->chip_enable = !data;
180216}
181217
182218
183219/* Cursor enable, active low */
184void dl1416_set_input_cu(int which, int data)
220void dl1416_set_input_cu(dl1416_t *chip, int data)
185221{
186   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
187   dl1416[which].cursor_enable = !data;
222   chip->cursor_enable = !data;
188223}
189224
190225
191226/* Data */
192void dl1416_write(int which, offs_t offset, UINT8 data)
227void dl1416_write(dl1416_t *chip, offs_t offset, UINT8 data)
193228{
194229   int i, digit;
195230
196   assert_always(which < MAX_DL1416, "'which' exceeds maximum number of configured DL1416s!");
197
198231   offset &= 0x03; /* A0-A1 */
199232   data &= 0x7f;   /* D0-D6 */
200233
201234   /* Only try to update the data if we are enabled and write is enabled */
202   if (dl1416[which].chip_enable && dl1416[which].write_enable)
235   if (chip->chip_enable && chip->write_enable)
203236   {
204      if (dl1416[which].cursor_enable)
237      if (chip->cursor_enable)
205238      {
206         switch (dl1416[which].intf->type)
239         switch (chip->intf->type)
207240         {
208241
209242         case DL1416B:
210243
211244            /* The cursor will be set if D0 is high and the original */
212245            /* character restored otherwise */
213            digit = data & 1 ? SEG_CURSOR : dl1416[which].cursor_ram[offset];
246            digit = data & 1 ? SEG_CURSOR : chip->cursor_ram[offset];
214247
215248            /* Call update function */
216            dl1416[which].intf->digit_changed(offset, digit);
249            chip->intf->digit_changed(offset, digit);
217250
218251            break;
219252
r1764r1765
222255            for (i = 0; i < 4; i++)
223256            {
224257               /* Save old digit */
225               int previous_digit = dl1416[which].cursor_ram[i];
258               int previous_digit = chip->cursor_ram[i];
226259
227260               /* Either set the cursor or restore the original character */
228               digit = data & i ? SEG_CURSOR : dl1416[which].cursor_ram[i];
261               digit = data & i ? SEG_CURSOR : chip->cursor_ram[i];
229262
230263               /* Call update function if we changed something */
231264               if (previous_digit != digit)
232                  dl1416[which].intf->digit_changed(i, digit);
265                  chip->intf->digit_changed(i, digit);
233266            }
234267            break;
235268
r1764r1765
240273         /* On the DL1416T, a digit can only be changed if there is no */
241274         /* previously stored cursor, or overriden by an undefined */
242275         /* character (blank) */
243         if ((dl1416[which].intf->type != DL1416T) || (
244            (dl1416[which].cursor_ram[offset] != SEG_CURSOR) ||
276         if ((chip->intf->type != DL1416T) || (
277            (chip->cursor_ram[offset] != SEG_CURSOR) ||
245278            (dl1416t_segments[data] == SEG_UNDEF)))
246279         {
247280            /* Load data */
r1764r1765
252285               digit = SEG_BLANK;
253286
254287            /* Save value */
255            dl1416[which].cursor_ram[offset] = digit;
288            chip->cursor_ram[offset] = digit;
256289
257290            /* Call update function */
258            dl1416[which].intf->digit_changed(offset, digit);
291            chip->intf->digit_changed(offset, digit);
259292         }
260293      }
261294   }
262295}
263
264
265/* Standard handlers */
266WRITE8_HANDLER( dl1416_0_w ) { dl1416_write(0, offset, data); }
267WRITE8_HANDLER( dl1416_1_w ) { dl1416_write(1, offset, data); }
268WRITE8_HANDLER( dl1416_2_w ) { dl1416_write(2, offset, data); }
269WRITE8_HANDLER( dl1416_3_w ) { dl1416_write(3, offset, data); }
270WRITE8_HANDLER( dl1416_4_w ) { dl1416_write(4, offset, data); }
src/mess/video/dl1416.h
r1764r1765
1515#define DL1416_H_
1616
1717
18#define DL1416 dl1416_get_info
19
20
1821typedef enum
1922{
2023   DL1416B,
2124   DL1416T
2225} dl1416_type_t;
2326
24
25/* Interface */
27typedef struct _dl1416_t dl1416_t;
2628typedef struct _dl1416_interface dl1416_interface;
29
2730struct _dl1416_interface
2831{
2932   dl1416_type_t type;
3033   void (*digit_changed)(int digit, int data);
3134};
3235
33/* Configuration */
34void dl1416_config(int which, const dl1416_interface *intf);
35void dl1416_reset(int which);
36/* Device interface */
37void dl1416_get_info(running_machine *machine, void *token, UINT32 state, deviceinfo *info);
3638
3739/* Inputs */
38void dl1416_set_input_w(int which, int data); /* Write enable */
39void dl1416_set_input_ce(int which, int data); /* Chip enable */
40void dl1416_set_input_cu(int which, int data); /* Cursor enable */
41void dl1416_write(int which, offs_t offset, UINT8 data); /* Data */
40void dl1416_set_input_w(dl1416_t *chip, int data); /* Write enable */
41void dl1416_set_input_ce(dl1416_t *chip, int data); /* Chip enable */
42void dl1416_set_input_cu(dl1416_t *chip, int data); /* Cursor enable */
43void dl1416_write(dl1416_t *chip, offs_t offset, UINT8 data); /* Data */
4244
43/* Standard handlers */
44WRITE8_HANDLER( dl1416_0_w );
45WRITE8_HANDLER( dl1416_1_w );
46WRITE8_HANDLER( dl1416_2_w );
47WRITE8_HANDLER( dl1416_3_w );
48WRITE8_HANDLER( dl1416_4_w );
4945
50#endif /*DL1416_H_*/
46#endif /* DL1416_H_ */
src/mess/machine/aim65.c
r1764r1765
2323
2424
2525/******************************************************************************
26 Function Prototypes
27******************************************************************************/
28
29static void aim65_update_ds1(int digit, int data);
30static void aim65_update_ds2(int digit, int data);
31static void aim65_update_ds3(int digit, int data);
32static void aim65_update_ds4(int digit, int data);
33static void aim65_update_ds5(int digit, int data);
34
35
36
37/******************************************************************************
3826 Global variables
3927******************************************************************************/
4028
r1764r1765
4230static UINT8 pia_a, pia_b;
4331static UINT8 riot_port_a;
4432
45/* Display driver interfaces */
46static const dl1416_interface dl1416_ds1 = { DL1416T, aim65_update_ds1 };
47static const dl1416_interface dl1416_ds2 = { DL1416T, aim65_update_ds2 };
48static const dl1416_interface dl1416_ds3 = { DL1416T, aim65_update_ds3 };
49static const dl1416_interface dl1416_ds4 = { DL1416T, aim65_update_ds4 };
50static const dl1416_interface dl1416_ds5 = { DL1416T, aim65_update_ds5 };
5133
5234
53
5435/******************************************************************************
5536 Interrupt handling
5637******************************************************************************/
r1764r1765
9071 * PB7: CU (Cursor)
9172 */
9273
93static void aim65_pia(void)
74static void dl1416_update(dl1416_t *chip, int index)
9475{
95   int which;
76   dl1416_set_input_ce(chip, pia_a & (0x04 << index));
77   dl1416_set_input_w(chip, pia_a & 0x80);
78   dl1416_set_input_cu(chip, pia_b & 0x80);
79   dl1416_write(chip, pia_a & 0x03, pia_b & 0x7f);
80}
9681
97   for (which = 0; which < 5; which++)
98   {
99      dl1416_set_input_ce(which, pia_a & (0x04 << which));
100      dl1416_set_input_w(which, pia_a & 0x80);
101      dl1416_set_input_cu(which, pia_b & 0x80);
102      dl1416_write(which, pia_a & 0x03, pia_b & 0x7f);
103   }
82static void aim65_pia(void)
83{
84   dl1416_update(devtag_get_token(Machine, DL1416, "ds1"), 0);
85   dl1416_update(devtag_get_token(Machine, DL1416, "ds2"), 1);
86   dl1416_update(devtag_get_token(Machine, DL1416, "ds3"), 2);
87   dl1416_update(devtag_get_token(Machine, DL1416, "ds4"), 3);
88   dl1416_update(devtag_get_token(Machine, DL1416, "ds5"), 4);
10489}
10590
10691
r1764r1765
135120};
136121
137122
138static void aim65_update_ds1(int digit, int data) { output_set_digit_value( 0 + (digit ^ 3), data); }
139static void aim65_update_ds2(int digit, int data) { output_set_digit_value( 4 + (digit ^ 3), data); }
140static void aim65_update_ds3(int digit, int data) { output_set_digit_value( 8 + (digit ^ 3), data); }
141static void aim65_update_ds4(int digit, int data) { output_set_digit_value(12 + (digit ^ 3), data); }
142static void aim65_update_ds5(int digit, int data) { output_set_digit_value(16 + (digit ^ 3), data); }
123void aim65_update_ds1(int digit, int data) { output_set_digit_value( 0 + (digit ^ 3), data); }
124void aim65_update_ds2(int digit, int data) { output_set_digit_value( 4 + (digit ^ 3), data); }
125void aim65_update_ds3(int digit, int data) { output_set_digit_value( 8 + (digit ^ 3), data); }
126void aim65_update_ds4(int digit, int data) { output_set_digit_value(12 + (digit ^ 3), data); }
127void aim65_update_ds5(int digit, int data) { output_set_digit_value(16 + (digit ^ 3), data); }
143128
144129
145130
r1764r1765
247232   memory_set_bankptr(1, mess_ram);
248233
249234   if (mess_ram_size < 4 * 1024)
250      memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM,
235      memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM,
251236         mess_ram_size, 0x0fff, 0, 0, MRA8_NOP, MWA8_NOP);
252237
253   /* Init display driver */
254   dl1416_config(0, &dl1416_ds1);
255   dl1416_config(1, &dl1416_ds2);
256   dl1416_config(2, &dl1416_ds3);
257   dl1416_config(3, &dl1416_ds4);
258   dl1416_config(4, &dl1416_ds5);
259
260   dl1416_reset(0);
261   dl1416_reset(1);
262   dl1416_reset(2);
263   dl1416_reset(3);
264   dl1416_reset(4);
265
266238   pia_config(0, &pia);
267239
268240   r6532_config(0, &r6532_interface);
src/mess/drivers/aim65.c
r1764r1765
1717#include "includes/aim65.h"
1818
1919/* peripheral chips */
20#include "video/dl1416.h"
2021#include "machine/6522via.h"
2122#include "machine/6532riot.h"
2223#include "machine/6821pia.h"
r1764r1765
146147
147148
148149/******************************************************************************
150 Device interfaces
151******************************************************************************/
152
153/* Display driver interfaces */
154static const dl1416_interface dl1416_ds1 = { DL1416T, aim65_update_ds1 };
155static const dl1416_interface dl1416_ds2 = { DL1416T, aim65_update_ds2 };
156static const dl1416_interface dl1416_ds3 = { DL1416T, aim65_update_ds3 };
157static const dl1416_interface dl1416_ds4 = { DL1416T, aim65_update_ds4 };
158static const dl1416_interface dl1416_ds5 = { DL1416T, aim65_update_ds5 };
159
160
161
162/******************************************************************************
149163 Machine Drivers
150164******************************************************************************/
151165
r1764r1765
157171
158172   MDRV_DEFAULT_LAYOUT(layout_aim65)
159173
174   MDRV_DEVICE_ADD("ds1", DL1416)
175   MDRV_DEVICE_CONFIG(dl1416_ds1)
176   MDRV_DEVICE_ADD("ds2", DL1416)
177   MDRV_DEVICE_CONFIG(dl1416_ds2)
178   MDRV_DEVICE_ADD("ds3", DL1416)
179   MDRV_DEVICE_CONFIG(dl1416_ds3)
180   MDRV_DEVICE_ADD("ds4", DL1416)
181   MDRV_DEVICE_CONFIG(dl1416_ds4)
182   MDRV_DEVICE_ADD("ds5", DL1416)
183   MDRV_DEVICE_CONFIG(dl1416_ds5)
184
160185   MDRV_VIDEO_START(aim65)
161186MACHINE_DRIVER_END
162187

Previous 15994 Revisions Next


© 1998-2018 The MESS Team