trunk/src/mess/machine/macrtc.c
| r18614 | r18615 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 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 | |
| 7 | 10 | ***************************************************************************/ |
| 8 | 11 | |
| 9 | 12 | #include "emu.h" |
| 10 | | #include "includes/mac.h" |
| 13 | #include "macrtc.h" |
| 11 | 14 | |
| 12 | 15 | #ifdef MAME_DEBUG |
| 13 | 16 | #define LOG_RTC 0 |
| r18614 | r18615 | |
| 23 | 26 | RTC_STATE_XPWRITE |
| 24 | 27 | }; |
| 25 | 28 | |
| 26 | | /* init the rtc core */ |
| 27 | | void mac_state::rtc_init() |
| 29 | //************************************************************************** |
| 30 | // LIVE DEVICE |
| 31 | //************************************************************************** |
| 32 | |
| 33 | // device type definition |
| 34 | const device_type RTC3430042 = &device_creator<rtc3430042_device>; |
| 35 | |
| 36 | |
| 37 | //------------------------------------------------- |
| 38 | // rtc4543_device - constructor |
| 39 | //------------------------------------------------- |
| 40 | |
| 41 | rtc3430042_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) |
| 28 | 45 | { |
| 46 | } |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // device_start - device-specific startup |
| 50 | //------------------------------------------------- |
| 51 | |
| 52 | void 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 | |
| 61 | void rtc3430042_device::device_reset() |
| 62 | { |
| 63 | set_current_time(machine()); |
| 64 | |
| 65 | m_rtc_rTCEnb = 0; |
| 29 | 66 | 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; |
| 30 | 73 | |
| 31 | | m_rtc_write_protect = 0; |
| 32 | | m_rtc_rTCEnb = 0; |
| 33 | | rtc_write_rTCEnb(1); |
| 74 | ce_w(1); |
| 34 | 75 | m_rtc_state = RTC_STATE_NORMAL; |
| 35 | 76 | } |
| 36 | 77 | |
| 78 | //------------------------------------------------- |
| 79 | // device_timer - handler timer events |
| 80 | //------------------------------------------------- |
| 81 | |
| 82 | void 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 | |
| 91 | void 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 | |
| 37 | 124 | /* write the rTCEnb state */ |
| 38 | | void mac_state::rtc_write_rTCEnb(int val) |
| 125 | WRITE_LINE_MEMBER( rtc3430042_device::ce_w ) |
| 39 | 126 | { |
| 40 | | if (val && (! m_rtc_rTCEnb)) |
| 127 | if (state && (! m_rtc_rTCEnb)) |
| 41 | 128 | { |
| 42 | 129 | /* rTCEnb goes high (inactive) */ |
| 43 | 130 | m_rtc_rTCEnb = 1; |
| r18614 | r18615 | |
| 45 | 132 | m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0; |
| 46 | 133 | m_rtc_state = RTC_STATE_NORMAL; |
| 47 | 134 | } |
| 48 | | else if ((! val) && m_rtc_rTCEnb) |
| 135 | else if ((!state) && m_rtc_rTCEnb) |
| 49 | 136 | { |
| 50 | 137 | /* rTCEnb goes low (active) */ |
| 51 | 138 | m_rtc_rTCEnb = 0; |
| r18614 | r18615 | |
| 53 | 140 | m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0; |
| 54 | 141 | m_rtc_state = RTC_STATE_NORMAL; |
| 55 | 142 | } |
| 143 | |
| 144 | m_rtc_rTCEnb = state; |
| 56 | 145 | } |
| 57 | 146 | |
| 147 | WRITE_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 | |
| 157 | READ_LINE_MEMBER( rtc3430042_device::data_r ) |
| 158 | { |
| 159 | return m_rtc_data_out; |
| 160 | } |
| 161 | |
| 162 | WRITE_LINE_MEMBER( rtc3430042_device::data_w ) |
| 163 | { |
| 164 | m_data_latch = state; |
| 165 | } |
| 166 | |
| 58 | 167 | /* shift data (called on rTCClk high-to-low transition (?)) */ |
| 59 | | void mac_state::rtc_shift_data(int data) |
| 168 | void rtc3430042_device::rtc_shift_data(int data) |
| 60 | 169 | { |
| 61 | 170 | if (m_rtc_rTCEnb) |
| 62 | 171 | /* if enable line inactive (high), do nothing */ |
| r18614 | r18615 | |
| 79 | 188 | } |
| 80 | 189 | } |
| 81 | 190 | |
| 82 | | /* called every second, to increment the Clock count */ |
| 83 | | void 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 | | |
| 99 | 191 | /* Executes a command. |
| 100 | 192 | Called when the first byte after "enable" is received, and when the data byte after a write command |
| 101 | 193 | is received. */ |
| 102 | | void mac_state::rtc_execute_cmd(int data) |
| 194 | void rtc3430042_device::rtc_execute_cmd(int data) |
| 103 | 195 | { |
| 104 | 196 | int i; |
| 105 | 197 | |
| r18614 | r18615 | |
| 113 | 205 | { |
| 114 | 206 | // read command |
| 115 | 207 | 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]); |
| 117 | 209 | |
| 118 | 210 | 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]; |
| 120 | 212 | m_rtc_state = RTC_STATE_NORMAL; |
| 121 | 213 | } |
| 122 | 214 | else |
| r18614 | r18615 | |
| 131 | 223 | { |
| 132 | 224 | if (LOG_RTC) |
| 133 | 225 | 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; |
| 135 | 227 | m_rtc_state = RTC_STATE_NORMAL; |
| 136 | 228 | } |
| 137 | 229 | else if (m_rtc_state == RTC_STATE_WRITE) |
| r18614 | r18615 | |
| 146 | 238 | switch(i) |
| 147 | 239 | { |
| 148 | 240 | 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 | } |
| 154 | 250 | break; |
| 155 | 251 | |
| 156 | 252 | case 8: case 9: case 10: case 11: /* RAM address $10-$13 */ |
| 157 | 253 | 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; |
| 160 | 256 | break; |
| 161 | 257 | |
| 162 | 258 | case 12: |
| r18614 | r18615 | |
| 177 | 273 | case 24: case 25: case 26: case 27: |
| 178 | 274 | case 28: case 29: case 30: case 31: |
| 179 | 275 | 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; |
| 182 | 278 | break; |
| 183 | 279 | |
| 184 | 280 | default: |
| r18614 | r18615 | |
| 217 | 313 | |
| 218 | 314 | case 8: case 9: case 10: case 11: |
| 219 | 315 | 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]; |
| 222 | 318 | break; |
| 223 | 319 | |
| 224 | 320 | case 16: case 17: case 18: case 19: |
| r18614 | r18615 | |
| 226 | 322 | case 24: case 25: case 26: case 27: |
| 227 | 323 | case 28: case 29: case 30: case 31: |
| 228 | 324 | 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]; |
| 231 | 327 | break; |
| 232 | 328 | |
| 233 | 329 | default: |
| r18614 | r18615 | |
| 251 | 347 | } |
| 252 | 348 | } |
| 253 | 349 | |
| 254 | | /* should save PRAM to file */ |
| 255 | | /* TODO : save write_protect flag, save time difference with host clock */ |
| 256 | | NVRAM_HANDLER( mac ) |
| 350 | void rtc3430042_device::nvram_default() |
| 257 | 351 | { |
| 258 | | mac_state *mac = machine.driver_data<mac_state>(); |
| 352 | memset(m_pram, 0, 0x100); |
| 259 | 353 | |
| 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 | } |
| 277 | 370 | |
| 278 | | if (LOG_RTC) |
| 279 | | logerror("trashing PRAM\n"); |
| 371 | void rtc3430042_device::nvram_read(emu_file &file) |
| 372 | { |
| 373 | file.read(m_pram, 0x100); |
| 374 | } |
| 280 | 375 | |
| 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 | | } |
| 376 | void rtc3430042_device::nvram_write(emu_file &file) |
| 377 | { |
| 378 | file.write(m_pram, 0x100); |
| 368 | 379 | } |
| 369 | 380 | |
| 370 | | |
| 371 | | |
trunk/src/mess/machine/macrtc.h
| r0 | r18615 | |
| 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 | |
| 31 | class rtc3430042_device : public device_t, |
| 32 | public device_rtc_interface, |
| 33 | public device_nvram_interface |
| 34 | { |
| 35 | public: |
| 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 | |
| 44 | protected: |
| 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 | |
| 59 | private: |
| 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 |
| 97 | extern const device_type RTC3430042; |
| 98 | |
| 99 | #endif |
trunk/src/mess/includes/mac.h
| r18614 | r18615 | |
| 18 | 18 | #include "machine/ncr539x.h" |
| 19 | 19 | #include "machine/ncr5380.h" |
| 20 | 20 | #include "machine/mackbd.h" |
| 21 | #include "machine/macrtc.h" |
| 21 | 22 | #include "sound/asc.h" |
| 22 | 23 | #include "sound/awacs.h" |
| 23 | 24 | |
| r18614 | r18615 | |
| 144 | 145 | void mac_asc_irq(device_t *device, int state); |
| 145 | 146 | void mac_fdc_set_enable_lines(device_t *device, int enable_mask); |
| 146 | 147 | |
| 147 | | |
| 148 | | |
| 149 | | |
| 150 | | |
| 151 | | |
| 152 | | NVRAM_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 | | |
| 180 | 148 | /*----------- defined in audio/mac.c -----------*/ |
| 181 | 149 | |
| 182 | 150 | class mac_sound_device : public device_t, |
| r18614 | r18615 | |
| 229 | 197 | m_539x_2(*this, MAC_539X_2_TAG), |
| 230 | 198 | m_ncr5380(*this, "scsi:ncr5380"), |
| 231 | 199 | m_mackbd(*this, MACKBD_TAG), |
| 200 | m_rtc(*this,"rtc"), |
| 232 | 201 | m_vram(*this,"vram"), |
| 233 | 202 | m_vram16(*this,"vram16") |
| 234 | 203 | { } |
| r18614 | r18615 | |
| 246 | 215 | optional_device<ncr539x_device> m_539x_2; |
| 247 | 216 | optional_device<ncr5380_device> m_ncr5380; |
| 248 | 217 | optional_device<mackbd_device> m_mackbd; |
| 218 | optional_device<rtc3430042_device> m_rtc; |
| 249 | 219 | |
| 250 | 220 | virtual void machine_start(); |
| 251 | 221 | virtual void machine_reset(); |
| r18614 | r18615 | |
| 290 | 260 | |
| 291 | 261 | int irq_count, ca1_data, ca2_data; |
| 292 | 262 | |
| 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 | | |
| 320 | 263 | // Mac ADB state |
| 321 | 264 | INT32 m_adb_irq_pending, m_adb_waiting_cmd, m_adb_datasize, m_adb_buffer[257]; |
| 322 | 265 | INT32 m_adb_state, m_adb_command, m_adb_send, m_adb_timer_ticks, m_adb_extclock, m_adb_direction; |
| r18614 | r18615 | |
| 446 | 389 | DECLARE_DIRECT_UPDATE_MEMBER(overlay_opbaseoverride); |
| 447 | 390 | private: |
| 448 | 391 | int has_adb(); |
| 449 | | void rtc_init(); |
| 450 | | void rtc_execute_cmd(int data); |
| 451 | 392 | void adb_reset(); |
| 452 | 393 | void adb_vblank(); |
| 453 | 394 | int adb_pollkbd(int update); |
| r18614 | r18615 | |
| 467 | 408 | int m_adb_keybaddr; |
| 468 | 409 | int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers; |
| 469 | 410 | |
| 411 | // PRAM for ADB MCU HLEs (mostly unused now) |
| 412 | UINT8 m_adb_pram[256]; |
| 413 | |
| 470 | 414 | UINT8 m_oss_regs[0x400]; |
| 471 | 415 | |
| 472 | 416 | // AMIC for x100 PowerMacs |
trunk/src/mess/drivers/mac.c
| r18614 | r18615 | |
| 905 | 905 | MCFG_SOUND_ADD("custom", MAC_SOUND, 0) |
| 906 | 906 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 907 | 907 | |
| 908 | | /* nvram */ |
| 909 | | MCFG_NVRAM_HANDLER(mac) |
| 910 | | |
| 911 | 908 | /* devices */ |
| 909 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 912 | 910 | MCFG_IWM_ADD("fdc", mac_iwm_interface) |
| 913 | 911 | MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface) |
| 914 | 912 | |
| r18614 | r18615 | |
| 989 | 987 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 990 | 988 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 991 | 989 | |
| 992 | | /* nvram */ |
| 993 | | MCFG_NVRAM_HANDLER(mac) |
| 994 | | |
| 995 | 990 | /* devices */ |
| 991 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 996 | 992 | MCFG_SCSIBUS_ADD("scsi") |
| 997 | 993 | MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6) |
| 998 | 994 | MCFG_SCSIDEV_ADD("scsi:harddisk2", SCSIHD, SCSI_ID_5) |
| r18614 | r18615 | |
| 1027 | 1023 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1028 | 1024 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1029 | 1025 | |
| 1030 | | /* nvram */ |
| 1031 | | MCFG_NVRAM_HANDLER(mac) |
| 1032 | | |
| 1033 | 1026 | /* devices */ |
| 1027 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 1034 | 1028 | MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf) |
| 1035 | 1029 | MCFG_NUBUS_SLOT_ADD("nubus","nb9", mac_nubus_cards, "48gc", NULL) |
| 1036 | 1030 | MCFG_NUBUS_SLOT_ADD("nubus","nba", mac_nubus_cards, NULL, NULL) |
| r18614 | r18615 | |
| 1079 | 1073 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1080 | 1074 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1081 | 1075 | |
| 1082 | | /* nvram */ |
| 1083 | | MCFG_NVRAM_HANDLER(mac) |
| 1084 | | |
| 1085 | 1076 | /* devices */ |
| 1077 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 1086 | 1078 | MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf) |
| 1087 | 1079 | MCFG_NUBUS_SLOT_ADD("nubus","nb9", mac_nubus_cards, "48gc", NULL) |
| 1088 | 1080 | MCFG_NUBUS_SLOT_ADD("nubus","nba", mac_nubus_cards, NULL, NULL) |
| r18614 | r18615 | |
| 1286 | 1278 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1287 | 1279 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1288 | 1280 | |
| 1289 | | /* nvram */ |
| 1290 | | MCFG_NVRAM_HANDLER(mac) |
| 1291 | | |
| 1292 | 1281 | /* devices */ |
| 1282 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 1293 | 1283 | MCFG_SCSIBUS_ADD("scsi") |
| 1294 | 1284 | MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6) |
| 1295 | 1285 | MCFG_SCSIDEV_ADD("scsi:harddisk2", SCSIHD, SCSI_ID_5) |
| r18614 | r18615 | |
| 1337 | 1327 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1338 | 1328 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1339 | 1329 | |
| 1340 | | /* nvram */ |
| 1341 | | MCFG_NVRAM_HANDLER(mac) |
| 1342 | | |
| 1343 | 1330 | /* devices */ |
| 1344 | 1331 | MCFG_SCSIBUS_ADD("scsi") |
| 1345 | 1332 | MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6) |
| r18614 | r18615 | |
| 1408 | 1395 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1409 | 1396 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1410 | 1397 | |
| 1411 | | /* nvram */ |
| 1412 | | MCFG_NVRAM_HANDLER(mac) |
| 1413 | | |
| 1414 | 1398 | /* devices */ |
| 1415 | 1399 | MCFG_SCSIBUS_ADD("scsi") |
| 1416 | 1400 | MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6) |
| r18614 | r18615 | |
| 1580 | 1564 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1581 | 1565 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1582 | 1566 | |
| 1583 | | /* nvram */ |
| 1584 | | MCFG_NVRAM_HANDLER(mac) |
| 1585 | | |
| 1586 | 1567 | /* devices */ |
| 1587 | 1568 | MCFG_SCSIBUS_ADD("scsi") |
| 1588 | 1569 | MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6) |
| r18614 | r18615 | |
| 1628 | 1609 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1629 | 1610 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
| 1630 | 1611 | |
| 1631 | | /* nvram */ |
| 1632 | | MCFG_NVRAM_HANDLER(mac) |
| 1633 | | |
| 1634 | 1612 | /* devices */ |
| 1613 | MCFG_RTC3430042_ADD("rtc", XTAL_32_768kHz) |
| 1635 | 1614 | MCFG_NUBUS_BUS_ADD("nubus", "maincpu", nubus_intf) |
| 1636 | 1615 | MCFG_NUBUS_SLOT_ADD("nubus","nbd", mac_nubus_cards, NULL, NULL) |
| 1637 | 1616 | MCFG_NUBUS_SLOT_ADD("nubus","nbe", mac_nubus_cards, NULL, NULL) |