Previous 199869 Revisions Next

r18615 Saturday 20th October, 2012 at 02:44:23 UTC by R. Belmont
(MESS) Mac: Convert 343-004x RTC/PRAM chip into modern RTC device [R. Belmont]
[src/mess/drivers]mac.c
[src/mess/includes]mac.h
[src/mess/machine]mac.c macadb.c macrtc.c macrtc.h*

trunk/src/mess/machine/mac.c
r18614r18615
13331333         {
13341334            val |= 0x08;
13351335         }
1336
1337            val |= m_rtc->data_r();
13361338      }
13371339      else if (ADB_IS_EGRET)
13381340        {
r18614r18615
13501352            val |= 0x10;
13511353         if ((machine().root_device().ioport("MOUSE0")->read() & 0x01) == 0)
13521354            val |= 0x08;
1355
1356            if (!ADB_IS_PM_CLASS)
1357            {
1358                val |= m_rtc->data_r();
1359            }
13531360      }
1354      if (m_rtc_data_out)
1355         val |= 1;
13561361   }
13571362
13581363//  printf("VIA1 IN_B = %02x (PC %x)\n", val, machine().device("maincpu")->safe_pc());
r18614r18615
14051410WRITE8_MEMBER(mac_state::mac_via_out_b)
14061411{
14071412   device_t *sound = machine().device("custom");
1408   int new_rtc_rTCClk;
14091413//  printf("VIA1 OUT B: %02x (PC %x)\n", data, machine().device("maincpu")->safe_pc());
14101414
14111415   if (ADB_IS_PM_VIA1)
r18614r18615
14961500      }
14971501   }
14981502
1499   rtc_write_rTCEnb(data & 0x04);
1500   new_rtc_rTCClk = (data >> 1) & 0x01;
1501   if ((! new_rtc_rTCClk) && (m_rtc_rTCClk))
1502      rtc_shift_data(data & 0x01);
1503   m_rtc_rTCClk = new_rtc_rTCClk;
1504
15051503   if (ADB_IS_BITBANG_CLASS)
15061504   {
15071505      mac_adb_newaction((data & 0x30) >> 4);
1506
1507        m_rtc->ce_w((data & 0x04)>>2);
1508        m_rtc->data_w(data & 0x01);
1509        m_rtc->clk_w((data >> 1) & 0x01);
15081510   }
15091511   else if (ADB_IS_EGRET)
15101512   {
r18614r18615
15221524        m_cuda->set_byteack((data&0x10) ? 1 : 0);
15231525        m_cuda->set_tip((data&0x20) ? 1 : 0);
15241526   }
1527    else if (!ADB_IS_PM_CLASS)
1528    {
1529        m_rtc->ce_w((data & 0x04)>>2);
1530        m_rtc->data_w(data & 0x01);
1531        m_rtc->clk_w((data >> 1) & 0x01);
1532    }
15251533}
15261534
15271535static void mac_via_irq(device_t *device, int state)
r18614r18615
18481856
18491857   m_last_taken_interrupt = -1;
18501858
1851   /* initialize real-time clock */
1852   rtc_init();
1853
18541859   /* setup the memory overlay */
18551860   if (m_model < MODEL_MAC_POWERMAC_6100)   // no overlay for PowerPC
18561861   {
r18614r18615
19021907   m_kbd_shift_reg = 0;
19031908   m_kbd_shift_count = 0;
19041909   m_mouse_bit_x = m_mouse_bit_y = 0;
1905   m_rtc_rTCEnb = 0;
1906   m_rtc_rTCClk = 0;
1907   m_rtc_bit_count = 0;
1908   m_rtc_data_dir = 0;
1909   m_rtc_data_out = 0;
1910   m_rtc_cmd = 0;
1911   m_rtc_write_protect = 0;
1912   m_rtc_state = 0;
19131910   m_pm_data_send = m_pm_data_recv = m_pm_ack = m_pm_req = m_pm_dptr = 0;
19141911   m_pm_state = 0;
19151912   m_last_taken_interrupt = 0;
r18614r18615
21992196      ca2_data ^= 1;
22002197      /* signal 1 Hz irq on CA2 input on the VIA */
22012198      m_via1->write_ca2(ca2_data);
2202      rtc_incticks();
22032199   }
22042200
22052201   // handle SE/30 vblank IRQ
trunk/src/mess/machine/macrtc.c
r18614r18615
11/***************************************************************************
22
3  macrtc.c - the real-time clock & NVRAM chip used in Macs and the Apple IIgs.
4
5  TODO: convert to a device, share between Mac and IIgs
6
3  macrtc.c - the real-time clock & NVRAM chip used in early 680x0 Macs,
4  Apple part numbers 343-0040 (original) and 343-0042 (with extended PRAM)
5 
6  The IIgs has this chip also, but the VGC contains a relatively
7  sophisticated logic block that offloads the low-level serial comms
8  from the CPU, which makes it look quite different to software.
9 
710***************************************************************************/
811
912#include "emu.h"
10#include "includes/mac.h"
13#include "macrtc.h"
1114
1215#ifdef MAME_DEBUG
1316#define LOG_RTC         0
r18614r18615
2326   RTC_STATE_XPWRITE
2427};
2528
26/* init the rtc core */
27void mac_state::rtc_init()
29//**************************************************************************
30//  LIVE DEVICE
31//**************************************************************************
32
33// device type definition
34const device_type RTC3430042 = &device_creator<rtc3430042_device>;
35
36
37//-------------------------------------------------
38//  rtc4543_device - constructor
39//-------------------------------------------------
40
41rtc3430042_device::rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
42    : device_t(mconfig, RTC3430042, "Apple 343-0042 clock/PRAM", tag, owner, clock),
43     device_rtc_interface(mconfig, *this),
44      device_nvram_interface(mconfig, *this)
2845{
46}
47
48//-------------------------------------------------
49//  device_start - device-specific startup
50//-------------------------------------------------
51
52void rtc3430042_device::device_start()
53{
54   // allocate timers
55   m_clock_timer = timer_alloc();
56   m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
57
58   // state saving
59}
60
61void rtc3430042_device::device_reset()
62{
63   set_current_time(machine());
64
65    m_rtc_rTCEnb = 0;
2966   m_rtc_rTCClk = 0;
67   m_rtc_bit_count = 0;
68   m_rtc_data_dir = 0;
69   m_rtc_data_out = 0;
70   m_rtc_cmd = 0;
71   m_rtc_write_protect = 0;
72   m_rtc_state = 0;
3073
31   m_rtc_write_protect = 0;
32   m_rtc_rTCEnb = 0;
33   rtc_write_rTCEnb(1);
74   ce_w(1);
3475   m_rtc_state = RTC_STATE_NORMAL;
3576}
3677
78//-------------------------------------------------
79//  device_timer - handler timer events
80//-------------------------------------------------
81
82void rtc3430042_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
83{
84    advance_seconds();
85}
86
87//-------------------------------------------------
88//  rtc_clock_updated - called by the RTC base class when the time changes
89//-------------------------------------------------
90
91void rtc3430042_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
92{
93    struct tm cur_time, mac_reference;
94    UINT32 seconds;
95
96    cur_time.tm_sec = second;
97    cur_time.tm_min = minute;
98    cur_time.tm_hour = hour;
99    cur_time.tm_mday = day;
100    cur_time.tm_mon = month-1;
101    cur_time.tm_year = year+100;    // assumes post-2000 current system time
102    cur_time.tm_isdst = 0;
103
104    /* The count starts on 1st January 1904 */
105    mac_reference.tm_sec = 0;
106    mac_reference.tm_min = 0;
107    mac_reference.tm_hour = 0;
108    mac_reference.tm_mday = 1;
109    mac_reference.tm_mon = 0;
110    mac_reference.tm_year = 4;
111    mac_reference.tm_isdst = 0;
112
113    seconds = difftime(mktime(&cur_time), mktime(&mac_reference));
114
115    if (LOG_RTC)
116        logerror("second count 0x%lX\n", (unsigned long) seconds);
117
118    m_rtc_seconds[0] = seconds & 0xff;
119    m_rtc_seconds[1] = (seconds >> 8) & 0xff;
120    m_rtc_seconds[2] = (seconds >> 16) & 0xff;
121    m_rtc_seconds[3] = (seconds >> 24) & 0xff;
122}
123
37124/* write the rTCEnb state */
38void mac_state::rtc_write_rTCEnb(int val)
125WRITE_LINE_MEMBER( rtc3430042_device::ce_w )
39126{
40   if (val && (! m_rtc_rTCEnb))
127   if (state && (! m_rtc_rTCEnb))
41128   {
42129      /* rTCEnb goes high (inactive) */
43130      m_rtc_rTCEnb = 1;
r18614r18615
45132      m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0;
46133      m_rtc_state = RTC_STATE_NORMAL;
47134   }
48   else if ((! val) && m_rtc_rTCEnb)
135   else if ((!state) && m_rtc_rTCEnb)
49136   {
50137      /* rTCEnb goes low (active) */
51138      m_rtc_rTCEnb = 0;
r18614r18615
53140      m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0;
54141      m_rtc_state = RTC_STATE_NORMAL;
55142   }
143
144    m_rtc_rTCEnb = state;
56145}
57146
147WRITE_LINE_MEMBER( rtc3430042_device::clk_w )
148{
149   if ((!state) && (m_rtc_rTCClk))
150    {
151      rtc_shift_data(m_data_latch & 0x01);
152    }
153
154    m_rtc_rTCClk = state;
155}
156
157READ_LINE_MEMBER( rtc3430042_device::data_r )
158{
159    return m_rtc_data_out;
160}
161
162WRITE_LINE_MEMBER( rtc3430042_device::data_w )
163{
164    m_data_latch = state;
165}
166
58167/* shift data (called on rTCClk high-to-low transition (?)) */
59void mac_state::rtc_shift_data(int data)
168void rtc3430042_device::rtc_shift_data(int data)
60169{
61170   if (m_rtc_rTCEnb)
62171      /* if enable line inactive (high), do nothing */
r18614r18615
79188   }
80189}
81190
82/* called every second, to increment the Clock count */
83void mac_state::rtc_incticks()
84{
85   if (LOG_RTC)
86      logerror("rtc_incticks called\n");
87
88   if (++m_rtc_seconds[0] == 0)
89      if (++m_rtc_seconds[1] == 0)
90         if (++m_rtc_seconds[2] == 0)
91            ++m_rtc_seconds[3];
92
93   /*if (++m_rtc_seconds[4] == 0)
94        if (++m_rtc_seconds[5] == 0)
95            if (++m_rtc_seconds[6] == 0)
96                ++m_rtc_seconds[7];*/
97}
98
99191/* Executes a command.
100192Called when the first byte after "enable" is received, and when the data byte after a write command
101193is received. */
102void mac_state::rtc_execute_cmd(int data)
194void rtc3430042_device::rtc_execute_cmd(int data)
103195{
104196   int i;
105197
r18614r18615
113205      {
114206         // read command
115207         if (LOG_RTC)
116            printf("RTC: Reading extended address %x = %x\n", m_rtc_xpaddr, m_rtc_ram[m_rtc_xpaddr]);
208            printf("RTC: Reading extended address %x = %x\n", m_rtc_xpaddr, m_pram[m_rtc_xpaddr]);
117209
118210         m_rtc_data_dir = 1;
119         m_rtc_data_byte = m_rtc_ram[m_rtc_xpaddr];
211         m_rtc_data_byte = m_pram[m_rtc_xpaddr];
120212         m_rtc_state = RTC_STATE_NORMAL;
121213      }
122214      else
r18614r18615
131223   {
132224      if (LOG_RTC)
133225         printf("RTC: writing %x to extended address %x\n", data, m_rtc_xpaddr);
134      m_rtc_ram[m_rtc_xpaddr] = data;
226      m_pram[m_rtc_xpaddr] = data;
135227      m_rtc_state = RTC_STATE_NORMAL;
136228   }
137229   else if (m_rtc_state == RTC_STATE_WRITE)
r18614r18615
146238      switch(i)
147239      {
148240      case 0: case 1: case 2: case 3:   /* seconds register */
149      case 4: case 5: case 6: case 7:   /* ??? (not described in IM III) */
150         /* after various tries, I assumed m_rtc_seconds[4+i] is mapped to m_rtc_seconds[i] */
151         if (LOG_RTC)
152            logerror("RTC clock write, address = %X, data = %X\n", i, (int) m_rtc_data_byte);
153         m_rtc_seconds[i & 3] = m_rtc_data_byte;
241        case 4: case 5: case 6: case 7:   /* ??? (not described in IM III) */
242            {
243                /* after various tries, I assumed m_rtc_seconds[4+i] is mapped to m_rtc_seconds[i] */
244                if (LOG_RTC)
245                    logerror("RTC clock write, address = %X, data = %X\n", i, (int) m_rtc_data_byte);
246                m_rtc_seconds[i & 3] = m_rtc_data_byte;
247
248                // TODO: call the base class's time set here
249            }
154250         break;
155251
156252      case 8: case 9: case 10: case 11:   /* RAM address $10-$13 */
157253         if (LOG_RTC)
158            printf("RTC RAM write, address = %X, data = %X\n", (i & 3) + 0x10, (int) m_rtc_data_byte);
159         m_rtc_ram[(i & 3) + 0x10] = m_rtc_data_byte;
254            printf("PRAM write, address = %X, data = %X\n", (i & 3) + 0x10, (int) m_rtc_data_byte);
255         m_pram[(i & 3) + 0x10] = m_rtc_data_byte;
160256         break;
161257
162258      case 12:
r18614r18615
177273      case 24: case 25: case 26: case 27:
178274      case 28: case 29: case 30: case 31:
179275         if (LOG_RTC)
180            printf("RTC RAM write, address = %X, data = %X\n", i & 15, (int) m_rtc_data_byte);
181         m_rtc_ram[i & 15] = m_rtc_data_byte;
276            printf("PRAM write, address = %X, data = %X\n", i & 15, (int) m_rtc_data_byte);
277         m_pram[i & 15] = m_rtc_data_byte;
182278         break;
183279
184280      default:
r18614r18615
217313
218314               case 8: case 9: case 10: case 11:
219315                  if (LOG_RTC)
220                     printf("RTC RAM read, address = %X data = %x\n", (i & 3) + 0x10, m_rtc_ram[(i & 3) + 0x10]);
221                  m_rtc_data_byte = m_rtc_ram[(i & 3) + 0x10];
316                     printf("PRAM read, address = %X data = %x\n", (i & 3) + 0x10, m_pram[(i & 3) + 0x10]);
317                  m_rtc_data_byte = m_pram[(i & 3) + 0x10];
222318                  break;
223319
224320               case 16: case 17: case 18: case 19:
r18614r18615
226322               case 24: case 25: case 26: case 27:
227323               case 28: case 29: case 30: case 31:
228324                  if (LOG_RTC)
229                     printf("RTC RAM read, address = %X data = %x\n", i & 15, m_rtc_ram[i & 15]);
230                  m_rtc_data_byte = m_rtc_ram[i & 15];
325                     printf("PRAM read, address = %X data = %x\n", i & 15, m_pram[i & 15]);
326                  m_rtc_data_byte = m_pram[i & 15];
231327                  break;
232328
233329               default:
r18614r18615
251347   }
252348}
253349
254/* should save PRAM to file */
255/* TODO : save write_protect flag, save time difference with host clock */
256NVRAM_HANDLER( mac )
350void rtc3430042_device::nvram_default()
257351{
258   mac_state *mac = machine.driver_data<mac_state>();
352   memset(m_pram, 0, 0x100);
259353
260   if (read_or_write)
261   {
262      if (LOG_RTC)
263         logerror("Writing PRAM to file\n");
264      file->write(mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
265   }
266   else
267   {
268      if (file)
269      {
270         if (LOG_RTC)
271            logerror("Reading PRAM from file\n");
272         file->read(mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
273      }
274      else
275      {
276         UINT8 *pram = &mac->m_rtc_ram[0];
354    // some Mac ROMs are buggy in the presence of
355    // no NVRAM, so let's try to setup some reasonable defaults
356    m_pram[0] = 0xa8;   // valid
357    m_pram[4] = 0xcc;
358    m_pram[5] = 0x0a;
359    m_pram[6] = 0xcc;
360    m_pram[7] = 0x0a;
361    m_pram[0xc] = 0x42;   // XPRAM valid for Plus/SE
362    m_pram[0xd] = 0x75;
363    m_pram[0xe] = 0x67;
364    m_pram[0xf] = 0x73;
365    m_pram[0x10] = 0x1b;    // volume
366    m_pram[0x11] = 0x88;
367    m_pram[0x12] = 0x01;
368    m_pram[0x13] = 0x4c;
369}
277370
278         if (LOG_RTC)
279            logerror("trashing PRAM\n");
371void rtc3430042_device::nvram_read(emu_file &file)
372{
373   file.read(m_pram, 0x100);
374}
280375
281         memset(mac->m_rtc_ram, 0, sizeof(mac->m_rtc_ram));
282
283         // some Mac ROMs are buggy in the presence of
284         // no NVRAM, so let's initialize it right
285         pram[0] = 0xa8;   // valid
286         pram[4] = 0xcc;
287         pram[5] = 0x0a;
288         pram[6] = 0xcc;
289         pram[7] = 0x0a;
290         pram[0xc] = 0x42;   // XPRAM valid for Plus/SE
291         pram[0xd] = 0x75;
292         pram[0xe] = 0x67;
293         pram[0xf] = 0x73;
294         pram[0x10] = 0x18;
295         pram[0x11] = 0x88;
296         pram[0x12] = 0x01;
297         pram[0x13] = 0x4c;
298
299         if (mac->m_model >= MODEL_MAC_II)
300         {
301            pram[0xc] = 0x4e;   // XPRAM valid is different for these
302            pram[0xd] = 0x75;
303            pram[0xe] = 0x4d;
304            pram[0xf] = 0x63;
305            pram[0x77] = 0x01;
306            pram[0x78] = 0xff;
307            pram[0x79] = 0xff;
308            pram[0x7a] = 0xff;
309            pram[0x7b] = 0xdf;
310
311            if (mac->m_model == MODEL_MAC_IICI)
312            {
313               pram[0] = 0xa8;
314               pram[1] = 0x80;
315               pram[2] = 0x4f;
316               pram[3] = 0x48;
317               pram[4] = 0xcc;
318               pram[5] = 0x0a;
319               pram[6] = 0xcc;
320               pram[7] = 0x0a;
321               pram[0x10] = 0x18;
322               pram[0x11] = 0x88;
323               pram[0x12] = 0x03;
324               pram[0x13] = 0xec;
325               pram[0x57] = 0x1f;
326               pram[0x58] = 0x83;
327               pram[0x59] = 0x86;
328               pram[0x81] = 0x86;
329               pram[0x8a] = 0x05;
330               pram[0xb9] = 0xb0;
331               pram[0xf1] = 0x01;
332               pram[0xf3] = 0x02;
333               pram[0xf9] = 0x01;
334               pram[0xfb] = 0x8e;
335            }
336         }
337      }
338
339      {
340         /* Now we copy the host clock into the Mac clock */
341         /* Cool, isn't it ? :-) */
342         system_time systime;
343         struct tm mac_reference;
344         UINT32 seconds;
345
346         machine.base_datetime(systime);
347
348         /* The count starts on 1st January 1904 */
349         mac_reference.tm_sec = 0;
350         mac_reference.tm_min = 0;
351         mac_reference.tm_hour = 0;
352         mac_reference.tm_mday = 1;
353         mac_reference.tm_mon = 0;
354         mac_reference.tm_year = 4;
355         mac_reference.tm_isdst = 0;
356
357         seconds = difftime((time_t) systime.time, mktime(& mac_reference));
358
359         if (LOG_RTC)
360            logerror("second count 0x%lX\n", (unsigned long) seconds);
361
362         mac->m_rtc_seconds[0] = seconds & 0xff;
363         mac->m_rtc_seconds[1] = (seconds >> 8) & 0xff;
364         mac->m_rtc_seconds[2] = (seconds >> 16) & 0xff;
365         mac->m_rtc_seconds[3] = (seconds >> 24) & 0xff;
366      }
367   }
376void rtc3430042_device::nvram_write(emu_file &file)
377{
378   file.write(m_pram, 0x100);
368379}
369380
370
371
trunk/src/mess/machine/macrtc.h
r0r18615
1/**********************************************************************
2
3    macrtc.h - Apple 343-0042 real time clock and battery RAM
4    by R. Belmont
5
6**********************************************************************/
7
8#pragma once
9
10#ifndef __RTC3430042_H__
11#define __RTC3430042_H__
12
13#include "emu.h"
14
15
16//**************************************************************************
17//  INTERFACE CONFIGURATION MACROS
18//**************************************************************************
19
20#define MCFG_RTC3430042_ADD(_tag, _clock) \
21   MCFG_DEVICE_ADD(_tag, RTC3430042, _clock)
22
23
24
25//**************************************************************************
26//  TYPE DEFINITIONS
27//**************************************************************************
28
29// ======================> rtc3430042_device
30
31class rtc3430042_device :  public device_t,
32                        public device_rtc_interface,
33                        public device_nvram_interface
34{
35public:
36    // construction/destruction
37    rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
38
39    DECLARE_WRITE_LINE_MEMBER( ce_w );
40    DECLARE_WRITE_LINE_MEMBER( clk_w );
41    DECLARE_READ_LINE_MEMBER( data_r );
42    DECLARE_WRITE_LINE_MEMBER( data_w );
43
44protected:
45    // device-level overrides
46    virtual void device_start();
47    virtual void device_reset();
48    virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
49
50    // device_rtc_interface overrides
51    virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
52    virtual bool rtc_feature_leap_year() { return true; }
53
54    // device_nvram_interface overrides
55    virtual void nvram_default();
56    virtual void nvram_read(emu_file &file);
57    virtual void nvram_write(emu_file &file);
58
59private:
60   /* state of rTCEnb and rTCClk lines */
61   UINT8 m_rtc_rTCEnb;
62   UINT8 m_rtc_rTCClk;
63
64   /* serial transmit/receive register : bits are shifted in/out of this byte */
65   UINT8 m_rtc_data_byte;
66   /* serial transmitted/received bit count */
67   UINT8 m_rtc_bit_count;
68   /* direction of the current transfer (0 : VIA->RTC, 1 : RTC->VIA) */
69   UINT8 m_rtc_data_dir;
70   /* when rtc_data_dir == 1, state of rTCData as set by RTC (-> data bit seen by VIA) */
71   UINT8 m_rtc_data_out;
72
73   /* set to 1 when command in progress */
74   UINT8 m_rtc_cmd;
75
76   /* write protect flag */
77   UINT8 m_rtc_write_protect;
78
79   /* internal seconds register */
80   UINT8 m_rtc_seconds[/*8*/4];
81   /* 20-byte long PRAM, or 256-byte long XPRAM */
82   UINT8 m_pram[256];
83   /* current extended address and RTC state */
84   UINT8 m_rtc_xpaddr;
85   UINT8 m_rtc_state;
86    UINT8 m_data_latch;
87
88    // timers
89    emu_timer *m_clock_timer;
90
91    void rtc_shift_data(int data);
92    void rtc_execute_cmd(int data);
93};
94
95
96// device type definition
97extern const device_type RTC3430042;
98
99#endif
trunk/src/mess/machine/macadb.c
r18614r18615
857857         {
858858            for (int i = 0; i < 20; i++)
859859            {
860               m_rtc_ram[i] = m_pm_cmd[1+i];
860               m_adb_pram[i] = m_pm_cmd[1+i];
861861            }
862862         }
863863         break;
r18614r18615
869869
870870            for (i = 0; i < m_pm_cmd[3]; i++)
871871            {
872               m_rtc_ram[m_pm_cmd[2] + i] = m_pm_cmd[4+i];
872               m_adb_pram[m_pm_cmd[2] + i] = m_pm_cmd[4+i];
873873            }
874874         }
875875         break;
r18614r18615
877877      case 0x38:  // read time
878878         {
879879            m_pm_out[0] = m_pm_out[1] = 4;
880            m_pm_out[2] = m_rtc_seconds[0];
881            m_pm_out[3] = m_rtc_seconds[1];
882            m_pm_out[4] = m_rtc_seconds[2];
883            m_pm_out[5] = m_rtc_seconds[3];
880            m_pm_out[2] = 0x63; // famous Mac RTC value of 8/27/56 8:35:00 PM
881            m_pm_out[3] = 0x0b;
882            m_pm_out[4] = 0xd1;
883            m_pm_out[5] = 0x78;
884884            m_pm_slen = 6;
885885            m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200)));
886886         }
r18614r18615
893893            m_pm_out[0] = m_pm_out[1] = 20;
894894            for (i = 0; i < 20; i++)
895895            {
896               m_pm_out[2 + i] = m_rtc_ram[i];
896               m_pm_out[2 + i] = m_adb_pram[i];
897897            }
898898            m_pm_slen = 22;
899899            m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200)));
r18614r18615
908908            m_pm_out[0] = m_pm_out[1] = m_pm_cmd[3];
909909            for (i = 0; i < m_pm_cmd[3]; i++)
910910            {
911               m_pm_out[2 + i] = m_rtc_ram[m_pm_cmd[2] + i];
911               m_pm_out[2 + i] = m_adb_pram[m_pm_cmd[2] + i];
912912            }
913913            m_pm_slen = m_pm_out[0] + 2;
914914            m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200)));
trunk/src/mess/includes/mac.h
r18614r18615
1818#include "machine/ncr539x.h"
1919#include "machine/ncr5380.h"
2020#include "machine/mackbd.h"
21#include "machine/macrtc.h"
2122#include "sound/asc.h"
2223#include "sound/awacs.h"
2324
r18614r18615
144145void mac_asc_irq(device_t *device, int state);
145146void mac_fdc_set_enable_lines(device_t *device, int enable_mask);
146147
147
148
149
150
151
152NVRAM_HANDLER( mac );
153
154/*----------- defined in video/mac.c -----------*/
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180148/*----------- defined in audio/mac.c -----------*/
181149
182150class mac_sound_device : public device_t,
r18614r18615
229197        m_539x_2(*this, MAC_539X_2_TAG),
230198      m_ncr5380(*this, "scsi:ncr5380"),
231199        m_mackbd(*this, MACKBD_TAG),
200      m_rtc(*this,"rtc"),
232201      m_vram(*this,"vram"),
233202      m_vram16(*this,"vram16")
234203    { }
r18614r18615
246215    optional_device<ncr539x_device> m_539x_2;
247216    optional_device<ncr5380_device> m_ncr5380;
248217    optional_device<mackbd_device> m_mackbd;
218   optional_device<rtc3430042_device> m_rtc;
249219
250220   virtual void machine_start();
251221   virtual void machine_reset();
r18614r18615
290260
291261   int irq_count, ca1_data, ca2_data;
292262
293   /* state of rTCEnb and rTCClk lines */
294   UINT8 m_rtc_rTCEnb;
295   UINT8 m_rtc_rTCClk;
296
297   /* serial transmit/receive register : bits are shifted in/out of this byte */
298   UINT8 m_rtc_data_byte;
299   /* serial transmitted/received bit count */
300   UINT8 m_rtc_bit_count;
301   /* direction of the current transfer (0 : VIA->RTC, 1 : RTC->VIA) */
302   UINT8 m_rtc_data_dir;
303   /* when rtc_data_dir == 1, state of rTCData as set by RTC (-> data bit seen by VIA) */
304   UINT8 m_rtc_data_out;
305
306   /* set to 1 when command in progress */
307   UINT8 m_rtc_cmd;
308
309   /* write protect flag */
310   UINT8 m_rtc_write_protect;
311
312   /* internal seconds register */
313   UINT8 m_rtc_seconds[/*8*/4];
314   /* 20-byte long PRAM, or 256-byte long XPRAM */
315   UINT8 m_rtc_ram[256];
316   /* current extended address and RTC state */
317   UINT8 m_rtc_xpaddr;
318   UINT8 m_rtc_state;
319
320263   // Mac ADB state
321264   INT32 m_adb_irq_pending, m_adb_waiting_cmd, m_adb_datasize, m_adb_buffer[257];
322265   INT32 m_adb_state, m_adb_command, m_adb_send, m_adb_timer_ticks, m_adb_extclock, m_adb_direction;
r18614r18615
446389   DECLARE_DIRECT_UPDATE_MEMBER(overlay_opbaseoverride);
447390private:
448391   int has_adb();
449   void rtc_init();
450   void rtc_execute_cmd(int data);
451392   void adb_reset();
452393   void adb_vblank();
453394   int adb_pollkbd(int update);
r18614r18615
467408   int m_adb_keybaddr;
468409   int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers;
469410
411   // PRAM for ADB MCU HLEs (mostly unused now)
412   UINT8 m_adb_pram[256];
413
470414    UINT8 m_oss_regs[0x400];
471415
472416    // AMIC for x100 PowerMacs
trunk/src/mess/drivers/mac.c
r18614r18615
905905   MCFG_SOUND_ADD("custom", MAC_SOUND, 0)
906906   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
907907
908   /* nvram */
909   MCFG_NVRAM_HANDLER(mac)
910
911908   /* devices */
909    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
912910   MCFG_IWM_ADD("fdc", mac_iwm_interface)
913911   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
914912
r18614r18615
989987   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
990988   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
991989
992   /* nvram */
993   MCFG_NVRAM_HANDLER(mac)
994
995990   /* devices */
991    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
996992   MCFG_SCSIBUS_ADD("scsi")
997993   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
998994   MCFG_SCSIDEV_ADD("scsi:harddisk2", SCSIHD, SCSI_ID_5)
r18614r18615
10271023   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
10281024   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
10291025
1030   /* nvram */
1031   MCFG_NVRAM_HANDLER(mac)
1032
10331026   /* devices */
1027    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
10341028   MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf)
10351029   MCFG_NUBUS_SLOT_ADD("nubus","nb9", mac_nubus_cards, "48gc", NULL)
10361030   MCFG_NUBUS_SLOT_ADD("nubus","nba", mac_nubus_cards, NULL, NULL)
r18614r18615
10791073   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
10801074   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
10811075
1082   /* nvram */
1083   MCFG_NVRAM_HANDLER(mac)
1084
10851076   /* devices */
1077    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
10861078   MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf)
10871079   MCFG_NUBUS_SLOT_ADD("nubus","nb9", mac_nubus_cards, "48gc", NULL)
10881080   MCFG_NUBUS_SLOT_ADD("nubus","nba", mac_nubus_cards, NULL, NULL)
r18614r18615
12861278   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
12871279   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
12881280
1289   /* nvram */
1290   MCFG_NVRAM_HANDLER(mac)
1291
12921281   /* devices */
1282    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
12931283   MCFG_SCSIBUS_ADD("scsi")
12941284   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
12951285   MCFG_SCSIDEV_ADD("scsi:harddisk2", SCSIHD, SCSI_ID_5)
r18614r18615
13371327   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
13381328   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
13391329
1340   /* nvram */
1341   MCFG_NVRAM_HANDLER(mac)
1342
13431330   /* devices */
13441331   MCFG_SCSIBUS_ADD("scsi")
13451332   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
r18614r18615
14081395   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
14091396   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
14101397
1411   /* nvram */
1412   MCFG_NVRAM_HANDLER(mac)
1413
14141398   /* devices */
14151399   MCFG_SCSIBUS_ADD("scsi")
14161400   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
r18614r18615
15801564   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
15811565   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
15821566
1583   /* nvram */
1584   MCFG_NVRAM_HANDLER(mac)
1585
15861567   /* devices */
15871568   MCFG_SCSIBUS_ADD("scsi")
15881569   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
r18614r18615
16281609   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
16291610   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
16301611
1631   /* nvram */
1632   MCFG_NVRAM_HANDLER(mac)
1633
16341612   /* devices */
1613    MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz)
16351614   MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf)
16361615   MCFG_NUBUS_SLOT_ADD("nubus","nbd", mac_nubus_cards, NULL, NULL)
16371616   MCFG_NUBUS_SLOT_ADD("nubus","nbe", mac_nubus_cards, NULL, NULL)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team