Previous 15994 Revisions Next

r3080 Friday 22nd August, 2008 at 14:53:42 UTC by Curt Coder
[NEWBRAIN] Added preliminary ADC0808 emulation.
[src/mess]mess.mak
[src/mess/drivers]newbrain.c
[src/mess/includes]newbrain.h
[src/mess/machine]adc080x.c* adc080x.h*

src/mess/includes/newbrain.h
r3079r3080
22#define __NEWBRAIN__
33
44#define SCREEN_TAG         "main"
5#define Z80_TAG            "409"
6#define COP420_TAG         "419"
7#define MC6850_TAG         "459"
8#define ADC0809_TAG         "427"
9#define DAC0808_TAG         "461"
10#define Z80CTC_TAG         "458"
11#define FDC_Z80_TAG         "416"
12#define NEC765AC_TAG      "418"
513
614#define NEWBRAIN_VIDEO_RV         0x01
715#define NEWBRAIN_VIDEO_FS         0x02
r3079r3080
1927   int clkint;            /* clock interrupt */
2028   int aciaint;         /* ACIA interrupt */
2129   int copint;            /* COP interrupt */
30   int anint;            /* A/DC interrupt */
2231   int bee;            /* identity */
2332   UINT8 enrg1;         /* enable register 1 */
2433   UINT8 enrg2;         /* enable register 2 */
src/mess/machine/adc080x.c
r0r3080
1/**********************************************************************
2 
3    ADC0808/ADC0809 8-Bit A/D Converter emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#include "driver.h"
11#include "adc080x.h"
12 
13typedef struct _adc080x_t adc080x_t;
14struct _adc080x_t
15{
16   const adc080x_interface *intf;      /* interface */
17 
18   int address;                  /* analog channel address */
19   int ale;                     /* address latch enable pin */
20   int start;                     /* start conversion pin */
21   int eoc;                     /* end of conversion pin */
22   int next_eoc;                  /* next value end of conversion pin */
23   
24   UINT8 sar;                     /* successive approximation register */
25 
26   int cycle;                     /* clock cycle counter */
27   int bit;                     /* bit counter */
28 
29   /* timers */
30   emu_timer *cycle_timer;            /* cycle timer */
31};
32 
33INLINE adc080x_t *get_safe_token(const device_config *device)
34{
35   assert(device != NULL);
36   assert(device->token != NULL);
37 
38   return (adc080x_t *)device->token;
39}
40 
41/* Approximation Cycle */
42 
43static TIMER_CALLBACK( cycle_tick )
44{
45   const device_config *device = ptr;
46   adc080x_t *adc080x = get_safe_token(device);
47 
48   if (!adc080x->start)
49   {
50      if (adc080x->cycle == 7)
51      {
52         adc080x->bit++;
53 
54         if (adc080x->bit == 8)
55         {
56            /* sample input */
57            double vref_pos = adc080x->intf->vref_pos_r(device);
58            double vref_neg = adc080x->intf->vref_neg_r(device);
59            double input = adc080x->intf->input_r(device, adc080x->address);
60 
61            adc080x->sar = (255 * (input - vref_neg)) / (vref_pos - vref_neg);
62 
63            /* trigger end of conversion */
64            adc080x->next_eoc = 1;
65         }
66      }
67   }
68 
69   if (adc080x->cycle == 0)
70   {
71      /* set end of conversion pin */
72      if (adc080x->next_eoc != adc080x->eoc)
73      {
74         adc080x->intf->on_eoc_changed(device, adc080x->next_eoc);
75         adc080x->eoc = adc080x->next_eoc;
76      }
77   }
78 
79   adc080x->cycle++;
80 
81   if (adc080x->cycle == 8)
82   {
83      adc080x->cycle = 0;
84   }
85}
86 
87/* Address Latch Enable */
88 
89void adc080x_ale_w(const device_config *device, int level, int address)
90{
91   adc080x_t *adc080x = get_safe_token(device);
92 
93   if (adc080x->ale && !level) // falling edge
94   {
95      adc080x->address = address;
96   }
97 
98   adc080x->ale = level;
99}
100 
101/* Start Conversion */
102 
103void adc080x_start_w(const device_config *device, int level)
104{
105   adc080x_t *adc080x = get_safe_token(device);
106 
107   if (!adc080x->start && level) // rising edge
108   {
109      // reset registers
110 
111      adc080x->sar = 0;
112      adc080x->bit = 0;
113   }
114   else if (adc080x->start && !level) // falling edge
115   {
116      // start conversion
117 
118      adc080x->next_eoc = 0;
119   }
120 
121   adc080x->start = level;
122}
123 
124/* Conversion Data */
125 
126READ8_DEVICE_HANDLER( adc080x_data_r )
127{
128   adc080x_t *adc080x = get_safe_token(device);
129 
130   return adc080x->sar;
131}
132 
133/* Device Interface */
134 
135static DEVICE_START( adc080x )
136{
137   adc080x_t *adc080x = get_safe_token(device);
138   char unique_tag[30];
139 
140   /* validate arguments */
141   assert(device != NULL);
142   assert(device->tag != NULL);
143   assert(strlen(device->tag) < 20);
144 
145   adc080x->intf = device->static_config;
146 
147   assert(adc080x->intf != NULL);
148   assert(adc080x->intf->clock > 0);
149 
150   /* set initial values */
151   adc080x->eoc = 1;
152 
153   /* allocate cycle timer */
154   adc080x->cycle_timer = timer_alloc(cycle_tick, (void *)device);
155   timer_adjust_periodic(adc080x->cycle_timer, attotime_zero, 0, ATTOTIME_IN_HZ(adc080x->intf->clock));
156 
157   /* register for state saving */
158   state_save_combine_module_and_tag(unique_tag, "adc080x", device->tag);
159 
160   state_save_register_item(unique_tag, 0, adc080x->address);
161   state_save_register_item(unique_tag, 0, adc080x->ale);
162   state_save_register_item(unique_tag, 0, adc080x->start);
163   state_save_register_item(unique_tag, 0, adc080x->eoc);
164   state_save_register_item(unique_tag, 0, adc080x->next_eoc);
165   state_save_register_item(unique_tag, 0, adc080x->sar);
166   state_save_register_item(unique_tag, 0, adc080x->cycle);
167   state_save_register_item(unique_tag, 0, adc080x->bit);
168}
169 
170static DEVICE_SET_INFO( adc080x )
171{
172   switch (state)
173   {
174      /* no parameters to set */
175   }
176}
177 
178DEVICE_GET_INFO( adc0808 )
179{
180   switch (state)
181   {
182      /* --- the following bits of info are returned as 64-bit signed integers --- */
183      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(adc080x_t);            break;
184      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
185      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
186 
187      /* --- the following bits of info are returned as pointers to data or functions --- */
188      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(adc080x); break;
189      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(adc080x);   break;
190      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
191      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
192 
193      /* --- the following bits of info are returned as NULL-terminated strings --- */
194      case DEVINFO_STR_NAME:                     info->s = "National Semiconductor ADC0808";   break;
195      case DEVINFO_STR_FAMILY:                  info->s = "National Semiconductor ADC080";   break;
196      case DEVINFO_STR_VERSION:                  info->s = "1.0";                     break;
197      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                     break;
198      case DEVINFO_STR_CREDITS:                  info->s = "Copyright MESS Team";         break;
199   }
200}
201 
202DEVICE_GET_INFO( adc0809 )
203{
204   switch (state)
205   {
206      /* --- the following bits of info are returned as NULL-terminated strings --- */
207      case DEVINFO_STR_NAME:                     info->s = "National Semiconductor ADC0809";   break;
208 
209      default:                              DEVICE_GET_INFO_CALL(adc0808);            break;
210   }
211}
src/mess/machine/adc080x.h
r0r3080
1/**********************************************************************
2 
3    ADC0808/ADC0809 8-Bit A/D Converter emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************
9                     _____   _____
10               IN3    1 |*    \_/     | 28  IN2
11               IN4    2 |          | 27  IN1
12               IN5    3 |          | 26  IN0
13               IN6    4 |          | 25  ADD A
14               IN7    5 |          | 24  ADD B
15             START    6 |          | 23  ADD C
16               EOC    7 |   ADC0808    | 22  ALE
17               2-5    8 |   ADC0809    | 21  2-1 MSB
18       OUTPUT ENABLE    9 |          | 20  2-2
19             CLOCK   10 |          | 19  2-3
20               Vcc   11 |          | 18  2-4
21             Vref+   12 |          | 17  2-8 LSB
22               GND   13 |          | 16  Vref-
23               2-7   14 |_____________| 15  2-6
24 
25**********************************************************************/
26 
27#ifndef __ADC080X__
28#define __ADC080X__
29 
30typedef void (*adc080x_on_eoc_changed_func) (const device_config *device, int level);
31#define ADC080X_ON_EOC_CHANGED(name) void name(const device_config *device, int level)
32 
33typedef double (*adc080x_vref_pos_read) (const device_config *device);
34#define ADC080X_VREF_POSITIVE_READ(name) double name(const device_config *device)
35 
36typedef double (*adc080x_vref_neg_read) (const device_config *device);
37#define ADC080X_VREF_NEGATIVE_READ(name) double name(const device_config *device)
38 
39typedef double (*adc080x_input_read) (const device_config *device, int channel);
40#define ADC080X_INPUT_READ(name) double name(const device_config *device, int channel)
41 
42#define ADC0808      DEVICE_GET_INFO_NAME(adc0808)
43#define ADC0809      DEVICE_GET_INFO_NAME(adc0809)
44 
45/* interface */
46typedef struct _adc080x_interface adc080x_interface;
47struct _adc080x_interface
48{
49   int clock;               /* the clock (pin 10) of the chip */
50 
51   /* this gets called for every change of the EOC pin (pin 7) */
52   adc080x_on_eoc_changed_func      on_eoc_changed;
53 
54   /* this gets called for every sampling of the positive reference voltage (pin 12) */
55   adc080x_vref_pos_read         vref_pos_r;
56 
57   /* this gets called for every sampling of the negative reference voltage (pin 16) */
58   adc080x_vref_neg_read         vref_neg_r;
59 
60   /* this gets called for every sampling of the input pins IN0-IN7 */
61   adc080x_input_read            input_r;
62};
63#define ADC080X_INTERFACE(name) const adc080x_interface (name)=
64 
65/* device interface */
66DEVICE_GET_INFO( adc0808 );
67DEVICE_GET_INFO( adc0809 );
68 
69/* address latching */
70void adc080x_ale_w(const device_config *device, int level, int address);
71 
72/* start conversion */
73void adc080x_start_w(const device_config *device, int level);
74 
75/* conversion data */
76READ8_DEVICE_HANDLER( adc080x_data_r );
77 
78#endif
src/mess/mess.mak
r3079r3080
12741274
12751275$(MESSOBJ)/grundy.a: \
12761276   $(MESS_DRIVERS)/newbrain.o \
1277   $(MESS_VIDEO)/newbrain.o
1277   $(MESS_VIDEO)/newbrain.o \
1278   $(MESS_MACHINE)/adc080x.o
12781279
12791280#-------------------------------------------------
12801281# layout dependencies
src/mess/drivers/newbrain.c
r3079r3080
44#include "cpu/cop400/cop400.h"
55#include "machine/nec765.h"
66#include "machine/6850acia.h"
7#include "machine/adc080x.h"
78#include "machine/z80ctc.h"
89#include "machine/z80dart.h"
910#include "machine/z80sio.h"
r3079r3080
833834   }
834835}
835836
837/* A/D Converter */
838
839static ADC080X_ON_EOC_CHANGED( newbrain_adc_on_eoc_changed )
840{
841   newbrain_state *state = device->machine->driver_data;
842
843   state->anint = level;
844}
845
846static ADC080X_VREF_POSITIVE_READ( newbrain_adc_vref_pos_r )
847{
848   return 5.0;
849}
850
851static ADC080X_VREF_NEGATIVE_READ( newbrain_adc_vref_neg_r )
852{
853   return 0.0;
854}
855
856static ADC080X_INPUT_READ( newbrain_adc_input_r )
857{
858   return 0.0;
859}
860
861static ADC080X_INTERFACE( newbrain_adc0809_intf )
862{
863   500000,
864   newbrain_adc_on_eoc_changed,
865   newbrain_adc_vref_pos_r,
866   newbrain_adc_vref_neg_r,
867   newbrain_adc_input_r
868};
869
836870/* Memory Maps */
837871
838872static ADDRESS_MAP_START( newbrain_map, ADDRESS_SPACE_PROGRAM, 8 )
r3079r3080
11141148
11151149   for (bank = 1; bank < 9; bank++)
11161150   {
1117      memory_configure_bank(bank, 0, 1, memory_region(machine, "main") + (bank - 1) * 0x2000, 0);
1151      memory_configure_bank(bank, 0, 1, memory_region(machine, Z80_TAG) + (bank - 1) * 0x2000, 0);
11181152      memory_set_bank(bank, 0);
11191153   }
11201154}
r3079r3080
11281162
11291163   for (bank = 1; bank < 9; bank++)
11301164   {
1131      memory_configure_bank(bank, 0, 1, memory_region(machine, "main") + 0xe000, 0);
1165      memory_configure_bank(bank, 0, 1, memory_region(machine, Z80_TAG) + 0xe000, 0);
11321166      memory_set_bank(bank, 0);
11331167   }
11341168
r3079r3080
11981232
11991233   // basic system hardware
12001234
1201   MDRV_CPU_ADD("main", Z80, XTAL_16MHz/8)
1235   MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/8)
12021236   MDRV_CPU_PROGRAM_MAP(newbrain_map, 0)
12031237   MDRV_CPU_IO_MAP(newbrain_ei_io_map, 0)
1204   MDRV_CPU_VBLANK_INT("main", newbrain_interrupt)
1238   MDRV_CPU_VBLANK_INT(Z80_TAG, newbrain_interrupt)
12051239
1206   MDRV_CPU_ADD("cop", COP420, XTAL_16MHz/8) // COP420-GUW/M
1240   MDRV_CPU_ADD(COP420_TAG, COP420, XTAL_16MHz/8) // COP420-GUW/M
12071241   MDRV_CPU_PROGRAM_MAP(newbrain_cop_map, 0)
12081242   MDRV_CPU_IO_MAP(newbrain_cop_io_map, 0)
12091243   MDRV_CPU_CONFIG(newbrain_cop_intf)
12101244
1211   MDRV_CPU_ADD("fdc", Z80, XTAL_4MHz)
1245   MDRV_CPU_ADD(FDC_Z80_TAG, Z80, XTAL_4MHz)
12121246   MDRV_CPU_PROGRAM_MAP(newbrain_fdc_map, 0)
12131247   MDRV_CPU_IO_MAP(newbrain_fdc_io_map, 0)
12141248
12151249   MDRV_MACHINE_START(newbrain)
12161250   MDRV_MACHINE_RESET(newbrain)
12171251
1252   // A/D converter
1253
1254   MDRV_DEVICE_ADD(ADC0809_TAG, ADC0809)
1255   MDRV_DEVICE_CONFIG(newbrain_adc0809_intf)
1256
12181257   // video hardware
12191258
12201259   MDRV_IMPORT_FROM(newbrain_video)
r3079r3080
12251264
12261265   // basic system hardware
12271266
1228   MDRV_CPU_ADD("main", Z80, XTAL_16MHz/8)
1267   MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/8)
12291268   MDRV_CPU_PROGRAM_MAP(newbrain_map, 0)
12301269   MDRV_CPU_IO_MAP(newbrain_m_io_map, 0)
1231   MDRV_CPU_VBLANK_INT("main", newbrain_interrupt)
1270   MDRV_CPU_VBLANK_INT(Z80_TAG, newbrain_interrupt)
12321271
1233   MDRV_CPU_ADD("cop", COP420, XTAL_16MHz/8) // COP420-GUW/M
1272   MDRV_CPU_ADD(COP420_TAG, COP420, XTAL_16MHz/8) // COP420-GUW/M
12341273   MDRV_CPU_PROGRAM_MAP(newbrain_cop_map, 0)
12351274   MDRV_CPU_IO_MAP(newbrain_cop_io_map, 0)
12361275   MDRV_CPU_CONFIG(newbrain_cop_intf)
r3079r3080
12481287
12491288   // basic system hardware
12501289
1251   MDRV_CPU_ADD("main", Z80, XTAL_16MHz/8)
1290   MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/8)
12521291   MDRV_CPU_PROGRAM_MAP(newbrain_map, 0)
12531292   MDRV_CPU_IO_MAP(newbrain_a_io_map, 0)
1254   MDRV_CPU_VBLANK_INT("main", newbrain_interrupt)
1293   MDRV_CPU_VBLANK_INT(Z80_TAG, newbrain_interrupt)
12551294
1256   MDRV_CPU_ADD("cop", COP420, XTAL_16MHz/8) // COP420-GUW/M
1295   MDRV_CPU_ADD(COP420_TAG, COP420, XTAL_16MHz/8) // COP420-GUW/M
12571296   MDRV_CPU_PROGRAM_MAP(newbrain_cop_map, 0)
12581297   MDRV_CPU_IO_MAP(newbrain_cop_io_map, 0)
12591298   MDRV_CPU_CONFIG(newbrain_cop_intf)
r3079r3080
12711310
12721311   // basic system hardware
12731312
1274   MDRV_CPU_ADD("main", Z80, XTAL_16MHz/8)
1313   MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/8)
12751314   MDRV_CPU_PROGRAM_MAP(newbrain_map, 0)
12761315   MDRV_CPU_IO_MAP(newbrain_v_io_map, 0)
1277   MDRV_CPU_VBLANK_INT("main", newbrain_interrupt)
1316   MDRV_CPU_VBLANK_INT(Z80_TAG, newbrain_interrupt)
12781317
1279   MDRV_CPU_ADD("cop", COP420, XTAL_16MHz/8) // COP420-GUW/M
1318   MDRV_CPU_ADD(COP420_TAG, COP420, XTAL_16MHz/8) // COP420-GUW/M
12801319   MDRV_CPU_PROGRAM_MAP(newbrain_cop_map, 0)
12811320   MDRV_CPU_IO_MAP(newbrain_cop_io_map, 0)
12821321   MDRV_CPU_CONFIG(newbrain_cop_intf)
r3079r3080
12921331/* ROMs */
12931332
12941333ROM_START( newbrain )
1295   ROM_REGION( 0x10000, "main", 0 )
1334   ROM_REGION( 0x10000, Z80_TAG, 0 )
12961335   ROM_LOAD( "d413-2.rom", 0x8000, 0x2000, CRC(097591f1) SHA1(c2aa1d27d4f3a24ab0c8135df746a4a44201a7f4) )
12971336   ROM_LOAD( "cdmd.rom", 0xc000, 0x2000, CRC(6b4d9429) SHA1(ef688be4e75aced61f487c928258c8932a0ae00a) )
12981337   ROM_LOAD( "efmd.rom", 0xe000, 0x2000, CRC(20dd0b49) SHA1(74b517ca223cefb588e9f49e72ff2d4f1627efc6) )
12991338
1300   ROM_REGION( 0x400, "cop", 0 )
1339   ROM_REGION( 0x400, COP420_TAG, 0 )
13011340   ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP )
13021341
13031342   ROM_REGION( 0x10000, "eim", 0 ) // Expansion Interface Module
r3079r3080
13061345   ROM_LOAD( "e416-3.rom", 0x6000, 0x2000, CRC(8b5099d8) SHA1(19b0cfce4c8b220eb1648b467f94113bafcb14e0) ) // 10/8/83.mtv
13071346   ROM_LOAD( "e417-2.rom", 0x8000, 0x2000, CRC(6a7afa20) SHA1(f90db4f8318777313a862b3d5bab83c2fd260010) )
13081347
1309   ROM_REGION( 0x10000, "fdc", 0 ) // Floppy Disk Controller
1348   ROM_REGION( 0x10000, FDC_Z80_TAG, 0 ) // Floppy Disk Controller
13101349   ROM_LOAD( "d417-1.rom", 0x0000, 0x2000, CRC(40fad31c) SHA1(5137be4cc026972c0ffd4fa6990e8583bdfce163) )
13111350   ROM_LOAD( "d417-2.rom", 0x0000, 0x2000, CRC(e8bda8b9) SHA1(c85a76a5ff7054f4ef4a472ce99ebaed1abd269c) )
13121351
r3079r3080
13151354ROM_END
13161355
13171356ROM_START( newbraim )
1318   ROM_REGION( 0x10000, "main", 0 )
1357   ROM_REGION( 0x10000, Z80_TAG, 0 )
13191358   ROM_LOAD( "cdmd.rom", 0xc000, 0x2000, CRC(6b4d9429) SHA1(ef688be4e75aced61f487c928258c8932a0ae00a) )
13201359   ROM_LOAD( "efmd.rom", 0xe000, 0x2000, CRC(20dd0b49) SHA1(74b517ca223cefb588e9f49e72ff2d4f1627efc6) )
13211360
1322   ROM_REGION( 0x400, "cop", 0 )
1361   ROM_REGION( 0x400, COP420_TAG, 0 )
13231362   ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP )
13241363
13251364   ROM_REGION( 0x1000, "chargen", 0 )
r3079r3080
13271366ROM_END
13281367
13291368ROM_START( newbraia )
1330   ROM_REGION( 0x10000, "main", 0 )
1369   ROM_REGION( 0x10000, Z80_TAG, 0 )
13311370   ROM_SYSTEM_BIOS( 0, "rom20", "ROM 2.0" )
13321371   ROMX_LOAD( "aben20.rom", 0xa000, 0x2000, CRC(3d76d0c8) SHA1(753b4530a518ad832e4b81c4e5430355ba3f62e0), ROM_BIOS(1) )
13331372   ROMX_LOAD( "cd20tci.rom", 0xc000, 0x4000, CRC(f65b2350) SHA1(1ada7fbf207809537ec1ffb69808524300622ada), ROM_BIOS(1) )
r3079r3080
13471386   ROMX_LOAD( "cd.rom", 0xc000, 0x2000, CRC(6b4d9429) SHA1(ef688be4e75aced61f487c928258c8932a0ae00a), ROM_BIOS(4) )
13481387   ROMX_LOAD( "ef1x.rom", 0xe000, 0x2000, CRC(20dd0b49) SHA1(74b517ca223cefb588e9f49e72ff2d4f1627efc6), ROM_BIOS(4) )
13491388
1350   ROM_REGION( 0x400, "cop", 0 )
1389   ROM_REGION( 0x400, COP420_TAG, 0 )
13511390   ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP )
13521391
13531392   ROM_REGION( 0x1000, "chargen", 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team