src/mess/machine/cdp1871.c
| r0 | r2589 | |
| 1 | /**********************************************************************
|
| 2 | |
| 3 | RCA CDP1871 Keyboard Encoder emulation
|
| 4 | |
| 5 | Copyright MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | **********************************************************************/
|
| 9 | |
| 10 | #include "driver.h"
|
| 11 | #include "cdp1871.h"
|
| 12 | |
| 13 | static const UINT8 CDP1871_KEY_CODES[4][11][8] =
|
| 14 | {
|
| 15 | // normal
|
| 16 | {
|
| 17 | { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 },
|
| 18 | { 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f },
|
| 19 | { 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 },
|
| 20 | { 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f },
|
| 21 | { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 },
|
| 22 | { 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f },
|
| 23 | { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
|
| 24 | { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
| 25 | { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
|
| 26 | { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
|
| 27 | { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
|
| 28 | },
|
| 29 | |
| 30 | // alpha
|
| 31 | {
|
| 32 | { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 },
|
| 33 | { 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f },
|
| 34 | { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 },
|
| 35 | { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f },
|
| 36 | { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 },
|
| 37 | { 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f },
|
| 38 | { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
|
| 39 | { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
| 40 | { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
|
| 41 | { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
|
| 42 | { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
|
| 43 | },
|
| 44 | |
| 45 | // shift
|
| 46 | {
|
| 47 | { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 },
|
| 48 | { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f },
|
| 49 | { 0x61, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 },
|
| 50 | { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f },
|
| 51 | { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 },
|
| 52 | { 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f },
|
| 53 | { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
|
| 54 | { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
| 55 | { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
|
| 56 | { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
|
| 57 | { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
|
| 58 | },
|
| 59 | |
| 60 | // control
|
| 61 | {
|
| 62 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
| 63 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
| 64 | { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
|
| 65 | { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
| 66 | { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
|
| 67 | { 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
| 68 | { 0x20, 0xff, 0x0a, 0x1b, 0xff, 0x0d, 0xff, 0x7f },
|
| 69 | { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
| 70 | { 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f },
|
| 71 | { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
|
| 72 | { 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f }
|
| 73 | }
|
| 74 | };
|
| 75 | |
| 76 | typedef struct _cdp1871_t cdp1871_t;
|
| 77 | struct _cdp1871_t
|
| 78 | {
|
| 79 | const cdp1871_interface *intf;
|
| 80 | |
| 81 | int inhibit; /* scan counter clock inhibit */
|
| 82 | int sense; /* sense input scan counter */
|
| 83 | int drive; /* drive output scan counter */
|
| 84 | int modifiers; /* modifier inputs */
|
| 85 |
|
| 86 | int da; /* data available flag */
|
| 87 | int next_da; /* next value of data available flag */
|
| 88 | int rpt; /* repeat flag */
|
| 89 | int next_rpt; /* next value of repeat flag */
|
| 90 | |
| 91 | /* timers */
|
| 92 | emu_timer *scan_timer; /* keyboard scan timer */
|
| 93 | };
|
| 94 | |
| 95 | INLINE cdp1871_t *get_safe_token(const device_config *device)
|
| 96 | {
|
| 97 | assert(device != NULL);
|
| 98 | assert(device->token != NULL);
|
| 99 | |
| 100 | return (cdp1871_t *)device->token;
|
| 101 | }
|
| 102 | |
| 103 | static void change_output_lines(const device_config *device)
|
| 104 | {
|
| 105 | cdp1871_t *cdp1871 = get_safe_token(device);
|
| 106 | |
| 107 | if (cdp1871->next_da != cdp1871->da)
|
| 108 | {
|
| 109 | cdp1871->da = cdp1871->next_da;
|
| 110 | |
| 111 | cdp1871->intf->on_da_changed(device, cdp1871->da);
|
| 112 | }
|
| 113 | |
| 114 | if (cdp1871->next_rpt != cdp1871->rpt)
|
| 115 | {
|
| 116 | cdp1871->rpt = cdp1871->next_rpt;
|
| 117 | |
| 118 | cdp1871->intf->on_rpt_changed(device, cdp1871->rpt);
|
| 119 | }
|
| 120 | }
|
| 121 | |
| 122 | static void clock_scan_counters(const device_config *device)
|
| 123 | {
|
| 124 | cdp1871_t *cdp1871 = get_safe_token(device);
|
| 125 | |
| 126 | if (!cdp1871->inhibit)
|
| 127 | {
|
| 128 | cdp1871->sense++;
|
| 129 | |
| 130 | if (cdp1871->sense == 8)
|
| 131 | {
|
| 132 | cdp1871->sense = 0;
|
| 133 | cdp1871->drive++;
|
| 134 | |
| 135 | if (cdp1871->drive == 11)
|
| 136 | {
|
| 137 | cdp1871->drive = 0;
|
| 138 | }
|
| 139 | }
|
| 140 | }
|
| 141 | }
|
| 142 | |
| 143 | static void detect_keypress(const device_config *device)
|
| 144 | {
|
| 145 | cdp1871_t *cdp1871 = get_safe_token(device);
|
| 146 | char port[3];
|
| 147 | |
| 148 | sprintf(port, "D%d", cdp1871->drive + 1);
|
| 149 |
|
| 150 | if (input_port_read(device->machine, port) == (1 << cdp1871->sense))
|
| 151 | {
|
| 152 | if (!cdp1871->inhibit)
|
| 153 | {
|
| 154 | cdp1871->modifiers = input_port_read(device->machine, "MODIFIERS");
|
| 155 | |
| 156 | cdp1871->inhibit = 1;
|
| 157 | cdp1871->next_da = 0;
|
| 158 | }
|
| 159 | else
|
| 160 | {
|
| 161 | cdp1871->next_rpt = 0;
|
| 162 | }
|
| 163 | }
|
| 164 | else
|
| 165 | {
|
| 166 | cdp1871->inhibit = 0;
|
| 167 | cdp1871->next_rpt = 1;
|
| 168 | }
|
| 169 | }
|
| 170 | |
| 171 | static TIMER_CALLBACK( cdp1871_scan_tick )
|
| 172 | {
|
| 173 | const device_config *device = ptr;
|
| 174 | |
| 175 | change_output_lines(device);
|
| 176 | clock_scan_counters(device);
|
| 177 | detect_keypress(device);
|
| 178 | }
|
| 179 | |
| 180 | /* Keyboard Data */
|
| 181 | |
| 182 | READ8_DEVICE_HANDLER( cdp1871_data_r )
|
| 183 | {
|
| 184 | cdp1871_t *cdp1871 = get_safe_token(device);
|
| 185 | |
| 186 | int shift = BIT(cdp1871->modifiers, 0);
|
| 187 | int control = BIT(cdp1871->modifiers, 1);
|
| 188 | int alpha = BIT(cdp1871->modifiers, 2);
|
| 189 | int table = 0;
|
| 190 | |
| 191 | if (control) table = 3; else if (shift) table = 2; else if (alpha) table = 1;
|
| 192 | |
| 193 | // reset DA on next TPB
|
| 194 | |
| 195 | cdp1871->next_da = 1;
|
| 196 | |
| 197 | return CDP1871_KEY_CODES[table][cdp1871->drive][cdp1871->sense];
|
| 198 | }
|
| 199 | |
| 200 | /* Input Ports */
|
| 201 | |
| 202 | INPUT_PORTS_START( cdp1871 )
|
| 203 | PORT_START_TAG("D1")
|
| 204 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(' ')
|
| 205 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
| 206 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
|
| 207 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
|
| 208 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
| 209 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
| 210 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
|
| 211 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('´')
|
| 212 | |
| 213 | PORT_START_TAG("D2")
|
| 214 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
|
| 215 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
|
| 216 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('*')
|
| 217 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR(';') PORT_CHAR('+')
|
| 218 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
|
| 219 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
|
| 220 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
|
| 221 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
|
| 222 | |
| 223 | PORT_START_TAG("D3")
|
| 224 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('@') PORT_CHAR('\'')
|
| 225 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
|
| 226 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
|
| 227 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
|
| 228 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
|
| 229 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
|
| 230 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
|
| 231 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
|
| 232 | |
| 233 | PORT_START_TAG("D4")
|
| 234 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
|
| 235 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
|
| 236 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
|
| 237 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
|
| 238 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
|
| 239 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
|
| 240 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
|
| 241 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
|
| 242 | |
| 243 | PORT_START_TAG("D5")
|
| 244 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
|
| 245 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
|
| 246 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
|
| 247 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
|
| 248 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
|
| 249 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
|
| 250 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
|
| 251 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
|
| 252 | |
| 253 | PORT_START_TAG("D6")
|
| 254 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
|
| 255 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
|
| 256 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
|
| 257 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
|
| 258 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
|
| 259 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
|
| 260 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~')
|
| 261 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("- Delete") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('_')
|
| 262 | |
| 263 | PORT_START_TAG("D7")
|
| 264 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
| 265 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 266 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Line Feed") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_CHAR(10)
|
| 267 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Escape") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
|
| 268 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 269 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Carriage Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
|
| 270 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 271 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Delete") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
|
| 272 | |
| 273 | PORT_START_TAG("D8")
|
| 274 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 275 | |
| 276 | PORT_START_TAG("D9")
|
| 277 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 278 | |
| 279 | PORT_START_TAG("D10")
|
| 280 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 281 | |
| 282 | PORT_START_TAG("D11")
|
| 283 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_KEYBOARD )
|
| 284 | |
| 285 | PORT_START_TAG("MODIFIERS")
|
| 286 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
| 287 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
|
| 288 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Alpha Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
|
| 289 | INPUT_PORTS_END
|
| 290 | |
| 291 | /* Device Interface */
|
| 292 | |
| 293 | static DEVICE_START( cdp1871 )
|
| 294 | {
|
| 295 | cdp1871_t *cdp1871 = get_safe_token(device);
|
| 296 | char unique_tag[30];
|
| 297 | |
| 298 | /* validate arguments */
|
| 299 | assert(device != NULL);
|
| 300 | assert(device->tag != NULL);
|
| 301 | assert(strlen(device->tag) < 20);
|
| 302 | |
| 303 | cdp1871->intf = device->static_config;
|
| 304 | |
| 305 | assert(cdp1871->intf != NULL);
|
| 306 | assert(cdp1871->intf->clock > 0);
|
| 307 | |
| 308 | /* create the timers */
|
| 309 | cdp1871->scan_timer = timer_alloc(cdp1871_scan_tick, (void *)device);
|
| 310 | timer_adjust_periodic(cdp1871->scan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(cdp1871->intf->clock));
|
| 311 | |
| 312 | /* register for state saving */
|
| 313 | state_save_combine_module_and_tag(unique_tag, "CDP1871", device->tag);
|
| 314 | |
| 315 | state_save_register_item(unique_tag, 0, cdp1871->inhibit);
|
| 316 | state_save_register_item(unique_tag, 0, cdp1871->sense);
|
| 317 | state_save_register_item(unique_tag, 0, cdp1871->drive);
|
| 318 | state_save_register_item(unique_tag, 0, cdp1871->modifiers);
|
| 319 | |
| 320 | state_save_register_item(unique_tag, 0, cdp1871->da);
|
| 321 | state_save_register_item(unique_tag, 0, cdp1871->next_da);
|
| 322 | state_save_register_item(unique_tag, 0, cdp1871->rpt);
|
| 323 | state_save_register_item(unique_tag, 0, cdp1871->next_rpt);
|
| 324 | }
|
| 325 | |
| 326 | static DEVICE_SET_INFO( cdp1871 )
|
| 327 | {
|
| 328 | switch (state)
|
| 329 | {
|
| 330 | /* no parameters to set */
|
| 331 | }
|
| 332 | }
|
| 333 | |
| 334 | DEVICE_GET_INFO( cdp1871 )
|
| 335 | {
|
| 336 | switch (state)
|
| 337 | {
|
| 338 | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 339 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1871_t); break;
|
| 340 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
|
| 341 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
|
| 342 | |
| 343 | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 344 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cdp1871); break;
|
| 345 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1871); break;
|
| 346 | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 347 | case DEVINFO_FCT_RESET: /* Nothing */ break;
|
| 348 | |
| 349 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 350 | case DEVINFO_STR_NAME: info->s = "RCA CDP1871"; break;
|
| 351 | case DEVINFO_STR_FAMILY: info->s = "RCA CDP1800"; break;
|
| 352 | case DEVINFO_STR_VERSION: info->s = "1.0"; break;
|
| 353 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break;
|
| 354 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break;
|
| 355 | }
|
| 356 | }
|
src/mess/drivers/comx35.c
| r0 | r2589 | |
| 1 | /*
|
| 2 | |
| 3 | TODO:
|
| 4 | |
| 5 | - fix keyboard
|
| 6 | - power on reset timeout?
|
| 7 | - reset on SPACE+RESET
|
| 8 | - DMA memory refresh
|
| 9 | - load .comx snapshots
|
| 10 |
|
| 11 | - tape
|
| 12 | - floppy
|
| 13 | - expansion box
|
| 14 | - expansion box w/F&M
|
| 15 | - 32K RAM card
|
| 16 | - F&M joy card
|
| 17 | - printer controller
|
| 18 | - printer controller w/F&M
|
| 19 | - F&M basic
|
| 20 | - PL-80 plotter
|
| 21 | - thermal printer
|
| 22 | - 80 column card with MC6845
|
| 23 | |
| 24 | */
|
| 25 | |
| 26 | #include "driver.h"
|
| 27 | #include "includes/comx35.h"
|
| 28 | #include "cpu/cdp1802/cdp1802.h"
|
| 29 | #include "devices/cassette.h"
|
| 30 | #include "machine/cdp1871.h"
|
| 31 | #include "video/cdp1869.h"
|
| 32 | |
| 33 | static const device_config *cassette_device_image(void)
|
| 34 | {
|
| 35 | return image_from_devtype_and_index(IO_CASSETTE, 0);
|
| 36 | }
|
| 37 | |
| 38 | /* Read/Write Handlers */
|
| 39 | |
| 40 | static WRITE8_HANDLER( bank_select_w )
|
| 41 | {
|
| 42 | memory_set_bank(1, data & 0x07);
|
| 43 | }
|
| 44 | |
| 45 | static WRITE8_HANDLER( system_io_w )
|
| 46 | {
|
| 47 | logerror("System IO %02x\n", data);
|
| 48 | }
|
| 49 | |
| 50 | /* Memory Maps */
|
| 51 | |
| 52 | static ADDRESS_MAP_START( comx35_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 53 | AM_RANGE(0x0000, 0x3fff) AM_ROM
|
| 54 | AM_RANGE(0x4000, 0xbfff) AM_RAM
|
| 55 | AM_RANGE(0xc000, 0xdfff) AM_RAMBANK(1)
|
| 56 | AM_RANGE(0xe000, 0xefff) AM_RAM
|
| 57 | AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
|
| 58 | AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
|
| 59 | ADDRESS_MAP_END
|
| 60 | |
| 61 | static ADDRESS_MAP_START( comx35_io_map, ADDRESS_SPACE_IO, 8 )
|
| 62 | AM_RANGE(0x01, 0x01) AM_WRITE(bank_select_w)
|
| 63 | AM_RANGE(0x02, 0x02) AM_WRITE(system_io_w)
|
| 64 | AM_RANGE(0x03, 0x03) AM_DEVREAD(CDP1871, CDP1871_TAG, cdp1871_data_r) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out3_w)
|
| 65 | AM_RANGE(0x04, 0x04) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out4_w)
|
| 66 | AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out5_w)
|
| 67 | AM_RANGE(0x06, 0x06) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out6_w)
|
| 68 | AM_RANGE(0x07, 0x07) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out7_w)
|
| 69 | ADDRESS_MAP_END
|
| 70 | |
| 71 | /* Input Ports */
|
| 72 | |
| 73 | static INPUT_PORTS_START( comx35 )
|
| 74 | PORT_START_TAG("D1")
|
| 75 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(' ')
|
| 76 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
| 77 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
|
| 78 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
|
| 79 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
| 80 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
| 81 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
|
| 82 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('´')
|
| 83 | |
| 84 | PORT_START_TAG("D2")
|
| 85 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('[')
|
| 86 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(']')
|
| 87 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR(':')
|
| 88 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR(';')
|
| 89 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('<') PORT_CHAR('(')
|
| 90 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('^')
|
| 91 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('>') PORT_CHAR(')')
|
| 92 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('_')
|
| 93 | |
| 94 | PORT_START_TAG("D3")
|
| 95 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('?') PORT_CHAR('@')
|
| 96 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
|
| 97 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
|
| 98 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
|
| 99 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
|
| 100 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
|
| 101 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
|
| 102 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
|
| 103 | |
| 104 | PORT_START_TAG("D4")
|
| 105 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
|
| 106 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
|
| 107 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
|
| 108 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
|
| 109 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
|
| 110 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
|
| 111 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
|
| 112 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
|
| 113 | |
| 114 | PORT_START_TAG("D5")
|
| 115 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
|
| 116 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
|
| 117 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
|
| 118 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
|
| 119 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
|
| 120 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
|
| 121 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
|
| 122 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
|
| 123 | |
| 124 | PORT_START_TAG("D6")
|
| 125 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
|
| 126 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
|
| 127 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
|
| 128 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR('+') PORT_CHAR('{')
|
| 129 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('-') PORT_CHAR('|')
|
| 130 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('*') PORT_CHAR('}')
|
| 131 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('/') PORT_CHAR('~')
|
| 132 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') PORT_CHAR(8)
|
| 133 | |
| 134 | PORT_START_TAG("D7")
|
| 135 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
|
| 136 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
|
| 137 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
|
| 138 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x92") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
|
| 139 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
|
| 140 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
|
| 141 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("DEL") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
|
| 142 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 143 | |
| 144 | PORT_START_TAG("D8")
|
| 145 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 146 | |
| 147 | PORT_START_TAG("D9")
|
| 148 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 149 | |
| 150 | PORT_START_TAG("D10")
|
| 151 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 152 | |
| 153 | PORT_START_TAG("D11")
|
| 154 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 155 | |
| 156 | PORT_START_TAG("MODIFIERS")
|
| 157 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
| 158 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
|
| 159 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 160 | |
| 161 | PORT_START_TAG("RESET")
|
| 162 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_NAME("RT") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
|
| 163 | INPUT_PORTS_END
|
| 164 | |
| 165 | /* CDP1802 Interface */
|
| 166 | |
| 167 | static TIMER_CALLBACK( dma_tick )
|
| 168 | {
|
| 169 | comx35_state *state = machine->driver_data;
|
| 170 | |
| 171 | if (!state->iden)
|
| 172 | {
|
| 173 | // cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, ASSERT_LINE);
|
| 174 | // cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE);
|
| 175 | }
|
| 176 | }
|
| 177 | |
| 178 | static CDP1802_MODE_READ( comx35_mode_r )
|
| 179 | {
|
| 180 | comx35_state *state = machine->driver_data;
|
| 181 | |
| 182 | return state->cdp1802_mode;
|
| 183 | }
|
| 184 | |
| 185 | static CDP1802_EF_READ( comx35_ef_r )
|
| 186 | {
|
| 187 | comx35_state *state = machine->driver_data;
|
| 188 | |
| 189 | int flags = 0x0f;
|
| 190 | |
| 191 | /*
|
| 192 | EF1 predis
|
| 193 | EF2 on power up: 1=PAL/0=NTSC, after toggle Q: _EFXB
|
| 194 | EF3 _EFXA
|
| 195 | EF4 cassette in (ear)
|
| 196 | */
|
| 197 | |
| 198 | if (!state->cdp1869_prd) flags -= EF1;
|
| 199 | |
| 200 | if (state->iden)
|
| 201 | {
|
| 202 | if (!state->pal_ntsc) flags -= EF2;
|
| 203 | }
|
| 204 | else
|
| 205 | {
|
| 206 | if (!state->cdp1871_efxb) flags -= EF2;
|
| 207 | }
|
| 208 | |
| 209 | if (!state->cdp1871_efxa) flags -= EF3;
|
| 210 | |
| 211 | if (cassette_input(cassette_device_image()) > +1.0) flags -= EF4;
|
| 212 | |
| 213 | return flags;
|
| 214 | }
|
| 215 | |
| 216 | static CDP1802_SC_WRITE( comx35_sc_w )
|
| 217 | {
|
| 218 | if (state == CDP1802_STATE_CODE_S3_INTERRUPT)
|
| 219 | {
|
| 220 | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
|
| 221 | }
|
| 222 | }
|
| 223 | |
| 224 | static CDP1802_Q_WRITE( comx35_q_w )
|
| 225 | {
|
| 226 | comx35_state *state = machine->driver_data;
|
| 227 | |
| 228 | if (state->iden && level)
|
| 229 | {
|
| 230 | state->iden = 0;
|
| 231 | }
|
| 232 | |
| 233 | cassette_output(cassette_device_image(), level ? -1.0 : +1.0);
|
| 234 | }
|
| 235 | |
| 236 | static const cdp1802_interface comx35_cdp1802_config =
|
| 237 | {
|
| 238 | comx35_mode_r,
|
| 239 | comx35_ef_r,
|
| 240 | comx35_sc_w,
|
| 241 | comx35_q_w,
|
| 242 | NULL,
|
| 243 | NULL
|
| 244 | };
|
| 245 | |
| 246 | /* CDP1871 Interface */
|
| 247 | |
| 248 | static CDP1871_ON_DA_CHANGED( comx35_da_w )
|
| 249 | {
|
| 250 | comx35_state *state = device->machine->driver_data;
|
| 251 | |
| 252 | state->cdp1871_efxa = level;
|
| 253 | }
|
| 254 | |
| 255 | static CDP1871_ON_DA_CHANGED( comx35_rpt_w )
|
| 256 | {
|
| 257 | comx35_state *state = device->machine->driver_data;
|
| 258 | |
| 259 | state->cdp1871_efxb = level;
|
| 260 | }
|
| 261 | |
| 262 | static CDP1871_INTERFACE( comx35n_cdp1871_intf )
|
| 263 | {
|
| 264 | CDP1869_CPU_CLK_PAL / 8,
|
| 265 | comx35_da_w,
|
| 266 | comx35_rpt_w
|
| 267 | };
|
| 268 | |
| 269 | static CDP1871_INTERFACE( comx35p_cdp1871_intf )
|
| 270 | {
|
| 271 | CDP1869_CPU_CLK_NTSC / 8,
|
| 272 | comx35_da_w,
|
| 273 | comx35_rpt_w
|
| 274 | };
|
| 275 | |
| 276 | /* Machine Initialization */
|
| 277 | |
| 278 | static TIMER_CALLBACK( reset_tick )
|
| 279 | {
|
| 280 | comx35_state *state = machine->driver_data;
|
| 281 | |
| 282 | state->cdp1802_mode = CDP1802_MODE_RUN;
|
| 283 | }
|
| 284 | |
| 285 | static MACHINE_START( comx35p )
|
| 286 | {
|
| 287 | comx35_state *state = machine->driver_data;
|
| 288 | |
| 289 | // RAM banking
|
| 290 | |
| 291 | memory_configure_bank(1, 0, 8, memory_region(REGION_USER1), 0x2000);
|
| 292 | memory_set_bank(1, 0);
|
| 293 | |
| 294 | // allocate DMA timer
|
| 295 | |
| 296 | state->dma_timer = timer_alloc(dma_tick, NULL);
|
| 297 | timer_adjust_periodic(state->dma_timer, attotime_zero, 0, ATTOTIME_IN_HZ(CDP1869_CPU_CLK_PAL / 8));
|
| 298 | |
| 299 | // allocate reset timer
|
| 300 |
|
| 301 | state->reset_timer = timer_alloc(reset_tick, NULL);
|
| 302 | |
| 303 | // screen format
|
| 304 | |
| 305 | state->pal_ntsc = CDP1869_PAL;
|
| 306 | }
|
| 307 | |
| 308 | static MACHINE_START( comx35n )
|
| 309 | {
|
| 310 | comx35_state *state = machine->driver_data;
|
| 311 | |
| 312 | MACHINE_START_CALL(comx35p);
|
| 313 | |
| 314 | timer_adjust_periodic(state->dma_timer, attotime_zero, 0, ATTOTIME_IN_HZ(CDP1869_CPU_CLK_NTSC / 8));
|
| 315 | |
| 316 | // screen format
|
| 317 | |
| 318 | state->pal_ntsc = CDP1869_NTSC;
|
| 319 | }
|
| 320 | |
| 321 | static MACHINE_RESET( comx35 )
|
| 322 | {
|
| 323 | comx35_state *state = machine->driver_data;
|
| 324 | |
| 325 | state->cdp1802_mode = CDP1802_MODE_RESET;
|
| 326 | state->iden = 1;
|
| 327 | |
| 328 | timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_MSEC(200), 0);
|
| 329 | }
|
| 330 | |
| 331 | /* Machine Drivers */
|
| 332 | |
| 333 | static MACHINE_DRIVER_START( comx35p )
|
| 334 | MDRV_DRIVER_DATA(comx35_state)
|
| 335 | |
| 336 | // basic system hardware
|
| 337 | |
| 338 | MDRV_CPU_ADD_TAG(CDP1802_TAG, CDP1802, CDP1869_CPU_CLK_PAL)
|
| 339 | MDRV_CPU_PROGRAM_MAP(comx35_map, 0)
|
| 340 | MDRV_CPU_IO_MAP(comx35_io_map, 0)
|
| 341 | MDRV_CPU_CONFIG(comx35_cdp1802_config)
|
| 342 | |
| 343 | MDRV_MACHINE_START(comx35p)
|
| 344 | MDRV_MACHINE_RESET(comx35)
|
| 345 | |
| 346 | // keyboard encoder
|
| 347 | |
| 348 | MDRV_DEVICE_ADD(CDP1871_TAG, CDP1871)
|
| 349 | MDRV_DEVICE_CONFIG(comx35p_cdp1871_intf)
|
| 350 |
|
| 351 | // video hardware
|
| 352 | |
| 353 | MDRV_IMPORT_FROM(comx35p_video)
|
| 354 | |
| 355 | // sound hardware
|
| 356 | |
| 357 | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 358 | |
| 359 | MDRV_SOUND_ADD(CDP1869, CDP1869_DOT_CLK_PAL)
|
| 360 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
| 361 | MACHINE_DRIVER_END
|
| 362 | |
| 363 | static MACHINE_DRIVER_START( comx35n )
|
| 364 | MDRV_DRIVER_DATA(comx35_state)
|
| 365 | |
| 366 | // basic system hardware
|
| 367 | |
| 368 | MDRV_CPU_ADD_TAG(CDP1802_TAG, CDP1802, CDP1869_CPU_CLK_NTSC)
|
| 369 | MDRV_CPU_PROGRAM_MAP(comx35_map, 0)
|
| 370 | MDRV_CPU_IO_MAP(comx35_io_map, 0)
|
| 371 | MDRV_CPU_CONFIG(comx35_cdp1802_config)
|
| 372 | |
| 373 | MDRV_MACHINE_START(comx35n)
|
| 374 | MDRV_MACHINE_RESET(comx35)
|
| 375 | |
| 376 | // keyboard encoder
|
| 377 | |
| 378 | MDRV_DEVICE_ADD(CDP1871_TAG, CDP1871)
|
| 379 | MDRV_DEVICE_CONFIG(comx35n_cdp1871_intf)
|
| 380 | |
| 381 | // video hardware
|
| 382 | |
| 383 | MDRV_IMPORT_FROM(comx35n_video)
|
| 384 | |
| 385 | // sound hardware
|
| 386 | |
| 387 | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 388 | |
| 389 | MDRV_SOUND_ADD(CDP1869, CDP1869_DOT_CLK_NTSC)
|
| 390 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
| 391 | MACHINE_DRIVER_END
|
| 392 | |
| 393 | /* ROMs */
|
| 394 | |
| 395 | ROM_START( comx35p )
|
| 396 | ROM_REGION( 0x10000, REGION_CPU1, 0 )
|
| 397 | ROM_SYSTEM_BIOS( 0, "basic100", "COMX BASIC V1.00" )
|
| 398 | ROMX_LOAD( "comx_10.u21", 0x0000, 0x4000, CRC(68d0db2d) SHA1(062328361629019ceed9375afac18e2b7849ce47), ROM_BIOS(1) )
|
| 399 | ROM_SYSTEM_BIOS( 1, "default", "COMX BASIC V1.01" )
|
| 400 | ROMX_LOAD( "comx_11.u21", 0x0000, 0x4000, CRC(609d89cd) SHA1(799646810510d8236fbfafaff7a73d5170990f16), ROM_BIOS(2) )
|
| 401 | |
| 402 | ROM_REGION( 0x2000, REGION_USER1, 0 )
|
| 403 | ROM_LOAD( "expansion.bin", 0x0000, 0x1000, CRC(52cb44e2) SHA1(3f9a3d9940b36d4fee5eca9f1359c99d7ed545b9) )
|
| 404 | ROM_LOAD( "f&m.expansion.3.1.bin", 0x0000, 0x1000, CRC(818ca2ef) SHA1(ea000097622e7fd472d53e7899e3c83773433045) )
|
| 405 | ROM_LOAD( "printer.bin", 0x0000, 0x0800, CRC(3bbc2b2e) SHA1(08bf7ea4174713ab24969c553affd5c1401876b8) )
|
| 406 | ROM_LOAD( "thermal.bin", 0x0000, 0x1000, CRC(41a72ba8) SHA1(3a8760c78bd8c7bec2dbf26657b930c9a6814803) )
|
| 407 | ROM_LOAD( "f&m.printer.1.2.bin", 0x0000, 0x1000, CRC(2feb997d) SHA1(ee9cb91042696c88ff5f2f44d2f702dc93369ba0) )
|
| 408 | ROM_LOAD( "fdc.bin", 0x0000, 0x2000, CRC(cf4ecd2e) SHA1(290e19bdc89e3c8059e63d5ae3cca4daa194e1fe) )
|
| 409 | ROM_LOAD( "pl80.tiny.bin", 0x0000, 0x0400, CRC(940ec1ed) SHA1(ad83a3b57e2f0fbaa1e40644cd999b3f239635e8) )
|
| 410 | ROM_LOAD( "rs232.bin", 0x0000, 0x0800, CRC(926ff2d1) SHA1(be02bd388bba0211ea72d4868264a63308e4318d) )
|
| 411 | ROM_LOAD( "f&m.joycard.bin", 0x0000, 0x0002, CRC(a681ea11) SHA1(ff4baa8b79471f31667337c30345d642810776e1) )
|
| 412 | ROM_END
|
| 413 | |
| 414 | ROM_START( comx35n )
|
| 415 | ROM_REGION( 0x10000, REGION_CPU1, 0 )
|
| 416 | ROM_SYSTEM_BIOS( 0, "basic100", "COMX BASIC V1.00" )
|
| 417 | ROMX_LOAD( "comx_10.u21", 0x0000, 0x4000, CRC(68d0db2d) SHA1(062328361629019ceed9375afac18e2b7849ce47), ROM_BIOS(1) )
|
| 418 | ROM_SYSTEM_BIOS( 1, "default", "COMX BASIC V1.01" )
|
| 419 | ROMX_LOAD( "comx_11.u21", 0x0000, 0x4000, CRC(609d89cd) SHA1(799646810510d8236fbfafaff7a73d5170990f16), ROM_BIOS(2) )
|
| 420 | |
| 421 | ROM_REGION( 0x2000, REGION_USER1, 0 )
|
| 422 | ROM_LOAD( "expansion.bin", 0x0000, 0x1000, CRC(52cb44e2) SHA1(3f9a3d9940b36d4fee5eca9f1359c99d7ed545b9) )
|
| 423 | ROM_LOAD( "f&m.expansion.3.1.bin", 0x0000, 0x1000, CRC(818ca2ef) SHA1(ea000097622e7fd472d53e7899e3c83773433045) )
|
| 424 | ROM_LOAD( "printer.bin", 0x0000, 0x0800, CRC(3bbc2b2e) SHA1(08bf7ea4174713ab24969c553affd5c1401876b8) )
|
| 425 | ROM_LOAD( "thermal.bin", 0x0000, 0x1000, CRC(41a72ba8) SHA1(3a8760c78bd8c7bec2dbf26657b930c9a6814803) )
|
| 426 | ROM_LOAD( "f&m.printer.1.2.bin", 0x0000, 0x1000, CRC(2feb997d) SHA1(ee9cb91042696c88ff5f2f44d2f702dc93369ba0) )
|
| 427 | ROM_LOAD( "fdc.bin", 0x0000, 0x2000, CRC(cf4ecd2e) SHA1(290e19bdc89e3c8059e63d5ae3cca4daa194e1fe) )
|
| 428 | ROM_LOAD( "pl80.tiny.bin", 0x0000, 0x0400, CRC(940ec1ed) SHA1(ad83a3b57e2f0fbaa1e40644cd999b3f239635e8) )
|
| 429 | ROM_LOAD( "rs232.bin", 0x0000, 0x0800, CRC(926ff2d1) SHA1(be02bd388bba0211ea72d4868264a63308e4318d) )
|
| 430 | ROM_LOAD( "f&m.joycard.bin", 0x0000, 0x0002, CRC(a681ea11) SHA1(ff4baa8b79471f31667337c30345d642810776e1) )
|
| 431 | ROM_END
|
| 432 | |
| 433 | /* System Configuration */
|
| 434 | |
| 435 | static void comx35_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
|
| 436 | {
|
| 437 | /* cassette */
|
| 438 | switch(state)
|
| 439 | {
|
| 440 | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 441 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break;
|
| 442 | case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE: info->i = CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED; break;
|
| 443 | |
| 444 | default: cassette_device_getinfo(devclass, state, info); break;
|
| 445 | }
|
| 446 | }
|
| 447 | |
| 448 | SYSTEM_CONFIG_START( comx35 )
|
| 449 | CONFIG_RAM_DEFAULT (32 * 1024)
|
| 450 | CONFIG_RAM (64 * 1024)
|
| 451 | CONFIG_DEVICE(comx35_cassette_getinfo)
|
| 452 | SYSTEM_CONFIG_END
|
| 453 | |
| 454 | /* System Drivers */
|
| 455 | |
| 456 | // YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS
|
| 457 | COMP( 1983, comx35p, 0, 0, comx35p, comx35, 0, comx35, "Comx World Operations Ltd", "COMX 35 (PAL)", GAME_NOT_WORKING )
|
| 458 | COMP( 1983, comx35n, comx35p,0, comx35n, comx35, 0, comx35, "Comx World Operations Ltd", "COMX 35 (NTSC)", GAME_NOT_WORKING )
|