src/emu/machine/msm6242.c
| r2197 | r2198 | |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | | #include "deprecat.h" |
| 9 | 8 | #include "machine/msm6242.h" |
| 10 | 9 | |
| 10 | |
| 11 | 11 | static UINT8 msm6264_reg[3] = { 0, 0, 0 }; |
| 12 | 12 | static mame_system_time msm6264_hold_time = { 0 }; |
| 13 | 13 | |
| 14 | /* temporary buffer to hold values written to the device */ |
| 15 | static UINT8 time_buffer[13]; |
| 16 | |
| 17 | /* TRUE if the time was just written */ |
| 18 | static int time_just_written = FALSE; |
| 19 | |
| 20 | |
| 14 | 21 | enum |
| 15 | 22 | { |
| 16 | 23 | MSM6264_REG_S1 = 0, |
| r2197 | r2198 | |
| 31 | 38 | MSM6264_REG_CF |
| 32 | 39 | }; |
| 33 | 40 | |
| 41 | |
| 42 | static TIMER_CALLBACK( reset_time ) |
| 43 | { |
| 44 | time_just_written = FALSE; |
| 45 | } |
| 46 | |
| 47 | |
| 34 | 48 | READ8_HANDLER( msm6242_r ) |
| 35 | 49 | { |
| 36 | 50 | mame_system_time curtime, *systime = &curtime; |
| 37 | 51 | |
| 52 | /* return the buffered time if it has recently been written */ |
| 53 | if (time_just_written && offset < MSM6264_REG_CD) |
| 54 | { |
| 55 | return time_buffer[offset]; |
| 56 | } |
| 57 | |
| 38 | 58 | if ( msm6264_reg[0] & 1 ) /* if HOLD is set, use the hold time */ |
| 39 | 59 | { |
| 40 | 60 | systime = &msm6264_hold_time; |
| 41 | 61 | } |
| 42 | 62 | else /* otherwise, use the current time */ |
| 43 | 63 | { |
| 44 | | mame_get_current_datetime(Machine, &curtime); |
| 64 | mame_get_current_datetime(machine, &curtime); |
| 45 | 65 | } |
| 46 | 66 | |
| 47 | 67 | switch(offset) |
| r2197 | r2198 | |
| 90 | 110 | return 0; |
| 91 | 111 | } |
| 92 | 112 | |
| 113 | |
| 93 | 114 | WRITE8_HANDLER( msm6242_w ) |
| 94 | 115 | { |
| 116 | /* mark as just written and start a timer to reset it again */ |
| 117 | if (offset < MSM6264_REG_CD) |
| 118 | { |
| 119 | time_buffer[offset] = data; |
| 120 | time_just_written = TRUE; |
| 121 | timer_set(ATTOTIME_IN_MSEC(500), NULL, 0, reset_time); |
| 122 | return; |
| 123 | } |
| 124 | |
| 95 | 125 | switch(offset) |
| 96 | 126 | { |
| 97 | 127 | case MSM6264_REG_CD: |
| r2197 | r2198 | |
| 100 | 130 | |
| 101 | 131 | if ( data & 1 ) /* was Hold set? */ |
| 102 | 132 | { |
| 103 | | mame_get_current_datetime(Machine, &msm6264_hold_time); |
| 133 | mame_get_current_datetime(machine, &msm6264_hold_time); |
| 104 | 134 | } |
| 105 | 135 | |
| 106 | 136 | return; |
| r2197 | r2198 | |
| 133 | 163 | return msm6242_r(machine, offset); |
| 134 | 164 | } |
| 135 | 165 | |
| 166 | |
| 136 | 167 | WRITE16_HANDLER( msm6242_lsb_w ) |
| 137 | 168 | { |
| 138 | 169 | if (ACCESSING_LSB) |
src/mess/machine/coupe.c
| r2197 | r2198 | |
| 11 | 11 | #include "includes/coupe.h" |
| 12 | 12 | #include "devices/basicdsk.h" |
| 13 | 13 | #include "machine/wd17xx.h" |
| 14 | #include "machine/msm6242.h" |
| 14 | 15 | |
| 15 | 16 | |
| 16 | 17 | #define LMPR_RAM0 0x20 /* If bit set ram is paged into bank 0, else its rom0 */ |
| r2197 | r2198 | |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | |
| 117 | static READ8_HANDLER( coupe_rtc_r ) |
| 118 | { |
| 119 | return msm6242_r(machine, offset >> 12); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | static WRITE8_HANDLER( coupe_rtc_w ) |
| 124 | { |
| 125 | msm6242_w(machine, offset >> 12, data); |
| 126 | } |
| 127 | |
| 128 | |
| 116 | 129 | MACHINE_RESET( coupe ) |
| 117 | 130 | { |
| 118 | 131 | memset(&coupe_regs, 0, sizeof(coupe_regs)); |
| r2197 | r2198 | |
| 123 | 136 | coupe_regs.line_int = 0xff; /* line interrupts disabled */ |
| 124 | 137 | coupe_regs.status = 0x1f; /* no interrupts active */ |
| 125 | 138 | |
| 139 | if (readinputportbytag("config") & 0x01) |
| 140 | { |
| 141 | /* install RTC */ |
| 142 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, coupe_rtc_r, coupe_rtc_w); |
| 143 | } |
| 144 | else |
| 145 | { |
| 146 | /* no RTC support */ |
| 147 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, SMH_UNMAP, SMH_UNMAP); |
| 148 | } |
| 149 | |
| 126 | 150 | coupe_update_memory(); |
| 127 | 151 | } |
| 128 | 152 | |
| 129 | 153 | |
| 130 | | MACHINE_START( coupe ) |
| 154 | DRIVER_INIT( coupe ) |
| 131 | 155 | { |
| 132 | 156 | wd17xx_init(machine, WD_TYPE_1772, NULL, NULL); |
| 133 | 157 | } |
src/mess/drivers/coupe.c
| r2197 | r2198 | |
| 430 | 430 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DOWN") PORT_CODE(KEYCODE_DOWN) |
| 431 | 431 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEFT") PORT_CODE(KEYCODE_LEFT) |
| 432 | 432 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RIGHT") PORT_CODE(KEYCODE_RIGHT) |
| 433 | |
| 434 | PORT_START_TAG("config") |
| 435 | PORT_CONFNAME(0x01, 0x00, "Real Time Clock") |
| 436 | PORT_CONFSETTING( 0x00, DEF_STR(None)) |
| 437 | PORT_CONFSETTING( 0x01, "SAMBUS") |
| 433 | 438 | INPUT_PORTS_END |
| 434 | 439 | |
| 435 | 440 | |
| r2197 | r2198 | |
| 495 | 500 | MDRV_CPU_IO_MAP(coupe_io, 0) |
| 496 | 501 | MDRV_CPU_VBLANK_INT("main", coupe_frame_interrupt) |
| 497 | 502 | |
| 498 | | MDRV_MACHINE_START(coupe) |
| 499 | 503 | MDRV_MACHINE_RESET(coupe) |
| 500 | 504 | |
| 501 | 505 | /* video hardware */ |
| r2197 | r2198 | |
| 603 | 607 | * |
| 604 | 608 | *************************************/ |
| 605 | 609 | |
| 606 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 607 | | COMP( 1989, coupe, 0, 0, coupe, coupe, 0, coupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |
| 610 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 611 | COMP( 1989, coupe, 0, 0, coupe, coupe, coupe, coupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |