src/mess/machine/rp5c15.c
| r4030 | r4031 | |
| 69 | 69 | |
| 70 | 70 | #include "rp5c15.h" |
| 71 | 71 | |
| 72 | | |
| 73 | | static struct rp5c15 rtc; |
| 74 | | |
| 75 | 72 | static emu_timer* rtc_timer; |
| 76 | 73 | |
| 77 | 74 | TIMER_CALLBACK(rtc_alarm_pulse) |
| 78 | 75 | { |
| 79 | | if(rtc.pulse16_state == 0) // low |
| 76 | const device_config* device = ptr; |
| 77 | rp5c15_t* rtc = device->token; |
| 78 | |
| 79 | if(rtc->pulse16_state == 0) // low |
| 80 | 80 | { |
| 81 | | rtc.pulse16_state = 1; // make high |
| 82 | | rtc.pulse_count++; |
| 81 | rtc->pulse16_state = 1; // make high |
| 82 | rtc->pulse_count++; |
| 83 | 83 | } |
| 84 | 84 | else |
| 85 | 85 | { |
| 86 | | rtc.pulse16_state = 0; // make low |
| 86 | rtc->pulse16_state = 0; // make low |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | | if(rtc.pulse_count == 8) |
| 89 | if(rtc->pulse_count == 8) |
| 90 | 90 | { |
| 91 | | rtc.pulse1_state = 0; |
| 91 | rtc->pulse1_state = 0; |
| 92 | 92 | } |
| 93 | | if(rtc.pulse_count == 16) |
| 93 | if(rtc->pulse_count == 16) |
| 94 | 94 | { |
| 95 | | rtc.pulse_count = 0; |
| 96 | | rtc.pulse1_state = 1; |
| 97 | | rtc_add_second(); |
| 95 | rtc->pulse_count = 0; |
| 96 | rtc->pulse1_state = 1; |
| 97 | rtc_add_second(device); |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | | void rp5c15_init(running_machine *machine, const struct rp5c15_interface* intf) |
| 101 | DEVICE_START( rp5c15 ) |
| 102 | 102 | { |
| 103 | rp5c15_t* rtc = device->token; |
| 103 | 104 | mame_system_time systm; |
| 104 | 105 | mame_system_tm time; |
| 105 | 106 | |
| 106 | | rtc.alarm_callback = intf->alarm_irq_callback; |
| 107 | assert(device->machine != NULL); |
| 108 | rtc->intf = device->static_config; |
| 107 | 109 | |
| 108 | | mame_get_base_datetime(machine,&systm); |
| 110 | rtc->alarm_callback = rtc->intf->alarm_irq_callback; |
| 111 | |
| 112 | mame_get_base_datetime(device->machine,&systm); |
| 109 | 113 | time = systm.local_time; |
| 110 | 114 | |
| 111 | 115 | // date/time is stored as BCD |
| 112 | | rtc.systime.sec_1 = time.second % 10; |
| 113 | | rtc.systime.sec_10 = time.second / 10; |
| 114 | | rtc.systime.min_1 = time.minute % 10; |
| 115 | | rtc.systime.min_10 = time.minute / 10; |
| 116 | | rtc.systime.hour_1 = time.hour % 10; |
| 117 | | rtc.systime.hour_10 = time.hour / 10; |
| 118 | | rtc.systime.day_1 = time.mday % 10; |
| 119 | | rtc.systime.day_10 = time.mday / 10; |
| 120 | | rtc.systime.month_1 = (time.month+1) % 10; |
| 121 | | rtc.systime.month_10 = (time.month+1) / 10; |
| 122 | | rtc.systime.year_1 = (time.year - 1980) % 10; |
| 123 | | rtc.systime.year_10 = (time.year - 1980) / 10; |
| 124 | | rtc.systime.dayofweek = time.weekday; |
| 125 | | rtc.alarm.min_1 = time.minute % 10; |
| 126 | | rtc.alarm.min_10 = time.minute / 10; |
| 127 | | rtc.alarm.hour_1 = time.hour % 10; |
| 128 | | rtc.alarm.hour_10 = time.hour / 10; |
| 129 | | rtc.alarm.day_1 = time.mday % 10; |
| 130 | | rtc.alarm.day_10 = time.mday / 10; |
| 131 | | rtc.alarm.dayofweek = time.weekday; |
| 132 | | rtc.leap = time.year % 4; |
| 116 | rtc->systime.sec_1 = time.second % 10; |
| 117 | rtc->systime.sec_10 = time.second / 10; |
| 118 | rtc->systime.min_1 = time.minute % 10; |
| 119 | rtc->systime.min_10 = time.minute / 10; |
| 120 | rtc->systime.hour_1 = time.hour % 10; |
| 121 | rtc->systime.hour_10 = time.hour / 10; |
| 122 | rtc->systime.day_1 = time.mday % 10; |
| 123 | rtc->systime.day_10 = time.mday / 10; |
| 124 | rtc->systime.month_1 = (time.month+1) % 10; |
| 125 | rtc->systime.month_10 = (time.month+1) / 10; |
| 126 | rtc->systime.year_1 = (time.year - 1980) % 10; |
| 127 | rtc->systime.year_10 = (time.year - 1980) / 10; |
| 128 | rtc->systime.dayofweek = time.weekday; |
| 129 | rtc->alarm.min_1 = time.minute % 10; |
| 130 | rtc->alarm.min_10 = time.minute / 10; |
| 131 | rtc->alarm.hour_1 = time.hour % 10; |
| 132 | rtc->alarm.hour_10 = time.hour / 10; |
| 133 | rtc->alarm.day_1 = time.mday % 10; |
| 134 | rtc->alarm.day_10 = time.mday / 10; |
| 135 | rtc->alarm.dayofweek = time.weekday; |
| 136 | rtc->leap = time.year % 4; |
| 133 | 137 | |
| 134 | | rtc.mode = 0x08; // Timer enabled, Alarm disable, BANK 0 selected (defaults are guessed) |
| 135 | | rtc.reset = 0x00; // enable both 1Hz and 16Hz alarm counters by default |
| 136 | | rtc.test = 0x00; |
| 137 | | rtc.pulse_count = 0; |
| 138 | rtc->mode = 0x08; // Timer enabled, Alarm disable, BANK 0 selected (defaults are guessed) |
| 139 | rtc->reset = 0x00; // enable both 1Hz and 16Hz alarm counters by default |
| 140 | rtc->test = 0x00; |
| 141 | rtc->pulse_count = 0; |
| 138 | 142 | |
| 139 | | rtc_timer = timer_alloc(machine, rtc_alarm_pulse, NULL); |
| 143 | rtc_timer = timer_alloc(device->machine, rtc_alarm_pulse, (void*)device); |
| 140 | 144 | timer_adjust_periodic(rtc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(32)); |
| 145 | |
| 146 | return DEVICE_START_OK; |
| 141 | 147 | } |
| 142 | 148 | |
| 143 | | static int rp5c15_read(int offset, UINT16 mem_mask) |
| 149 | static int rp5c15_read(const device_config* device, int offset, UINT16 mem_mask) |
| 144 | 150 | { |
| 145 | | if((rtc.mode & 0x01) == 0x00) // BANK 0 selected |
| 151 | rp5c15_t* rtc = device->token; |
| 152 | if((rtc->mode & 0x01) == 0x00) // BANK 0 selected |
| 146 | 153 | { |
| 147 | 154 | switch(offset) |
| 148 | 155 | { |
| 149 | 156 | case 0: |
| 150 | | return rtc.systime.sec_1; |
| 157 | return rtc->systime.sec_1; |
| 151 | 158 | case 1: |
| 152 | | return rtc.systime.sec_10; |
| 159 | return rtc->systime.sec_10; |
| 153 | 160 | case 2: |
| 154 | | return rtc.systime.min_1; |
| 161 | return rtc->systime.min_1; |
| 155 | 162 | case 3: |
| 156 | | return rtc.systime.min_10; |
| 163 | return rtc->systime.min_10; |
| 157 | 164 | case 4: |
| 158 | | return rtc.systime.hour_1; |
| 165 | return rtc->systime.hour_1; |
| 159 | 166 | case 5: |
| 160 | | return rtc.systime.hour_10; |
| 167 | return rtc->systime.hour_10; |
| 161 | 168 | case 6: |
| 162 | | return rtc.systime.dayofweek; |
| 169 | return rtc->systime.dayofweek; |
| 163 | 170 | case 7: |
| 164 | | return rtc.systime.day_1; |
| 171 | return rtc->systime.day_1; |
| 165 | 172 | case 8: |
| 166 | | return rtc.systime.day_10; |
| 173 | return rtc->systime.day_10; |
| 167 | 174 | case 9: |
| 168 | | return rtc.systime.month_1; |
| 175 | return rtc->systime.month_1; |
| 169 | 176 | case 10: |
| 170 | | return rtc.systime.month_10; |
| 177 | return rtc->systime.month_10; |
| 171 | 178 | case 11: |
| 172 | | return rtc.systime.year_1; |
| 179 | return rtc->systime.year_1; |
| 173 | 180 | case 12: |
| 174 | | return rtc.systime.year_10; |
| 181 | return rtc->systime.year_10; |
| 175 | 182 | case 13: |
| 176 | | return rtc.mode & 0x0f; |
| 183 | return rtc->mode & 0x0f; |
| 177 | 184 | } |
| 178 | 185 | } |
| 179 | 186 | else // BANK 1 selected |
| r4030 | r4031 | |
| 181 | 188 | switch(offset) |
| 182 | 189 | { |
| 183 | 190 | case 0: // CLKOUT |
| 184 | | return rtc.clkout & 0x07; |
| 191 | return rtc->clkout & 0x07; |
| 185 | 192 | case 1: // Adjustment (always returns 0) |
| 186 | 193 | return 0; |
| 187 | 194 | case 2: |
| 188 | | return rtc.alarm.min_1; |
| 195 | return rtc->alarm.min_1; |
| 189 | 196 | case 3: |
| 190 | | return rtc.alarm.min_10; |
| 197 | return rtc->alarm.min_10; |
| 191 | 198 | case 4: |
| 192 | | return rtc.alarm.hour_1; |
| 199 | return rtc->alarm.hour_1; |
| 193 | 200 | case 5: |
| 194 | | return rtc.alarm.hour_10; |
| 201 | return rtc->alarm.hour_10; |
| 195 | 202 | case 6: |
| 196 | | return rtc.alarm.dayofweek; |
| 203 | return rtc->alarm.dayofweek; |
| 197 | 204 | case 7: |
| 198 | | return rtc.alarm.day_1; |
| 205 | return rtc->alarm.day_1; |
| 199 | 206 | case 8: |
| 200 | | return rtc.alarm.day_10; |
| 207 | return rtc->alarm.day_10; |
| 201 | 208 | case 10: // 12/24 hour selection (returns AM/PM?) |
| 202 | 209 | return 0; |
| 203 | 210 | case 11: // Leap year |
| 204 | | return rtc.leap; |
| 211 | return rtc->leap; |
| 205 | 212 | case 13: |
| 206 | | return rtc.mode & 0x0f; |
| 213 | return rtc->mode & 0x0f; |
| 207 | 214 | default: |
| 208 | 215 | return 0; |
| 209 | 216 | } |
| r4030 | r4031 | |
| 211 | 218 | return 0; |
| 212 | 219 | } |
| 213 | 220 | |
| 214 | | static void rp5c15_write(int offset, int data, UINT16 mem_mask) |
| 221 | static void rp5c15_write(const device_config* device, int offset, int data, UINT16 mem_mask) |
| 215 | 222 | { |
| 223 | rp5c15_t* rtc = device->token; |
| 216 | 224 | if(offset == 13) |
| 217 | 225 | { |
| 218 | | rtc.mode = data & 0x0f; |
| 226 | rtc->mode = data & 0x0f; |
| 219 | 227 | return; |
| 220 | 228 | } |
| 221 | | if((rtc.mode & 0x01) == 0x00) // BANK 0 selected |
| 229 | if((rtc->mode & 0x01) == 0x00) // BANK 0 selected |
| 222 | 230 | { |
| 223 | 231 | switch(offset) |
| 224 | 232 | { |
| 225 | 233 | case 0: |
| 226 | | rtc.systime.sec_1 = data & 0x0f; |
| 234 | rtc->systime.sec_1 = data & 0x0f; |
| 227 | 235 | break; |
| 228 | 236 | case 1: |
| 229 | | rtc.systime.sec_10 = data & 0x0f; |
| 237 | rtc->systime.sec_10 = data & 0x0f; |
| 230 | 238 | break; |
| 231 | 239 | case 2: |
| 232 | | rtc.systime.min_1 = data & 0x0f; |
| 240 | rtc->systime.min_1 = data & 0x0f; |
| 233 | 241 | break; |
| 234 | 242 | case 3: |
| 235 | | rtc.systime.min_10 = data & 0x0f; |
| 243 | rtc->systime.min_10 = data & 0x0f; |
| 236 | 244 | break; |
| 237 | 245 | case 4: |
| 238 | | rtc.systime.hour_1 = data & 0x0f; |
| 246 | rtc->systime.hour_1 = data & 0x0f; |
| 239 | 247 | break; |
| 240 | 248 | case 5: |
| 241 | | rtc.systime.hour_10 = data & 0x0f; |
| 249 | rtc->systime.hour_10 = data & 0x0f; |
| 242 | 250 | break; |
| 243 | 251 | case 6: |
| 244 | | rtc.systime.dayofweek = data & 0x0f; |
| 252 | rtc->systime.dayofweek = data & 0x0f; |
| 245 | 253 | break; |
| 246 | 254 | case 7: |
| 247 | | rtc.systime.day_1 = data & 0x0f; |
| 255 | rtc->systime.day_1 = data & 0x0f; |
| 248 | 256 | break; |
| 249 | 257 | case 8: |
| 250 | | rtc.systime.day_10 = data & 0x0f; |
| 258 | rtc->systime.day_10 = data & 0x0f; |
| 251 | 259 | break; |
| 252 | 260 | case 9: |
| 253 | | rtc.systime.month_1 = data & 0x0f; |
| 261 | rtc->systime.month_1 = data & 0x0f; |
| 254 | 262 | break; |
| 255 | 263 | case 10: |
| 256 | | rtc.systime.month_10 = data & 0x0f; |
| 264 | rtc->systime.month_10 = data & 0x0f; |
| 257 | 265 | break; |
| 258 | 266 | case 11: |
| 259 | | rtc.systime.year_1 = data & 0x0f; |
| 267 | rtc->systime.year_1 = data & 0x0f; |
| 260 | 268 | break; |
| 261 | 269 | case 12: |
| 262 | | rtc.systime.year_10 = data & 0x0f; |
| 270 | rtc->systime.year_10 = data & 0x0f; |
| 263 | 271 | break; |
| 264 | 272 | } |
| 265 | 273 | } |
| r4030 | r4031 | |
| 268 | 276 | switch(offset) |
| 269 | 277 | { |
| 270 | 278 | case 0: |
| 271 | | rtc.clkout = data & 0x07; |
| 279 | rtc->clkout = data & 0x07; |
| 272 | 280 | break; |
| 273 | 281 | case 1: // Adjustment (resets seconds to 0, increases minute by 1 if seconds are > 30 |
| 274 | | if(rtc.systime.sec_10 >= 3) |
| 275 | | rtc_add_minute(); |
| 276 | | rtc.systime.sec_1 = 0; |
| 277 | | rtc.systime.sec_10 = 0; |
| 282 | if(rtc->systime.sec_10 >= 3) |
| 283 | rtc_add_minute(device); |
| 284 | rtc->systime.sec_1 = 0; |
| 285 | rtc->systime.sec_10 = 0; |
| 278 | 286 | break; |
| 279 | 287 | case 2: |
| 280 | | rtc.alarm.min_1 = data & 0x0f; |
| 288 | rtc->alarm.min_1 = data & 0x0f; |
| 281 | 289 | break; |
| 282 | 290 | case 3: |
| 283 | | rtc.alarm.min_10 = data & 0x0f; |
| 291 | rtc->alarm.min_10 = data & 0x0f; |
| 284 | 292 | break; |
| 285 | 293 | case 4: |
| 286 | | rtc.alarm.hour_1 = data & 0x0f; |
| 294 | rtc->alarm.hour_1 = data & 0x0f; |
| 287 | 295 | break; |
| 288 | 296 | case 5: |
| 289 | | rtc.alarm.hour_10 = data & 0x0f; |
| 297 | rtc->alarm.hour_10 = data & 0x0f; |
| 290 | 298 | break; |
| 291 | 299 | case 6: |
| 292 | | rtc.alarm.dayofweek = data & 0x0f; |
| 300 | rtc->alarm.dayofweek = data & 0x0f; |
| 293 | 301 | break; |
| 294 | 302 | case 7: |
| 295 | | rtc.alarm.day_1 = data & 0x0f; |
| 303 | rtc->alarm.day_1 = data & 0x0f; |
| 296 | 304 | break; |
| 297 | 305 | case 8: |
| 298 | | rtc.alarm.day_10 = data & 0x0f; |
| 306 | rtc->alarm.day_10 = data & 0x0f; |
| 299 | 307 | break; |
| 300 | 308 | case 10: // 12/24 hour clock selection |
| 301 | | rtc.hour24 = data; |
| 309 | rtc->hour24 = data; |
| 302 | 310 | break; |
| 303 | 311 | |
| 304 | 312 | } |
| 305 | 313 | } |
| 306 | 314 | } |
| 307 | 315 | |
| 308 | | void rtc_add_second() // add one second to current time |
| 316 | void rtc_add_second(const device_config* device) // add one second to current time |
| 309 | 317 | { |
| 310 | | if((rtc.mode & 0x08) == 0x00) // if timer is not enabled |
| 318 | rp5c15_t* rtc = device->token; |
| 319 | |
| 320 | if((rtc->mode & 0x08) == 0x00) // if timer is not enabled |
| 311 | 321 | return; |
| 312 | | rtc.systime.sec_1++; |
| 313 | | if(rtc.systime.sec_1 < 10) |
| 322 | rtc->systime.sec_1++; |
| 323 | if(rtc->systime.sec_1 < 10) |
| 314 | 324 | return; |
| 315 | | rtc.systime.sec_1 = 0; |
| 316 | | rtc.systime.sec_10++; |
| 317 | | if(rtc.systime.sec_10 < 6) |
| 325 | rtc->systime.sec_1 = 0; |
| 326 | rtc->systime.sec_10++; |
| 327 | if(rtc->systime.sec_10 < 6) |
| 318 | 328 | return; |
| 319 | | rtc.systime.sec_10 = 0; |
| 320 | | rtc_add_minute(); |
| 329 | rtc->systime.sec_10 = 0; |
| 330 | rtc_add_minute(device); |
| 321 | 331 | } |
| 322 | 332 | |
| 323 | | void rtc_add_minute() |
| 333 | void rtc_add_minute(const device_config* device) |
| 324 | 334 | { |
| 325 | | rtc.systime.min_1++; |
| 326 | | if(rtc.systime.min_1 < 10) |
| 335 | rp5c15_t* rtc = device->token; |
| 336 | |
| 337 | rtc->systime.min_1++; |
| 338 | if(rtc->systime.min_1 < 10) |
| 327 | 339 | return; |
| 328 | | rtc.systime.min_1 = 0; |
| 329 | | rtc.systime.min_10++; |
| 330 | | if(rtc.systime.min_10 < 6) |
| 340 | rtc->systime.min_1 = 0; |
| 341 | rtc->systime.min_10++; |
| 342 | if(rtc->systime.min_10 < 6) |
| 331 | 343 | return; |
| 332 | | rtc.systime.min_10 = 0; |
| 333 | | rtc.systime.hour_1++; |
| 334 | | if(rtc.systime.hour_1 < 10 && rtc.systime.hour_10 < 2) |
| 344 | rtc->systime.min_10 = 0; |
| 345 | rtc->systime.hour_1++; |
| 346 | if(rtc->systime.hour_1 < 10 && rtc->systime.hour_10 < 2) |
| 335 | 347 | return; |
| 336 | | if(rtc.systime.hour_10 < 3 && rtc.systime.hour_1 < 4) |
| 348 | if(rtc->systime.hour_10 < 3 && rtc->systime.hour_1 < 4) |
| 337 | 349 | return; |
| 338 | | rtc.systime.hour_1 = 0; |
| 339 | | rtc.systime.hour_10++; |
| 340 | | if(rtc.systime.hour_10 < 3) |
| 350 | rtc->systime.hour_1 = 0; |
| 351 | rtc->systime.hour_10++; |
| 352 | if(rtc->systime.hour_10 < 3) |
| 341 | 353 | return; |
| 342 | | rtc.systime.hour_10 = 0; |
| 343 | | rtc_add_day(); |
| 354 | rtc->systime.hour_10 = 0; |
| 355 | rtc_add_day(device); |
| 344 | 356 | } |
| 345 | 357 | |
| 346 | | void rtc_add_day() |
| 358 | void rtc_add_day(const device_config* device) |
| 347 | 359 | { |
| 360 | rp5c15_t* rtc = device->token; |
| 348 | 361 | int d,m; |
| 349 | 362 | |
| 350 | | rtc.systime.dayofweek++; |
| 351 | | if(rtc.systime.dayofweek >= 7) |
| 352 | | rtc.systime.dayofweek = 0; |
| 353 | | d = (rtc.systime.day_10 << 4) | rtc.systime.day_1; |
| 354 | | m = (rtc.systime.month_10 << 4) | rtc.systime.month_1; |
| 363 | rtc->systime.dayofweek++; |
| 364 | if(rtc->systime.dayofweek >= 7) |
| 365 | rtc->systime.dayofweek = 0; |
| 366 | d = (rtc->systime.day_10 << 4) | rtc->systime.day_1; |
| 367 | m = (rtc->systime.month_10 << 4) | rtc->systime.month_1; |
| 355 | 368 | d++; |
| 356 | 369 | if((d & 0x0f) >= 10) |
| 357 | 370 | { |
| 358 | 371 | d &= 0xf0; |
| 359 | 372 | d += 0x10; |
| 360 | 373 | } |
| 361 | | rtc.systime.day_1 = (d & 0x0f); |
| 362 | | rtc.systime.day_10 = (d & 0xf0) >> 4; |
| 374 | rtc->systime.day_1 = (d & 0x0f); |
| 375 | rtc->systime.day_10 = (d & 0xf0) >> 4; |
| 363 | 376 | switch(m) |
| 364 | 377 | { |
| 365 | 378 | case 1: |
| r4030 | r4031 | |
| 371 | 384 | case 0x12: |
| 372 | 385 | if(d > 0x31) |
| 373 | 386 | { |
| 374 | | rtc.systime.day_1 = 1; |
| 375 | | rtc.systime.day_10 = 0; |
| 376 | | rtc_add_month(); |
| 387 | rtc->systime.day_1 = 1; |
| 388 | rtc->systime.day_10 = 0; |
| 389 | rtc_add_month(device); |
| 377 | 390 | } |
| 378 | 391 | break; |
| 379 | 392 | case 4: |
| r4030 | r4031 | |
| 382 | 395 | case 11: |
| 383 | 396 | if(d > 0x30) |
| 384 | 397 | { |
| 385 | | rtc.systime.day_1 = 1; |
| 386 | | rtc.systime.day_10 = 0; |
| 387 | | rtc_add_month(); |
| 398 | rtc->systime.day_1 = 1; |
| 399 | rtc->systime.day_10 = 0; |
| 400 | rtc_add_month(device); |
| 388 | 401 | } |
| 389 | 402 | break; |
| 390 | 403 | case 2: |
| 391 | | if(rtc.leap == 0) // this is a leap year |
| 404 | if(rtc->leap == 0) // this is a leap year |
| 392 | 405 | { |
| 393 | 406 | if(d > 0x29) |
| 394 | 407 | { |
| 395 | | rtc.systime.day_1 = 1; |
| 396 | | rtc.systime.day_10 = 0; |
| 397 | | rtc_add_month(); |
| 408 | rtc->systime.day_1 = 1; |
| 409 | rtc->systime.day_10 = 0; |
| 410 | rtc_add_month(device); |
| 398 | 411 | } |
| 399 | 412 | } |
| 400 | 413 | else // not a leap year |
| 401 | 414 | { |
| 402 | 415 | if(d > 0x28) |
| 403 | 416 | { |
| 404 | | rtc.systime.day_1 = 1; |
| 405 | | rtc.systime.day_10 = 0; |
| 406 | | rtc_add_month(); |
| 417 | rtc->systime.day_1 = 1; |
| 418 | rtc->systime.day_10 = 0; |
| 419 | rtc_add_month(device); |
| 407 | 420 | } |
| 408 | 421 | } |
| 409 | 422 | break; |
| 410 | 423 | } |
| 411 | 424 | } |
| 412 | 425 | |
| 413 | | void rtc_add_month() |
| 426 | void rtc_add_month(const device_config* device) |
| 414 | 427 | { |
| 415 | | rtc.systime.month_1++; |
| 416 | | if(rtc.systime.month_1 < 10 && rtc.systime.month_10 < 1) |
| 428 | rp5c15_t* rtc = device->token; |
| 429 | |
| 430 | rtc->systime.month_1++; |
| 431 | if(rtc->systime.month_1 < 10 && rtc->systime.month_10 < 1) |
| 417 | 432 | return; |
| 418 | | if(rtc.systime.month_1 < 3 && rtc.systime.month_10 < 2) |
| 433 | if(rtc->systime.month_1 < 3 && rtc->systime.month_10 < 2) |
| 419 | 434 | return; |
| 420 | | rtc.systime.month_1 = 0; |
| 421 | | rtc.systime.month_10++; |
| 422 | | if(rtc.systime.month_10 < 2) |
| 435 | rtc->systime.month_1 = 0; |
| 436 | rtc->systime.month_10++; |
| 437 | if(rtc->systime.month_10 < 2) |
| 423 | 438 | return; |
| 424 | | rtc.systime.month_1 = 1; |
| 425 | | rtc.systime.month_10 = 0; |
| 426 | | rtc.systime.year_1++; |
| 427 | | if(rtc.systime.year_1 < 10) |
| 439 | rtc->systime.month_1 = 1; |
| 440 | rtc->systime.month_10 = 0; |
| 441 | rtc->systime.year_1++; |
| 442 | if(rtc->systime.year_1 < 10) |
| 428 | 443 | return; |
| 429 | | rtc.systime.year_1 = 0; |
| 430 | | rtc.systime.year_10++; |
| 431 | | if(rtc.systime.year_10 < 10) |
| 444 | rtc->systime.year_1 = 0; |
| 445 | rtc->systime.year_10++; |
| 446 | if(rtc->systime.year_10 < 10) |
| 432 | 447 | return; |
| 433 | | rtc.systime.year_10 = 0; |
| 448 | rtc->systime.year_10 = 0; |
| 434 | 449 | } |
| 435 | 450 | |
| 436 | | READ16_HANDLER(rp5c15_r) { return rp5c15_read(offset,mem_mask); } |
| 437 | | WRITE16_HANDLER(rp5c15_w) { rp5c15_write(offset,data,mem_mask); } |
| 451 | static DEVICE_SET_INFO( rp5c15 ) |
| 452 | { |
| 453 | switch (state) |
| 454 | { |
| 455 | /* no parameters to set */ |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | DEVICE_GET_INFO( rp5c15 ) |
| 460 | { |
| 461 | switch (state) |
| 462 | { |
| 463 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 464 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_OTHER; break; |
| 465 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(rp5c15_t); break; |
| 466 | |
| 467 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 468 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(rp5c15); break; |
| 469 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(rp5c15); break; |
| 470 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 471 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 472 | |
| 473 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 474 | case DEVINFO_STR_NAME: strcpy(info->s, "Ricoh RP5C15"); break; |
| 475 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Real Time Clock"); break; |
| 476 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 477 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 478 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | READ16_DEVICE_HANDLER(rp5c15_r) { return rp5c15_read(device,offset,mem_mask); } |
| 483 | WRITE16_DEVICE_HANDLER(rp5c15_w) { rp5c15_write(device,offset,data,mem_mask); } |
src/mess/drivers/atarist.c
| r4030 | r4031 | |
| 880 | 880 | AM_RANGE(0xfffc02, 0xfffc03) AM_DEVREADWRITE8(ACIA6850, "acia_0", acia6850_data_r, acia6850_data_w, 0xff00) |
| 881 | 881 | AM_RANGE(0xfffc04, 0xfffc05) AM_DEVREADWRITE8(ACIA6850, "acia_1", acia6850_stat_r, acia6850_ctrl_w, 0xff00) |
| 882 | 882 | AM_RANGE(0xfffc06, 0xfffc07) AM_DEVREADWRITE8(ACIA6850, "acia_1", acia6850_data_r, acia6850_data_w, 0xff00) |
| 883 | | AM_RANGE(0xfffc20, 0xfffc3f) AM_READWRITE(rp5c15_r, rp5c15_w) |
| 883 | AM_RANGE(0xfffc20, 0xfffc3f) AM_DEVREADWRITE(RP5C15, "rp5c15", rp5c15_r, rp5c15_w) |
| 884 | 884 | ADDRESS_MAP_END |
| 885 | 885 | |
| 886 | 886 | static ADDRESS_MAP_START( ste_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r4030 | r4031 | |
| 986 | 986 | AM_RANGE(0xfffc02, 0xfffc03) AM_DEVREADWRITE8(ACIA6850, "acia_0", acia6850_data_r, acia6850_data_w, 0xff00) |
| 987 | 987 | AM_RANGE(0xfffc04, 0xfffc05) AM_DEVREADWRITE8(ACIA6850, "acia_1", acia6850_stat_r, acia6850_ctrl_w, 0xff00) |
| 988 | 988 | AM_RANGE(0xfffc06, 0xfffc07) AM_DEVREADWRITE8(ACIA6850, "acia_1", acia6850_data_r, acia6850_data_w, 0xff00) |
| 989 | | AM_RANGE(0xfffc20, 0xfffc3f) AM_READWRITE(rp5c15_r, rp5c15_w) |
| 989 | AM_RANGE(0xfffc20, 0xfffc3f) AM_DEVREADWRITE(RP5C15, "rp5c15", rp5c15_r, rp5c15_w) |
| 990 | 990 | ADDRESS_MAP_END |
| 991 | 991 | |
| 992 | 992 | static ADDRESS_MAP_START( stbook_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r4030 | r4031 | |
| 1519 | 1519 | static MACHINE_START( megast ) |
| 1520 | 1520 | { |
| 1521 | 1521 | MACHINE_START_CALL(atarist); |
| 1522 | | |
| 1523 | | rp5c15_init(machine, &rtc_intf); |
| 1524 | 1522 | } |
| 1525 | 1523 | |
| 1526 | 1524 | static MC68901_GPIO_READ( atariste_mfp_gpio_r ) |
| r4030 | r4031 | |
| 1617 | 1615 | |
| 1618 | 1616 | MACHINE_START_CALL(atariste); |
| 1619 | 1617 | |
| 1620 | | rp5c15_init(machine, &rtc_intf); |
| 1621 | | |
| 1622 | 1618 | state_save_register_global(machine, state->megaste_cache); |
| 1623 | 1619 | } |
| 1624 | 1620 | |
| r4030 | r4031 | |
| 1749 | 1745 | |
| 1750 | 1746 | /* configure devices */ |
| 1751 | 1747 | centronics_config(machine, 0, atarist_centronics_config); |
| 1752 | | rp5c15_init(machine, &rtc_intf); |
| 1753 | 1748 | |
| 1754 | 1749 | /* set CPU interrupt callback */ |
| 1755 | 1750 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| r4030 | r4031 | |
| 1838 | 1833 | |
| 1839 | 1834 | MDRV_CPU_MODIFY("main") |
| 1840 | 1835 | MDRV_CPU_PROGRAM_MAP(megast_map, 0) |
| 1836 | MDRV_RP5C15_ADD("rp5c15",rtc_intf) |
| 1841 | 1837 | |
| 1842 | 1838 | MDRV_MACHINE_START(megast) |
| 1843 | 1839 | MACHINE_DRIVER_END |
| r4030 | r4031 | |
| 1899 | 1895 | |
| 1900 | 1896 | MDRV_CPU_MODIFY("main") |
| 1901 | 1897 | MDRV_CPU_PROGRAM_MAP(megaste_map, 0) |
| 1898 | MDRV_RP5C15_ADD("rp5c15",rtc_intf) |
| 1902 | 1899 | |
| 1903 | 1900 | MDRV_MACHINE_START(megaste) |
| 1904 | 1901 | MACHINE_DRIVER_END |
| r4030 | r4031 | |
| 1909 | 1906 | // basic machine hardware |
| 1910 | 1907 | MDRV_CPU_ADD("main", M68000, U517/2) |
| 1911 | 1908 | MDRV_CPU_PROGRAM_MAP(stbook_map, 0) |
| 1909 | MDRV_RP5C15_ADD("rp5c15",rtc_intf) |
| 1912 | 1910 | |
| 1913 | 1911 | //MDRV_CPU_ADD("cop888", COP888, Y700) |
| 1914 | 1912 | |