Previous 15994 Revisions Next

r5225 Tuesday 14th July, 2009 at 08:19:31 UTC by Curt Coder
[V1050] Fixed RTC protocol.
[src/mess/drivers]v1050.c
[src/mess/includes]v1050.h
[src/mess/machine]msm58321.c msm58321.h

src/mess/includes/v1050.h
r5224r5225
5454   /* memory state */
5555   UINT8 bank;               /* bank register */
5656
57   /* RTC state */
58   int rtc_busy;            /* RTC busy */
59
6057   /* video state */
6158   UINT8 *video_ram;         /* video RAM */
6259   UINT8 *attr_ram;         /* attribute RAM */
src/mess/machine/msm58321.c
r5224r5225
11/**********************************************************************
22
3    OKI MSM58321 Real Time Clock emulation
3    OKI MSM58321RS Real Time Clock emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r5224r5225
2525    PARAMETERS
2626***************************************************************************/
2727
28#define LOG 1
28#define LOG
2929
3030enum
3131{
3232   REGISTER_S1 = 0,
33   REGISTER_S0,
33   REGISTER_S10,
3434   REGISTER_MI1,
3535   REGISTER_MI10,
3636   REGISTER_H1,
r5224r5225
5656{
5757   devcb_resolved_write_line   out_busy_func;
5858
59   UINT8 reg[13];            /* registers */
59   int cs1;               /* chip select 1 */
60   int cs2;               /* chip select 2 */
6061   int busy;               /* busy flag */
62   int read;               /* read data */
63   int write;               /* write data */
64   int address_write;         /* write address */
6165
66   UINT8 reg[13];            /* registers */
67   UINT8 latch;            /* data latch (not present in real chip) */
68   UINT8 address;            /* address latch */
69
6270   /* timers */
6371   emu_timer *busy_timer;
6472};
r5224r5225
7886INLINE const msm58321_interface *get_interface(const device_config *device)
7987{
8088   assert(device != NULL);
81   assert(device->type == MSM58321);
89   assert(device->type == MSM58321RS);
8290   return (const msm58321_interface *) device->static_config;
8391}
8492
r5224r5225
8694    IMPLEMENTATION
8795***************************************************************************/
8896
97/*-------------------------------------------------
98    msm58321_r - read data
99-------------------------------------------------*/
100
89101READ8_DEVICE_HANDLER( msm58321_r )
90102{
91103   msm58321_t *msm58321 = get_safe_token(device);
92104
93105   UINT8 data = 0;
94106
95   switch(offset & 0x0f)
107   if (msm58321->cs1 && msm58321->cs2)
96108   {
97   case REGISTER_RESET:
98      break;
109      if (msm58321->read)
110      {
111         mame_system_time systime;
99112
100   case REGISTER_REF0:
101   case REGISTER_REF1:
102      break;
113         mame_get_current_datetime(device->machine, &systime);
103114
104   default:
105      data = msm58321->reg[offset];
106      break;
115         switch (msm58321->latch)
116         {
117         case REGISTER_S1:   data = systime.local_time.second % 10; break;
118         case REGISTER_S10:   data = systime.local_time.second / 10; break;
119         case REGISTER_MI1:   data = systime.local_time.minute % 10; break;
120         case REGISTER_MI10: data = systime.local_time.minute / 10; break;
121         case REGISTER_H1:   data = systime.local_time.hour % 10; break;
122         case REGISTER_H10:   data = (systime.local_time.hour / 10) | 0x08; break;
123         case REGISTER_W:   data = systime.local_time.weekday; break;
124         case REGISTER_D1:   data = systime.local_time.mday % 10; break;
125         case REGISTER_D10:   data = (systime.local_time.mday / 10) | ((systime.local_time.year % 4) ? 0 : 0x04); break;
126         case REGISTER_MO1:   data = (systime.local_time.month + 1) % 10; break;
127         case REGISTER_MO10: data = (systime.local_time.month + 1) / 10; break;
128         case REGISTER_Y1:   data = systime.local_time.year % 10; break;
129         case REGISTER_Y10:   data = (systime.local_time.year / 10) % 10;   break;
130
131         case REGISTER_RESET:
132            break;
133
134         case REGISTER_REF0:
135         case REGISTER_REF1:
136            break;
137
138         default:
139            data = msm58321->reg[offset];
140            break;
141         }
142      }
143
144      if (msm58321->write)
145      {
146         if (msm58321->address >= REGISTER_REF0)
147         {
148            // TODO: output reference values
149         }
150      }
107151   }
108152
109153   return data;
110154}
111155
156/*-------------------------------------------------
157    msm58321_w - write data
158-------------------------------------------------*/
159
112160WRITE8_DEVICE_HANDLER( msm58321_w )
113161{
114162   msm58321_t *msm58321 = get_safe_token(device);
115163
116   switch(offset & 0x0f)
164   /* latch data for future use */
165   msm58321->latch = data & 0x0f;
166
167   if (!msm58321->cs1 || !msm58321->cs2) return;
168
169   if (msm58321->address_write)
117170   {
118   case REGISTER_RESET:
119      if (LOG) logerror("MSM58321 '%s' Reset\n", device->tag);
120      break;
171      /* latch address */
172      msm58321->address = msm58321->latch;
173   }
121174
122   case REGISTER_REF0:
123   case REGISTER_REF1:
124      if (LOG) logerror("MSM58321 '%s' Reference Signal\n", device->tag);
125      break;
175   if (msm58321->write)
176   {
177      switch(msm58321->latch)
178      {
179      case REGISTER_RESET:
180         if (LOG) logerror("MSM58321 '%s' Reset\n", device->tag);
181         break;
126182
127   default:
128      if (LOG) logerror("MSM58321 '%s' Register %01x = %01x\n", device->tag, offset, data & 0x0f);
129      msm58321->reg[offset] = data & 0x0f;
130      break;
183      case REGISTER_REF0:
184      case REGISTER_REF1:
185         if (LOG) logerror("MSM58321 '%s' Reference Signal\n", device->tag);
186         break;
187
188      default:
189         if (LOG) logerror("MSM58321 '%s' Register %01x = %01x\n", device->tag, offset, data & 0x0f);
190         msm58321->reg[offset] = msm58321->latch & 0x0f;
191         break;
192      }
131193   }
132194}
133195
196/*-------------------------------------------------
197    msm58321_cs1_w - chip select 1
198-------------------------------------------------*/
199
200WRITE_LINE_DEVICE_HANDLER( msm58321_cs1_w )
201{
202   msm58321_t *msm58321 = get_safe_token(device);
203
204   if (LOG) logerror("MSM58321 '%s' CS1: %u\n", device->tag, state);
205
206   msm58321->cs1 = state;
207}
208
209/*-------------------------------------------------
210    msm58321_cs2_w - chip select 2
211-------------------------------------------------*/
212
213WRITE_LINE_DEVICE_HANDLER( msm58321_cs2_w )
214{
215   msm58321_t *msm58321 = get_safe_token(device);
216
217   if (LOG) logerror("MSM58321 '%s' CS2: %u\n", device->tag, state);
218
219   msm58321->cs2 = state;
220}
221
222/*-------------------------------------------------
223    msm58321_busy_r - busy flag read
224-------------------------------------------------*/
225
226READ_LINE_DEVICE_HANDLER( msm58321_busy_r )
227{
228   msm58321_t *msm58321 = get_safe_token(device);
229
230   return msm58321->busy;
231}
232
233/*-------------------------------------------------
234    msm58321_read_w - data read handshake
235-------------------------------------------------*/
236
237WRITE_LINE_DEVICE_HANDLER( msm58321_read_w )
238{
239   msm58321_t *msm58321 = get_safe_token(device);
240
241   if (LOG) logerror("MSM58321 '%s' READ: %u\n", device->tag, state);
242
243   msm58321->read = state;
244}
245
246/*-------------------------------------------------
247    msm58321_write_w - data write handshake
248-------------------------------------------------*/
249
250WRITE_LINE_DEVICE_HANDLER( msm58321_write_w )
251{
252   msm58321_t *msm58321 = get_safe_token(device);
253
254   if (LOG) logerror("MSM58321 '%s' WRITE: %u\n", device->tag, state);
255
256   msm58321->write = state;
257}
258
259/*-------------------------------------------------
260    msm58321_address_write_w - adddress write
261   handshake
262-------------------------------------------------*/
263
264WRITE_LINE_DEVICE_HANDLER( msm58321_address_write_w )
265{
266   msm58321_t *msm58321 = get_safe_token(device);
267
268   if (LOG) logerror("MSM58321 '%s' ADDRESS WRITE: %u\n", device->tag, state);
269
270   msm58321->address_write = state;
271}
272
273/*-------------------------------------------------
274    msm58321_stop_w - stop count
275-------------------------------------------------*/
276
134277WRITE_LINE_DEVICE_HANDLER( msm58321_stop_w )
135278{
136279//   msm58321_t *msm58321 = get_safe_token(device);
r5224r5225
138281   if (LOG) logerror("MSM58321 '%s' STOP: %u\n", device->tag, state);
139282}
140283
284/*-------------------------------------------------
285    msm58321_test_w - test
286-------------------------------------------------*/
287
141288WRITE_LINE_DEVICE_HANDLER( msm58321_test_w )
142289{
143290//   msm58321_t *msm58321 = get_safe_token(device);
r5224r5225
176323   timer_adjust_periodic(msm58321->busy_timer, attotime_zero, 0, ATTOTIME_IN_HZ(2));
177324
178325   /* register for state saving */
179//   state_save_register_device_item(device, 0, msm58321->);
326   state_save_register_device_item(device, 0, msm58321->cs1);
327   state_save_register_device_item(device, 0, msm58321->cs2);
328   state_save_register_device_item(device, 0, msm58321->busy);
329   state_save_register_device_item(device, 0, msm58321->read);
330   state_save_register_device_item(device, 0, msm58321->write);
331   state_save_register_device_item(device, 0, msm58321->address_write);
332   state_save_register_device_item_array(device, 0, msm58321->reg);
333   state_save_register_device_item(device, 0, msm58321->latch);
334   state_save_register_device_item(device, 0, msm58321->address);
180335}
181336
182337/*-------------------------------------------------
183    DEVICE_GET_INFO( msm58321 )
338    DEVICE_GET_INFO( msm58321rs )
184339-------------------------------------------------*/
185340
186DEVICE_GET_INFO( msm58321 )
341DEVICE_GET_INFO( msm58321rs )
187342{
188343   switch (state)
189344   {
r5224r5225
198353      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
199354
200355      /* --- the following bits of info are returned as NULL-terminated strings --- */
201      case DEVINFO_STR_NAME:                     strcpy(info->s, "OKI MSM58321");         break;
202      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "OKI MSM58321");         break;
356      case DEVINFO_STR_NAME:                     strcpy(info->s, "OKI MSM58321RS");         break;
357      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "OKI MSM58321RS");         break;
203358      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
204359      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
205360      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
src/mess/machine/msm58321.h
r5224r5225
11/**********************************************************************
22
3    OKI MSM58321 Real Time Clock/Calendar emulation
3    OKI MSM58321RS Real Time Clock/Calendar emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r5224r5225
1010               CS2    1 |*    \_/     | 16  Vdd
1111             WRITE    2 |          | 15  XT
1212              READ    3 |          | 14  _XT
13               D0    4 |   MSM58321    | 13  CS1
13               D0    4 | MSM58321RS    | 13  CS1
1414               D1    5 |          | 12  TEST
1515               D2    6 |          | 11  STOP
1616               D3    7 |          | 10  _BUSY
r5224r5225
2727    MACROS / CONSTANTS
2828***************************************************************************/
2929
30#define MSM58321      DEVICE_GET_INFO_NAME(msm58321)
30#define MSM58321RS      DEVICE_GET_INFO_NAME(msm58321rs)
3131
32#define MDRV_MSM58321_ADD(_tag, _clock, _intrf) \
33   MDRV_DEVICE_ADD(_tag, MSM58321, _clock) \
32#define MDRV_MSM58321RS_ADD(_tag, _clock, _intrf) \
33   MDRV_DEVICE_ADD(_tag, MSM58321RS, _clock) \
3434   MDRV_DEVICE_CONFIG(_intrf)
3535
3636#define MSM58321_INTERFACE(name) \
37   const msm58321_interface (name)=
37   const msm58321_interface (name) =
3838
3939/***************************************************************************
4040    TYPE DEFINITIONS
r5224r5225
5151***************************************************************************/
5252
5353/* device interface */
54DEVICE_GET_INFO( msm58321 );
54DEVICE_GET_INFO( msm58321rs );
5555
5656/* register access */
57READ8_DEVICE_HANDLER( msm58321_a_r );
58WRITE8_DEVICE_HANDLER( msm58321_b_w );
57READ8_DEVICE_HANDLER( msm58321_r );
58WRITE8_DEVICE_HANDLER( msm58321_w );
5959
60/* chip select */
61WRITE_LINE_DEVICE_HANDLER( msm58321_cs1_w );
62WRITE_LINE_DEVICE_HANDLER( msm58321_cs2_w );
63
64/* handshaking */
65READ_LINE_DEVICE_HANDLER( msm58321_busy_r );
66WRITE_LINE_DEVICE_HANDLER( msm58321_read_w );
67WRITE_LINE_DEVICE_HANDLER( msm58321_write_w );
68WRITE_LINE_DEVICE_HANDLER( msm58321_address_write_w );
69
6070/* stop */
6171WRITE_LINE_DEVICE_HANDLER( msm58321_stop_w );
6272
src/mess/drivers/v1050.c
r5224r5225
9595
9696   TODO:
9797
98   - ?
99      Device 'u76': warning - attempt to direct-map address 00001FFD in program space
100      Device 'u76': warning - attempt to direct-map address 00001FFE in program space
101      Device 'u76': warning - attempt to direct-map address 00001FFF in program space
102
98103   - keyboard hack
99104   - rombank1,2 to 0-0x1fff
100105   - interrupts
101   - RTC58321 chip
102106   - real keyboard w/i8049
103107   - Winchester (Xebec S1410 controller)
104108
r5224r5225
299303static READ8_HANDLER( v1050_get_key )
300304{
301305   v1050_state *state = space->machine->driver_data;
306
302307   state->keyavail = 0;
308
309   v1050_set_int(space->machine, INT_KEYBOARD, 0);
310
303311   return state->keydata;
304   //state->keydata = 0xff;
305   // return val;
306312}
307313
308314static READ8_HANDLER( v1050_get_key_status )
309315{
310316   v1050_state *state = space->machine->driver_data;
317
311318   UINT8 val =   msm8251_status_r(state->i8251_kb, 0);
319
312320   return val | (state->keyavail ? 0x02 : 0x00);
313321}
314322
r5224r5225
748756
749757/* MSM58321 Interface */
750758
751static WRITE_LINE_DEVICE_HANDLER( msm58321_busy_w )
752{
753   v1050_state *driver_state = device->machine->driver_data;
754
755   driver_state->rtc_busy = state;
756}
757
758759static MSM58321_INTERFACE( msm58321_intf )
759760{
760   DEVCB_LINE(msm58321_busy_w)
761   DEVCB_NULL
761762};
762763
763764/* Display 8255A Interface */
r5224r5225
873874
874875        bit      signal      description
875876
876      PC0     pr_strobe
877        PC1     f_int_enb
877      PC0     pr_strobe   printer strobe
878        PC1     f_int_enb   floppy interrupt enable
878879        PC2     baud_sel_a
879880        PC3     baud_sel_b
880        PC4      pr_busy*
881        PC5     pr_pe*
881        PC4      pr_busy*   printer busy
882        PC5     pr_pe*      printer paper end
882883        PC6     
883884        PC7     
884885   
r5224r5225
925926
926927/* Real Time Clock 8255A Interface */
927928
928static READ8_DEVICE_HANDLER( rtc_8255_a_r )
929{
930   /*
931
932        bit      signal      description
933
934      PA0     D0         RTC data bit 0
935        PA1     D1         RTC data bit 1
936        PA2     D2         RTC data bit 2
937        PA3      D3         RTC data bit 3
938        PA4               
939        PA5               
940        PA6               
941        PA7               
942   
943   */
944
945   logerror("RTC data read\n");
946
947   return 0;
948}
949
950static WRITE8_DEVICE_HANDLER( rtc_8255_a_w )
951{
952   /*
953
954        bit      signal      description
955
956      PA0     D0         RTC data bit 0
957        PA1     D1         RTC data bit 1
958        PA2     D2         RTC data bit 2
959        PA3      D3         RTC data bit 3
960        PA4               
961        PA5               
962        PA6               
963        PA7               
964   
965   */
966
967   logerror("RTC data write %01x\n", data & 0x0f);
968}
969
970929static WRITE8_DEVICE_HANDLER( rtc_8255_b_w )
971930{
972931   /*
r5224r5225
1010969
1011970   v1050_state *state = device->machine->driver_data;
1012971
1013   return state->rtc_busy << 3;
972   return msm58321_busy_r(state->msm58321) << 3;
1014973}
1015974
1016975static WRITE8_DEVICE_HANDLER( rtc_8255_c_w )
r5224r5225
1030989   
1031990   */
1032991
1033//   v1050_state *state = device->machine->driver_data;
1034   logerror("Clock Address Write: %u\n", BIT(data, 4));
1035   logerror("Clock Data Write: %u\n", BIT(data, 5));
1036   logerror("Clock Data Read: %u\n", BIT(data, 6));
1037   logerror("Clock Device Select: %u\n", BIT(data, 7));
992   v1050_state *state = device->machine->driver_data;
993
994   msm58321_address_write_w(state->msm58321, BIT(data, 4));
995   msm58321_write_w(state->msm58321, BIT(data, 5));
996   msm58321_read_w(state->msm58321, BIT(data, 6));
997   msm58321_cs2_w(state->msm58321, BIT(data, 7));
1038998}
1039999
10401000static I8255A_INTERFACE( rtc_8255_intf )
10411001{
1042   DEVCB_HANDLER(rtc_8255_a_r),      // Port A read
1002   DEVCB_DEVICE_HANDLER(MSM58321RS_TAG, msm58321_r),   // Port A read
10431003   DEVCB_NULL,                     // Port B read
10441004   DEVCB_HANDLER(rtc_8255_c_r),      // Port C read
1045   DEVCB_HANDLER(rtc_8255_a_w),      // Port A read
1005   DEVCB_DEVICE_HANDLER(MSM58321RS_TAG, msm58321_w),   // Port A write
10461006   DEVCB_HANDLER(rtc_8255_b_w),      // Port B write
10471007   DEVCB_HANDLER(rtc_8255_c_w)         // Port C write
10481008};
r5224r5225
11541114   /* initialize I8214 */
11551115   i8214_etlg_w(state->i8214, 1);
11561116   i8214_inte_w(state->i8214, 1);
1117   
1118   /* initialize RTC */
1119   msm58321_cs1_w(state->msm58321, 1);
11571120
11581121   /* setup memory banking */
11591122   memory_configure_bank(machine, 1, 0, 2, mess_ram, 0x10000);
r5224r5225
11841147   state_save_register_global(machine, state->txrdy);
11851148   state_save_register_global(machine, state->baud_sel);
11861149   state_save_register_global(machine, state->bank);
1187   state_save_register_global(machine, state->rtc_busy);
11881150}
11891151
11901152/* Machine Driver */
r5224r5225
12151177
12161178   /* devices */
12171179   MDRV_I8214_ADD(UPB8214_TAG, XTAL_16MHz/4, v1050_8214_intf)
1218   MDRV_MSM58321_ADD(MSM58321RS_TAG, XTAL_32_768kHz, msm58321_intf)
1180   MDRV_MSM58321RS_ADD(MSM58321RS_TAG, XTAL_32_768kHz, msm58321_intf)
12191181   MDRV_I8255A_ADD(I8255A_DISP_TAG, disp_8255_intf)
12201182   MDRV_I8255A_ADD(I8255A_MISC_TAG, misc_8255_intf)
12211183   MDRV_I8255A_ADD(I8255A_RTC_TAG, rtc_8255_intf)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team