src/mess/machine/tms9902.c
| r14513 | r14514 | |
| 1 | | /* |
| 1 | /**************************************************************************** |
| 2 | |
| 2 | 3 | TMS9902 Asynchronous Communication Controller |
| 3 | 4 | |
| 4 | 5 | TMS9902 is an asynchronous serial controller for use with the TI990 and |
| r14513 | r14514 | |
| 31 | 32 | |
| 32 | 33 | Raphael Nabet, 2003 |
| 33 | 34 | Michael Zapf, 2011 |
| 34 | | */ |
| 35 | February 2012: Rewritten as class |
| 35 | 36 | |
| 36 | | #include <math.h> |
| 37 | | #include "emu.h" |
| 37 | *****************************************************************************/ |
| 38 | 38 | |
| 39 | #include <math.h> |
| 39 | 40 | #include "tms9902.h" |
| 40 | 41 | |
| 41 | 42 | #define VERBOSE 1 |
| 42 | 43 | #define LOG logerror |
| 43 | 44 | |
| 45 | enum |
| 46 | { |
| 47 | DECTIMER, |
| 48 | RECVTIMER, |
| 49 | SENDTIMER |
| 50 | }; |
| 51 | |
| 44 | 52 | // Polling frequency. We use a much higher value to allow for line state changes |
| 45 | 53 | // happening between character transmissions (which happen in parallel in real |
| 46 | 54 | // communications but which must be serialized here) |
| 47 | 55 | #define POLLING_FREQ 20000 |
| 48 | 56 | |
| 49 | | /*************************************************************************** |
| 50 | | TYPE DEFINITIONS |
| 51 | | ***************************************************************************/ |
| 52 | 57 | |
| 53 | | typedef struct _tms9902_t tms9902_t; |
| 54 | | struct _tms9902_t |
| 58 | /* |
| 59 | Constructor |
| 60 | */ |
| 61 | tms9902_device::tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 62 | : device_t(mconfig, TMS9902, "TMS9902 Asynchronous Communication Controller", tag, owner, clock) |
| 55 | 63 | { |
| 56 | | /* driver-specific configuration */ |
| 57 | | /* tms9902 clock rate (PHI* pin, normally connected to TMS9900 Phi3*) */ |
| 58 | | // Official range is 2MHz-3.3MHz. Some tms9902s were sold as "MP9214", and |
| 59 | | // were tested for speeds up to 4MHz, provided the clk4m control bit is set. |
| 60 | | // (warning: 3MHz on a tms9900 is equivalent to 12MHz on a tms9995 or tms99000) |
| 61 | | double clock_rate; |
| 62 | | |
| 63 | | /* Modes */ |
| 64 | | bool LDCTRL; // Load control register |
| 65 | | bool LDIR; // Load interval register |
| 66 | | bool LRDR; // Load receive data register |
| 67 | | bool LXDR; // Load transmit data register |
| 68 | | bool TSTMD; // Test mode |
| 69 | | |
| 70 | | /* output pin */ |
| 71 | | bool RTSON; // RTS-on request |
| 72 | | |
| 73 | | /* transmitter registers */ |
| 74 | | bool BRKON; // BRK-on request |
| 75 | | bool BRKout; // indicates the current BRK state |
| 76 | | |
| 77 | | UINT8 XBR; // transmit buffer register |
| 78 | | UINT8 XSR; // transmit shift register |
| 79 | | |
| 80 | | /* receiver registers */ |
| 81 | | UINT8 RBR; // Receive buffer register |
| 82 | | |
| 83 | | /* Interrupt enable flags */ |
| 84 | | bool DSCENB; // Data set change interrupt enable |
| 85 | | bool RIENB; // Receiver interrupt enable |
| 86 | | bool XBIENB; // Tansmit buffer interrupt enable |
| 87 | | bool TIMENB; // Timer interrupt enable |
| 88 | | |
| 89 | | /* |
| 90 | | Rate registers. The receive bit rate calculates as |
| 91 | | bitrate = clock1 / (2 * (8 ^ RDV8) * RDR) |
| 92 | | (similarly for transmit) |
| 93 | | |
| 94 | | where clock1 = clock_rate / (CLK4M? 4:3) |
| 95 | | */ |
| 96 | | UINT16 RDR; // Receive data rate |
| 97 | | bool RDV8; // Receive data rate divider |
| 98 | | UINT16 XDR; // Transmit data rate |
| 99 | | bool XDV8; // Transmit data rate divider |
| 100 | | |
| 101 | | /* Status flags */ |
| 102 | | bool INT; // mirrors /INT output line, inverted |
| 103 | | bool DSCH; // Data set status change |
| 104 | | |
| 105 | | bool CTSin; // Inverted /CTS input (i.e. CTS) |
| 106 | | bool DSRin; // Inverted /DSR input (i.e. DSR) |
| 107 | | bool RTSout; // Current inverted /RTS line state (i.e. RTS) |
| 108 | | |
| 109 | | bool TIMELP; // Timer elapsed |
| 110 | | bool TIMERR; // Timer error |
| 111 | | |
| 112 | | bool XSRE; // Transmit shift register empty |
| 113 | | bool XBRE; // Transmit buffer register empty |
| 114 | | bool RBRL; // Receive buffer register loaded |
| 115 | | |
| 116 | | bool RIN; // State of the RIN pin |
| 117 | | bool RSBD; // Receive start bit detect |
| 118 | | bool RFBD; // Receive full bit detect |
| 119 | | bool RFER; // Receive framing error |
| 120 | | bool ROVER; // Receiver overflow |
| 121 | | bool RPER; // Receive parity error |
| 122 | | |
| 123 | | UINT8 RCL; // Character length |
| 124 | | bool ODDP; |
| 125 | | bool PENB; |
| 126 | | UINT8 STOPB; |
| 127 | | bool CLK4M; // /PHI input divide select |
| 128 | | |
| 129 | | UINT8 TMR; /* interval timer */ |
| 130 | | |
| 131 | | /* clock registers */ |
| 132 | | emu_timer *dectimer; /* MESS timer, used to emulate the decrementer register */ |
| 133 | | emu_timer *recvtimer; |
| 134 | | emu_timer *sendtimer; |
| 135 | | |
| 136 | | // This value is the ratio of data input versus the poll rate. The |
| 137 | | // data source should deliver data bytes at every 1/baudpoll call. |
| 138 | | // This is to ensure that data is delivered at a rate that is expected |
| 139 | | // from the emulated program. |
| 140 | | double baudpoll; |
| 141 | | |
| 142 | | /* Pointer to interface */ |
| 143 | | const tms9902_interface *intf; |
| 144 | | }; |
| 145 | | |
| 146 | | static void initiate_transmit(device_t *device); |
| 147 | | static void send_break(device_t *device, bool state); |
| 148 | | static DEVICE_RESET( tms9902 ); |
| 149 | | |
| 150 | | /*************************************************************************** |
| 151 | | INLINE FUNCTIONS |
| 152 | | ***************************************************************************/ |
| 153 | | |
| 154 | | INLINE tms9902_t *get_token(device_t *device) |
| 155 | | { |
| 156 | | assert(device != NULL); |
| 157 | | assert(device->type() == TMS9902); |
| 158 | | return (tms9902_t *) downcast<legacy_device_base *>(device)->token(); |
| 159 | 64 | } |
| 160 | 65 | |
| 161 | | |
| 162 | 66 | /* |
| 163 | 67 | should be called after any change to int_state or enabled_ints. |
| 164 | 68 | */ |
| 165 | | static void field_interrupts(device_t *device) |
| 69 | void tms9902_device::field_interrupts() |
| 166 | 70 | { |
| 167 | | tms9902_t *tms9902 = get_token(device); |
| 168 | | bool new_int = (tms9902->DSCH && tms9902->DSCENB) |
| 169 | | || (tms9902->RBRL && tms9902->RIENB) |
| 170 | | || (tms9902->XBRE && tms9902->XBIENB) |
| 171 | | || (tms9902->TIMELP && tms9902->TIMENB); |
| 71 | bool new_int = (m_DSCH && m_DSCENB) |
| 72 | || (m_RBRL && m_RIENB) |
| 73 | || (m_XBRE && m_XBIENB) |
| 74 | || (m_TIMELP && m_TIMENB); |
| 172 | 75 | // if (VERBOSE>3) LOG("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n", |
| 173 | | // tms9902->DSCH, tms9902->DSCENB, tms9902->RBRL, tms9902->RIENB, tms9902->XBRE, tms9902->XBIENB, tms9902->TIMELP, tms9902->TIMENB); |
| 174 | | if (new_int != tms9902->INT) |
| 76 | // m_DSCH, m_DSCENB, m_RBRL, m_RIENB, m_XBRE, m_XBIENB, m_TIMELP, m_TIMENB); |
| 77 | if (new_int != m_INT) |
| 175 | 78 | { |
| 176 | 79 | // Only consider edges |
| 177 | | tms9902->INT = new_int; |
| 178 | | if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (tms9902->INT)? "asserted" : "cleared"); |
| 179 | | if (tms9902->intf->int_callback) |
| 180 | | (*tms9902->intf->int_callback)(device, tms9902->INT? ASSERT_LINE : CLEAR_LINE); |
| 80 | m_INT = new_int; |
| 81 | if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (m_INT)? "asserted" : "cleared"); |
| 82 | int_callback(m_INT? ASSERT_LINE : CLEAR_LINE); |
| 181 | 83 | } |
| 182 | 84 | } |
| 183 | 85 | |
| r14513 | r14514 | |
| 185 | 87 | Called whenever the incoming CTS* line changes. This should be called by |
| 186 | 88 | the device that contains the UART. |
| 187 | 89 | */ |
| 188 | | void tms9902_rcv_cts(device_t *device, line_state state) |
| 90 | void tms9902_device::rcv_cts(line_state state) |
| 189 | 91 | { |
| 190 | | tms9902_t *tms9902 = get_token(device); |
| 191 | | bool previous = tms9902->CTSin; |
| 92 | bool previous = m_CTSin; |
| 192 | 93 | |
| 193 | 94 | // CTSin is an internal register of the TMS9902 with positive logic |
| 194 | | tms9902->CTSin = (state==ASSERT_LINE); |
| 95 | m_CTSin = (state==ASSERT_LINE); |
| 195 | 96 | |
| 196 | 97 | if (VERBOSE>3) LOG("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 197 | 98 | |
| 198 | | if (tms9902->CTSin != previous) |
| 99 | if (m_CTSin != previous) |
| 199 | 100 | { |
| 200 | | tms9902->DSCH = true; |
| 201 | | field_interrupts(device); |
| 101 | m_DSCH = true; |
| 102 | field_interrupts(); |
| 202 | 103 | |
| 203 | 104 | // If CTS becomes asserted and we have been sending |
| 204 | | if (state==ASSERT_LINE && tms9902->RTSout) |
| 105 | if (state==ASSERT_LINE && m_RTSout) |
| 205 | 106 | { |
| 206 | 107 | // and if the byte buffer is empty |
| 207 | | if (tms9902->XBRE) |
| 108 | if (m_XBRE) |
| 208 | 109 | { |
| 209 | 110 | // and we want to have a BRK, send it |
| 210 | | if (tms9902->BRKON) |
| 211 | | send_break(device, true); |
| 111 | if (m_BRKON) send_break(true); |
| 212 | 112 | } |
| 213 | 113 | else |
| 214 | 114 | { |
| 215 | 115 | // Buffer is not empty, we can send it |
| 216 | 116 | // If the shift register is empty, transfer the data |
| 217 | | if (tms9902->XSRE && !tms9902->BRKout) |
| 117 | if (m_XSRE && !m_BRKout) |
| 218 | 118 | { |
| 219 | | initiate_transmit(device); |
| 119 | initiate_transmit(); |
| 220 | 120 | } |
| 221 | 121 | } |
| 222 | 122 | } |
| 223 | 123 | } |
| 224 | 124 | else |
| 225 | 125 | { |
| 226 | | tms9902->DSCH = false; |
| 126 | m_DSCH = false; |
| 227 | 127 | if (VERBOSE>4) LOG("TMS9902: no change in CTS line, no interrupt."); |
| 228 | 128 | } |
| 229 | 129 | } |
| 230 | 130 | |
| 231 | | void tms9902_clock(device_t *device, bool state) |
| 131 | void tms9902_device::set_clock(bool state) |
| 232 | 132 | { |
| 233 | | tms9902_t *tms9902 = get_token(device); |
| 234 | 133 | if (state) |
| 235 | | tms9902->recvtimer->adjust(attotime::from_msec(1), 0, attotime::from_hz(POLLING_FREQ)); |
| 134 | m_recvtimer->adjust(attotime::from_msec(1), 0, attotime::from_hz(POLLING_FREQ)); |
| 236 | 135 | else |
| 237 | | tms9902->recvtimer->reset(); |
| 136 | m_recvtimer->reset(); |
| 238 | 137 | } |
| 239 | 138 | |
| 240 | 139 | /* |
| 241 | 140 | Called whenever the incoming DSR* line changes. This should be called by |
| 242 | 141 | the device that contains the UART. |
| 243 | 142 | */ |
| 244 | | void tms9902_rcv_dsr(device_t *device, line_state state) |
| 143 | void tms9902_device::rcv_dsr(line_state state) |
| 245 | 144 | { |
| 246 | | tms9902_t *tms9902 = get_token(device); |
| 247 | | bool previous = tms9902->DSRin; |
| 145 | bool previous = m_DSRin; |
| 248 | 146 | if (VERBOSE>3) LOG("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 249 | | tms9902->DSRin = (state==ASSERT_LINE); |
| 147 | m_DSRin = (state==ASSERT_LINE); |
| 250 | 148 | |
| 251 | | if (tms9902->DSRin != previous) |
| 149 | if (m_DSRin != previous) |
| 252 | 150 | { |
| 253 | | tms9902->DSCH = true; |
| 254 | | field_interrupts(device); |
| 151 | m_DSCH = true; |
| 152 | field_interrupts(); |
| 255 | 153 | } |
| 256 | 154 | else |
| 257 | 155 | { |
| 258 | | tms9902->DSCH = false; |
| 156 | m_DSCH = false; |
| 259 | 157 | if (VERBOSE>4) LOG("TMS9902: no change in DSR line, no interrupt."); |
| 260 | 158 | } |
| 261 | 159 | } |
| r14513 | r14514 | |
| 265 | 163 | the device that contains the UART. Unlike the real thing, we deliver |
| 266 | 164 | complete bytes in one go. |
| 267 | 165 | */ |
| 268 | | void tms9902_rcv_data(device_t *device, UINT8 data) |
| 166 | void tms9902_device::rcv_data(UINT8 data) |
| 269 | 167 | { |
| 270 | | tms9902_t *tms9902 = get_token(device); |
| 271 | | |
| 272 | 168 | // Put the received byte into the 1-byte receive buffer |
| 273 | | tms9902->RBR = data; |
| 169 | m_RBR = data; |
| 274 | 170 | |
| 275 | 171 | // Clear last errors |
| 276 | | tms9902->RFER = false; |
| 277 | | tms9902->RPER = false; |
| 172 | m_RFER = false; |
| 173 | m_RPER = false; |
| 278 | 174 | |
| 279 | | if (!tms9902->RBRL) |
| 175 | if (!m_RBRL) |
| 280 | 176 | { |
| 281 | 177 | // Receive buffer was empty |
| 282 | | tms9902->RBRL = true; |
| 283 | | tms9902->ROVER = false; |
| 178 | m_RBRL = true; |
| 179 | m_ROVER = false; |
| 284 | 180 | if (VERBOSE>3) LOG("TMS9902: Receive buffer loaded with byte %02x\n", data); |
| 285 | | field_interrupts(device); |
| 181 | field_interrupts(); |
| 286 | 182 | } |
| 287 | 183 | else |
| 288 | 184 | { |
| 289 | 185 | // Receive buffer was full |
| 290 | | tms9902->ROVER = true; |
| 186 | m_ROVER = true; |
| 291 | 187 | if (VERBOSE>1) LOG("TMS9902: Receive buffer still loaded; overflow error\n"); |
| 292 | 188 | } |
| 293 | 189 | } |
| r14513 | r14514 | |
| 300 | 196 | as if it occurred here. |
| 301 | 197 | The flag is reset by the next correctly received byte. |
| 302 | 198 | */ |
| 303 | | void tms9902_rcv_framing_error(device_t *device) |
| 199 | void tms9902_device::rcv_framing_error() |
| 304 | 200 | { |
| 305 | | tms9902_t *tms9902 = get_token(device); |
| 306 | 201 | if (VERBOSE>2) LOG("TMS9902: Detected framing error\n"); |
| 307 | | tms9902->RFER = true; |
| 202 | m_RFER = true; |
| 308 | 203 | } |
| 309 | 204 | |
| 310 | 205 | /* |
| r14513 | r14514 | |
| 313 | 208 | as if it occurred here. |
| 314 | 209 | The flag is reset by the next correctly received byte. |
| 315 | 210 | */ |
| 316 | | void tms9902_rcv_parity_error(device_t *device) |
| 211 | void tms9902_device::rcv_parity_error() |
| 317 | 212 | { |
| 318 | | tms9902_t *tms9902 = get_token(device); |
| 319 | 213 | if (VERBOSE>2) LOG("TMS9902: Detected parity error\n"); |
| 320 | | tms9902->RPER = true; |
| 214 | m_RPER = true; |
| 321 | 215 | } |
| 322 | 216 | |
| 323 | 217 | /* |
| r14513 | r14514 | |
| 326 | 220 | of low level on the RIN pin which makes the chip re-synchronize on the |
| 327 | 221 | next rising edge. |
| 328 | 222 | */ |
| 329 | | void tms9902_rcv_break(device_t *device, bool value) |
| 223 | void tms9902_device::rcv_break(bool value) |
| 330 | 224 | { |
| 331 | 225 | if (VERBOSE>2) LOG("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0); |
| 332 | 226 | } |
| 333 | 227 | |
| 334 | 228 | //------------------------------------------------ |
| 335 | 229 | |
| 336 | | |
| 337 | 230 | /* |
| 338 | | This call-back is called by the MESS timer system when the decrementer |
| 339 | | reaches 0. |
| 231 | Timer callback |
| 340 | 232 | */ |
| 341 | | static TIMER_CALLBACK(decrementer_callback) |
| 233 | void tms9902_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 342 | 234 | { |
| 343 | | device_t *device = (device_t *) ptr; |
| 344 | | tms9902_t *tms9902 = get_token(device); |
| 235 | switch (id) |
| 236 | { |
| 237 | // This call-back is called by the MESS timer system when the decrementer |
| 238 | // reaches 0. |
| 239 | case DECTIMER: |
| 240 | m_TIMERR = m_TIMELP; |
| 241 | break; |
| 345 | 242 | |
| 346 | | if (tms9902->TIMELP) |
| 347 | | tms9902->TIMERR = true; |
| 348 | | else |
| 349 | | tms9902->TIMELP = false; |
| 350 | | } |
| 243 | // Callback for the autonomous operations of the chip. This is normally |
| 244 | // controlled by an external clock of 3-4 MHz, internally divided by 3 or 4, |
| 245 | // depending on CLK4M. With this timer, reception of characters becomes |
| 246 | // possible. |
| 247 | case RECVTIMER: |
| 248 | rcv_callback(ASSERT_LINE); |
| 249 | break; |
| 351 | 250 | |
| 352 | | /* |
| 353 | | Callback for the autonomous operations of the chip. This is normally |
| 354 | | controlled by an external clock of 3-4 MHz, internally divided by 3 or 4, |
| 355 | | depending on CLK4M. With this timer, reception of characters becomes |
| 356 | | possible. |
| 357 | | We deliver the baudpoll value which allows the callback function to know |
| 358 | | when the next data byte shall be delivered. |
| 359 | | */ |
| 360 | | static TIMER_CALLBACK(op_callback) |
| 361 | | { |
| 362 | | device_t *device = (device_t *) ptr; |
| 363 | | tms9902_t *tms9902 = get_token(device); |
| 251 | case SENDTIMER: |
| 252 | // Byte has been sent |
| 253 | m_XSRE = true; |
| 364 | 254 | |
| 365 | | if (tms9902->intf->rcv_callback) |
| 366 | | (*tms9902->intf->rcv_callback)(device, tms9902->baudpoll); |
| 367 | | } |
| 368 | | |
| 369 | | static TIMER_CALLBACK(sender_callback) |
| 370 | | { |
| 371 | | device_t *device = (device_t *) ptr; |
| 372 | | tms9902_t *tms9902 = get_token(device); |
| 373 | | // Byte has been sent |
| 374 | | tms9902->XSRE = true; |
| 375 | | |
| 376 | | // In the meantime, the CPU may have pushed a new byte into the XBR |
| 377 | | // so we loop until all data are transferred |
| 378 | | if (!tms9902->XBRE && tms9902->CTSin) |
| 379 | | { |
| 380 | | initiate_transmit(device); |
| 255 | // In the meantime, the CPU may have pushed a new byte into the XBR |
| 256 | // so we loop until all data are transferred |
| 257 | if (!m_XBRE && m_CTSin) |
| 258 | { |
| 259 | initiate_transmit(); |
| 260 | } |
| 261 | break; |
| 381 | 262 | } |
| 382 | 263 | } |
| 383 | 264 | |
| 384 | 265 | /* |
| 385 | 266 | load the content of clockinvl into the decrementer |
| 386 | 267 | */ |
| 387 | | static void reload_interval_timer(device_t *device) |
| 268 | void tms9902_device::reload_interval_timer() |
| 388 | 269 | { |
| 389 | | tms9902_t *tms9902 = get_token(device); |
| 390 | | if (tms9902->TMR) |
| 270 | if (m_TMR) |
| 391 | 271 | { /* reset clock interval */ |
| 392 | | tms9902->dectimer->adjust( |
| 393 | | attotime::from_double((double) tms9902->TMR / (tms9902->clock_rate / ((tms9902->CLK4M) ? 4. : 3.) / 64.)), |
| 272 | m_dectimer->adjust( |
| 273 | attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.)), |
| 394 | 274 | 0, |
| 395 | | attotime::from_double((double) tms9902->TMR / (tms9902->clock_rate / ((tms9902->CLK4M) ? 4. : 3.) / 64.))); |
| 275 | attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.))); |
| 396 | 276 | } |
| 397 | 277 | else |
| 398 | 278 | { /* clock interval == 0 -> no timer */ |
| 399 | | tms9902->dectimer->enable(0); |
| 279 | m_dectimer->enable(0); |
| 400 | 280 | } |
| 401 | 281 | } |
| 402 | 282 | |
| 403 | | static void send_break(device_t *device, bool state) |
| 283 | void tms9902_device::send_break(bool state) |
| 404 | 284 | { |
| 405 | | tms9902_t *tms9902 = get_token(device); |
| 406 | | |
| 407 | | if (state != tms9902->BRKout) |
| 285 | if (state != m_BRKout) |
| 408 | 286 | { |
| 409 | | tms9902->BRKout = state; |
| 287 | m_BRKout = state; |
| 410 | 288 | if (VERBOSE>2) LOG("TMS9902: Sending BREAK=%d\n", state? 1:0); |
| 411 | 289 | |
| 412 | 290 | // Signal BRK (on/off) to the remote site |
| 413 | | if (tms9902->intf->ctrl_callback) |
| 414 | | (*tms9902->intf->ctrl_callback)(device, EXCEPT, BRK, state? 1:0); |
| 291 | ctrl_callback((EXCEPT | BRK), state? 1:0); |
| 415 | 292 | } |
| 416 | 293 | } |
| 417 | 294 | |
| 295 | /* |
| 296 | Baudpoll value allows the callback function to know when the next data byte shall be delivered. |
| 297 | */ |
| 298 | double tms9902_device::get_baudpoll() |
| 299 | { |
| 300 | return m_baudpoll; |
| 301 | } |
| 302 | |
| 418 | 303 | // ========================================================================== |
| 419 | 304 | |
| 420 | 305 | /* |
| r14513 | r14514 | |
| 429 | 314 | |
| 430 | 315 | CLK4M RDV8 RDR9 RDR8 | RDR7 RDR6 RDR5 RDR4 | RDR3 RDR2 RDR1 RDR0 |
| 431 | 316 | */ |
| 432 | | static void set_receive_data_rate(device_t *device) |
| 317 | void tms9902_device::set_receive_data_rate() |
| 433 | 318 | { |
| 434 | | tms9902_t *tms9902 = get_token(device); |
| 435 | | int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->RDV8? 0x400 : 0) | tms9902->RDR; |
| 319 | int value = (m_CLK4M? 0x800 : 0) | (m_RDV8? 0x400 : 0) | m_RDR; |
| 436 | 320 | if (VERBOSE>3) LOG("TMS9902: receive rate = %04x\n", value); |
| 437 | 321 | |
| 438 | 322 | // Calculate the ratio between receive baud rate and polling frequency |
| 439 | | double fint = tms9902->clock_rate / ((tms9902->CLK4M) ? 4.0 : 3.0); |
| 440 | | double baud = fint / (2.0 * ((tms9902->RDV8)? 8:1) * tms9902->RDR); |
| 323 | double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0); |
| 324 | double baud = fint / (2.0 * ((m_RDV8)? 8:1) * m_RDR); |
| 441 | 325 | |
| 442 | 326 | // We assume 10 bit per character (7 data usually add 1 parity; 1 start, 1 stop) |
| 443 | 327 | // This value represents the ratio of data inputs of one poll. |
| 444 | 328 | // Thus the callback function should add up this value on each poll |
| 445 | 329 | // and deliver a data input not before it sums up to 1. |
| 446 | | tms9902->baudpoll = (double)(baud / (10*POLLING_FREQ)); |
| 447 | | if (VERBOSE>3) LOG ("TMS9902: baudpoll = %lf\n", tms9902->baudpoll); |
| 330 | m_baudpoll = (double)(baud / (10*POLLING_FREQ)); |
| 331 | if (VERBOSE>3) LOG ("TMS9902: baudpoll = %lf\n", m_baudpoll); |
| 448 | 332 | |
| 449 | | if (tms9902->intf->ctrl_callback) |
| 450 | | (*tms9902->intf->ctrl_callback)(device, CONFIG, RATERECV, value); |
| 333 | m_last_config_value = value; |
| 334 | ctrl_callback(CONFIG, RATERECV); |
| 451 | 335 | } |
| 452 | 336 | |
| 453 | 337 | /* |
| 454 | 338 | Sets the data rate for the sender part. If a remote UART is attached, |
| 455 | 339 | propagate this setting. |
| 456 | 340 | */ |
| 457 | | static void set_transmit_data_rate(device_t *device) |
| 341 | void tms9902_device::set_transmit_data_rate() |
| 458 | 342 | { |
| 459 | | tms9902_t *tms9902 = get_token(device); |
| 460 | | int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->XDV8? 0x400 : 0) | tms9902->XDR; |
| 343 | int value = (m_CLK4M? 0x800 : 0) | (m_XDV8? 0x400 : 0) | m_XDR; |
| 461 | 344 | if (VERBOSE>3) LOG("TMS9902: set transmit rate = %04x\n", value); |
| 462 | | if (tms9902->intf->ctrl_callback) |
| 463 | | (*tms9902->intf->ctrl_callback)(device, CONFIG, RATEXMIT, value); |
| 345 | m_last_config_value = value; |
| 346 | ctrl_callback(CONFIG, RATEXMIT); |
| 464 | 347 | } |
| 465 | 348 | |
| 466 | | static void set_stop_bits(device_t *device) |
| 349 | void tms9902_device::set_stop_bits() |
| 467 | 350 | { |
| 468 | | tms9902_t *tms9902 = get_token(device); |
| 469 | | int value = tms9902->STOPB; |
| 351 | int value = m_STOPB; |
| 470 | 352 | if (VERBOSE>3) LOG("TMS9902: set stop bits = %02x\n", value); |
| 471 | | if (tms9902->intf->ctrl_callback) |
| 472 | | (*tms9902->intf->ctrl_callback)(device, CONFIG, STOPBITS, value); |
| 353 | m_last_config_value = value; |
| 354 | ctrl_callback(CONFIG, STOPBITS); |
| 473 | 355 | } |
| 474 | 356 | |
| 475 | | static void set_data_bits(device_t *device) |
| 357 | void tms9902_device::set_data_bits() |
| 476 | 358 | { |
| 477 | | tms9902_t *tms9902 = get_token(device); |
| 478 | | int value = tms9902->RCL; |
| 359 | int value = m_RCL; |
| 479 | 360 | if (VERBOSE>3) LOG("TMS9902: set data bits = %02x\n", value); |
| 480 | | if (tms9902->intf->ctrl_callback) |
| 481 | | (*tms9902->intf->ctrl_callback)(device, CONFIG, DATABITS, value); |
| 361 | m_last_config_value = value; |
| 362 | ctrl_callback(CONFIG, DATABITS); |
| 482 | 363 | } |
| 483 | 364 | |
| 484 | | static void set_parity(device_t *device) |
| 365 | void tms9902_device::set_parity() |
| 485 | 366 | { |
| 486 | | tms9902_t *tms9902 = get_token(device); |
| 487 | | int value = (tms9902->PENB? 2:0) | (tms9902->ODDP? 1:0); |
| 367 | int value = (m_PENB? 2:0) | (m_ODDP? 1:0); |
| 488 | 368 | if (VERBOSE>3) LOG("TMS9902: set parity = %02x\n", value); |
| 489 | | if (tms9902->intf->ctrl_callback) |
| 490 | | (*tms9902->intf->ctrl_callback)(device, CONFIG, PARITY, value); |
| 369 | m_last_config_value = value; |
| 370 | ctrl_callback(CONFIG, PARITY); |
| 491 | 371 | } |
| 492 | 372 | |
| 493 | | static void transmit_line_state(device_t *device) |
| 373 | void tms9902_device::transmit_line_state() |
| 494 | 374 | { |
| 495 | | tms9902_t *tms9902 = get_token(device); |
| 496 | | |
| 497 | 375 | // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 498 | 376 | // The 9902 only outputs RTS and BRK |
| 499 | | if (VERBOSE>3) LOG("TMS9902: transmitting line state (only RTS) = %02x\n", (tms9902->RTSout)? 1:0); |
| 500 | | |
| 501 | | if (tms9902->intf->ctrl_callback) |
| 502 | | (*tms9902->intf->ctrl_callback)(device, LINES, RTS, (tms9902->RTSout)? RTS : 0); |
| 377 | if (VERBOSE>3) LOG("TMS9902: transmitting line state (only RTS) = %02x\n", (m_RTSout)? 1:0); |
| 378 | m_last_config_value = (m_RTSout)? RTS : 0; |
| 379 | ctrl_callback(LINES, RTS); |
| 503 | 380 | } |
| 504 | 381 | |
| 505 | | static void set_rts(device_t *device, line_state state) |
| 382 | void tms9902_device::set_rts(line_state state) |
| 506 | 383 | { |
| 507 | | tms9902_t *tms9902 = get_token(device); |
| 508 | 384 | bool lstate = (state==ASSERT_LINE); |
| 509 | 385 | |
| 510 | | if (lstate != tms9902->RTSout) |
| 386 | if (lstate != m_RTSout) |
| 511 | 387 | { |
| 512 | 388 | // Signal RTS to the modem |
| 513 | 389 | if (VERBOSE>3) LOG("TMS9902: Set RTS=%d\n", lstate? 1:0); |
| 514 | | tms9902->RTSout = lstate; |
| 515 | | transmit_line_state(device); |
| 390 | m_RTSout = lstate; |
| 391 | transmit_line_state(); |
| 516 | 392 | } |
| 517 | 393 | } |
| 518 | 394 | |
| 395 | int tms9902_device::get_config_value() |
| 396 | { |
| 397 | return m_last_config_value; |
| 398 | } |
| 399 | |
| 519 | 400 | // ========================================================================== |
| 520 | 401 | |
| 521 | | static void initiate_transmit(device_t *device) |
| 402 | void tms9902_device::initiate_transmit() |
| 522 | 403 | { |
| 523 | | tms9902_t *tms9902 = get_token(device); |
| 524 | | |
| 525 | | if (tms9902->BRKON && tms9902->CTSin) |
| 404 | if (m_BRKON && m_CTSin) |
| 526 | 405 | /* enter break mode */ |
| 527 | | send_break(device, true); |
| 406 | send_break(true); |
| 528 | 407 | else |
| 529 | 408 | { |
| 530 | | if (!tms9902->RTSON && (!tms9902->CTSin || (tms9902->XBRE && !tms9902->BRKout))) |
| 409 | if (!m_RTSON && (!m_CTSin || (m_XBRE && !m_BRKout))) |
| 531 | 410 | /* clear RTS output */ |
| 532 | | set_rts(device, CLEAR_LINE); |
| 411 | set_rts(CLEAR_LINE); |
| 533 | 412 | else |
| 534 | 413 | { |
| 535 | 414 | if (VERBOSE>5) LOG("TMS9902: transferring XBR to XSR; XSRE=false, XBRE=true\n"); |
| 536 | | tms9902->XSR = tms9902->XBR; |
| 537 | | tms9902->XSRE = false; |
| 538 | | tms9902->XBRE = true; |
| 415 | m_XSR = m_XBR; |
| 416 | m_XSRE = false; |
| 417 | m_XBRE = true; |
| 539 | 418 | |
| 540 | | field_interrupts(device); |
| 419 | field_interrupts(); |
| 541 | 420 | |
| 542 | | if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", tms9902->XSR, tms9902->RCL); |
| 421 | if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", m_XSR, m_RCL); |
| 543 | 422 | |
| 544 | | if (tms9902->intf->xmit_callback) |
| 545 | | (*tms9902->intf->xmit_callback)(device, tms9902->XSR & (0xff >> (3-tms9902->RCL))); |
| 423 | xmit_callback(0, m_XSR & (0xff >> (3-m_RCL))); |
| 546 | 424 | |
| 547 | 425 | // Should store that somewhere (but the CPU is fast enough, can afford to recalc :-) ) |
| 548 | | double fint = tms9902->clock_rate / ((tms9902->CLK4M) ? 4.0 : 3.0); |
| 549 | | double baud = fint / (2.0 * ((tms9902->RDV8)? 8:1) * tms9902->RDR); |
| 426 | double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0); |
| 427 | double baud = fint / (2.0 * ((m_RDV8)? 8:1) * m_RDR); |
| 550 | 428 | |
| 551 | 429 | // Time for transmitting 10 bit (8 bit + start + stop) |
| 552 | | tms9902->sendtimer->adjust(attotime::from_hz(baud/10.0)); |
| 430 | m_sendtimer->adjust(attotime::from_hz(baud/10.0)); |
| 553 | 431 | } |
| 554 | 432 | } |
| 555 | 433 | } |
| r14513 | r14514 | |
| 573 | 451 | bit 13-15: not emulated, normally used for diagnostics |
| 574 | 452 | bit 16: RBINT (RBRL&RIENB) |
| 575 | 453 | */ |
| 576 | | READ8_DEVICE_HANDLER( tms9902_cru_r ) |
| 454 | READ8_MEMBER( tms9902_device::cruread ) |
| 577 | 455 | { |
| 578 | 456 | UINT8 answer = 0; |
| 579 | | tms9902_t *tms9902 = get_token(device); |
| 580 | 457 | |
| 581 | 458 | offset &= 0x0003; |
| 582 | 459 | |
| 583 | 460 | switch (offset) |
| 584 | 461 | { |
| 585 | 462 | case 3: // Bits 31-24 |
| 586 | | if (tms9902->INT) answer |= 0x80; |
| 587 | | if (tms9902->LDCTRL || tms9902->LDIR || tms9902->LRDR || tms9902->LXDR || tms9902->BRKON) answer |= 0x40; |
| 588 | | if (tms9902->DSCH) answer |= 0x20; |
| 589 | | if (tms9902->CTSin) answer |= 0x10; |
| 590 | | if (tms9902->DSRin) answer |= 0x08; |
| 591 | | if (tms9902->RTSout) answer |= 0x04; |
| 592 | | if (tms9902->TIMELP) answer |= 0x02; |
| 593 | | if (tms9902->TIMERR) answer |= 0x01; |
| 463 | if (m_INT) answer |= 0x80; |
| 464 | if (m_LDCTRL || m_LDIR || m_LRDR || m_LXDR || m_BRKON) answer |= 0x40; |
| 465 | if (m_DSCH) answer |= 0x20; |
| 466 | if (m_CTSin) answer |= 0x10; |
| 467 | if (m_DSRin) answer |= 0x08; |
| 468 | if (m_RTSout) answer |= 0x04; |
| 469 | if (m_TIMELP) answer |= 0x02; |
| 470 | if (m_TIMERR) answer |= 0x01; |
| 594 | 471 | break; |
| 595 | 472 | |
| 596 | 473 | case 2: // Bits 23-16 |
| 597 | | if (tms9902->XSRE) answer |= 0x80; |
| 598 | | if (tms9902->XBRE) answer |= 0x40; |
| 599 | | if (tms9902->RBRL) answer |= 0x20; |
| 600 | | if (tms9902->DSCH && tms9902->DSCENB) answer |= 0x10; |
| 601 | | if (tms9902->TIMELP && tms9902->TIMENB) answer |= 0x08; |
| 602 | | if (tms9902->XBRE && tms9902->XBIENB) answer |= 0x02; |
| 603 | | if (tms9902->RBRL && tms9902->RIENB) answer |= 0x01; |
| 474 | if (m_XSRE) answer |= 0x80; |
| 475 | if (m_XBRE) answer |= 0x40; |
| 476 | if (m_RBRL) answer |= 0x20; |
| 477 | if (m_DSCH && m_DSCENB) answer |= 0x10; |
| 478 | if (m_TIMELP && m_TIMENB) answer |= 0x08; |
| 479 | if (m_XBRE && m_XBIENB) answer |= 0x02; |
| 480 | if (m_RBRL && m_RIENB) answer |= 0x01; |
| 604 | 481 | break; |
| 605 | 482 | |
| 606 | 483 | case 1: // Bits 15-8 |
| 607 | | if (tms9902->RIN) answer |= 0x80; |
| 608 | | if (tms9902->RSBD) answer |= 0x40; |
| 609 | | if (tms9902->RFBD) answer |= 0x20; |
| 610 | | if (tms9902->RFER) answer |= 0x10; |
| 611 | | if (tms9902->ROVER) answer |= 0x08; |
| 612 | | if (tms9902->RPER) answer |= 0x04; |
| 613 | | if (tms9902->RPER || tms9902->RFER || tms9902->ROVER) answer |= 0x02; |
| 484 | if (m_RIN) answer |= 0x80; |
| 485 | if (m_RSBD) answer |= 0x40; |
| 486 | if (m_RFBD) answer |= 0x20; |
| 487 | if (m_RFER) answer |= 0x10; |
| 488 | if (m_ROVER) answer |= 0x08; |
| 489 | if (m_RPER) answer |= 0x04; |
| 490 | if (m_RPER || m_RFER || m_ROVER) answer |= 0x02; |
| 614 | 491 | break; |
| 615 | 492 | |
| 616 | 493 | case 0: // Bits 7-0 |
| 617 | | answer = tms9902->RBR; |
| 494 | answer = m_RBR; |
| 618 | 495 | break; |
| 619 | 496 | } |
| 620 | 497 | if (VERBOSE>7) LOG("TMS9902: Reading flag bits %d - %d = %02x\n", ((offset+1)*8-1), offset*8, answer); |
| r14513 | r14514 | |
| 637 | 514 | *reg &= ~bits; |
| 638 | 515 | } |
| 639 | 516 | |
| 640 | | static void reset_uart(device_t *device) |
| 517 | void tms9902_device::reset_uart() |
| 641 | 518 | { |
| 642 | | tms9902_t *tms9902 = get_token(device); |
| 643 | 519 | if (VERBOSE>1) LOG("TMS9902: resetting\n"); |
| 644 | 520 | |
| 645 | 521 | /* disable all interrupts */ |
| 646 | | tms9902->DSCENB = false; // Data Set Change Interrupt Enable |
| 647 | | tms9902->TIMENB = false; // Timer Interrupt Enable |
| 648 | | tms9902->XBIENB = false; // Transmit Buffer Interrupt Enable |
| 649 | | tms9902->RIENB = false; // Read Buffer Interrupt Enable |
| 522 | m_DSCENB = false; // Data Set Change Interrupt Enable |
| 523 | m_TIMENB = false; // Timer Interrupt Enable |
| 524 | m_XBIENB = false; // Transmit Buffer Interrupt Enable |
| 525 | m_RIENB = false; // Read Buffer Interrupt Enable |
| 650 | 526 | |
| 651 | 527 | /* initialize transmitter */ |
| 652 | | tms9902->XBRE = true; // Transmit Buffer Register Empty |
| 653 | | tms9902->XSRE = true; // Transmit Shift Register Empty |
| 528 | m_XBRE = true; // Transmit Buffer Register Empty |
| 529 | m_XSRE = true; // Transmit Shift Register Empty |
| 654 | 530 | |
| 655 | 531 | /* initialize receiver */ |
| 656 | | tms9902->RBRL = false; // Read Buffer Register Loaded |
| 532 | m_RBRL = false; // Read Buffer Register Loaded |
| 657 | 533 | |
| 658 | 534 | /* clear RTS */ |
| 659 | | tms9902->RTSON = false; // Request-to-send on (flag) |
| 660 | | tms9902->RTSout = true; // Note we are doing this to ensure the state is sent to the interface |
| 661 | | set_rts(device, CLEAR_LINE); |
| 662 | | tms9902->RTSout = false; // what we actually want |
| 535 | m_RTSON = false; // Request-to-send on (flag) |
| 536 | m_RTSout = true; // Note we are doing this to ensure the state is sent to the interface |
| 537 | set_rts(CLEAR_LINE); |
| 538 | m_RTSout = false; // what we actually want |
| 663 | 539 | |
| 664 | 540 | /* set all register load flags to 1 */ |
| 665 | | tms9902->LDCTRL = true; |
| 666 | | tms9902->LDIR = true; |
| 667 | | tms9902->LRDR = true; |
| 668 | | tms9902->LXDR = true; |
| 541 | m_LDCTRL = true; |
| 542 | m_LDIR = true; |
| 543 | m_LRDR = true; |
| 544 | m_LXDR = true; |
| 669 | 545 | |
| 670 | 546 | /* clear break condition */ |
| 671 | | tms9902->BRKON = false; |
| 672 | | tms9902->BRKout = false; |
| 547 | m_BRKON = false; |
| 548 | m_BRKout = false; |
| 673 | 549 | |
| 674 | | field_interrupts(device); |
| 550 | m_TMR = 0; |
| 551 | m_STOPB = 0; |
| 552 | m_RCL = 0; |
| 553 | m_XDR = 0; |
| 554 | m_RDR = 0; |
| 555 | m_RBR = 0; |
| 556 | m_XBR = 0; |
| 557 | m_XSR = 0; |
| 558 | |
| 559 | field_interrupts(); |
| 675 | 560 | } |
| 676 | 561 | |
| 677 | 562 | /* |
| 678 | 563 | TMS9902 CRU write |
| 679 | 564 | */ |
| 680 | | WRITE8_DEVICE_HANDLER( tms9902_cru_w ) |
| 565 | WRITE8_MEMBER( tms9902_device::cruwrite ) |
| 681 | 566 | { |
| 682 | | tms9902_t *tms9902 = get_token(device); |
| 683 | | |
| 684 | 567 | data &= 1; /* clear extra bits */ |
| 685 | 568 | |
| 686 | 569 | offset &= 0x1F; |
| r14513 | r14514 | |
| 690 | 573 | { |
| 691 | 574 | UINT16 mask = (1 << offset); |
| 692 | 575 | |
| 693 | | if (tms9902->LDCTRL) |
| 576 | if (m_LDCTRL) |
| 694 | 577 | { // Control Register mode. Values written to bits 0-7 are copied |
| 695 | 578 | // into the control register. |
| 696 | 579 | switch (offset) |
| 697 | 580 | { |
| 698 | 581 | case 0: |
| 699 | | set_bits8(&tms9902->RCL, 0x01, (data!=0)); |
| 582 | set_bits8(&m_RCL, 0x01, (data!=0)); |
| 700 | 583 | // we assume that bits are written in increasing order |
| 701 | 584 | // so we do not transmit the data bits twice |
| 702 | 585 | // (will fail when bit 1 is written first) |
| 703 | 586 | break; |
| 704 | 587 | case 1: |
| 705 | | set_bits8(&tms9902->RCL, 0x02, (data!=0)); |
| 706 | | set_data_bits(device); |
| 588 | set_bits8(&m_RCL, 0x02, (data!=0)); |
| 589 | set_data_bits(); |
| 707 | 590 | break; |
| 708 | 591 | case 2: |
| 709 | 592 | break; |
| 710 | 593 | case 3: |
| 711 | | tms9902->CLK4M = (data!=0); |
| 594 | m_CLK4M = (data!=0); |
| 712 | 595 | break; |
| 713 | 596 | case 4: |
| 714 | | tms9902->ODDP = (data!=0); |
| 597 | m_ODDP = (data!=0); |
| 715 | 598 | // we also assume that the parity type is set before the parity enable |
| 716 | 599 | break; |
| 717 | 600 | case 5: |
| 718 | | tms9902->PENB = (data!=0); |
| 719 | | set_parity(device); |
| 601 | m_PENB = (data!=0); |
| 602 | set_parity(); |
| 720 | 603 | break; |
| 721 | 604 | case 6: |
| 722 | | set_bits8(&tms9902->STOPB, 0x01, (data!=0)); |
| 605 | set_bits8(&m_STOPB, 0x01, (data!=0)); |
| 723 | 606 | break; |
| 724 | 607 | case 7: |
| 725 | | set_bits8(&tms9902->STOPB, 0x02, (data!=0)); |
| 608 | set_bits8(&m_STOPB, 0x02, (data!=0)); |
| 726 | 609 | // When bit 7 is written the control register mode is automatically terminated. |
| 727 | | tms9902->LDCTRL = false; |
| 728 | | set_stop_bits(device); |
| 610 | m_LDCTRL = false; |
| 611 | set_stop_bits(); |
| 729 | 612 | break; |
| 730 | 613 | default: |
| 731 | 614 | if (VERBOSE>1) LOG("tms9902: Invalid control register address %d\n", offset); |
| 732 | 615 | } |
| 733 | 616 | } |
| 734 | | else if (tms9902->LDIR) |
| 617 | else if (m_LDIR) |
| 735 | 618 | { // Interval Register mode. Values written to bits 0-7 are copied |
| 736 | 619 | // into the interval register. |
| 737 | 620 | if (offset <= 7) |
| 738 | 621 | { |
| 739 | | set_bits8(&tms9902->TMR, mask, (data!=0)); |
| 622 | set_bits8(&m_TMR, mask, (data!=0)); |
| 740 | 623 | |
| 741 | 624 | if (offset == 7) |
| 742 | 625 | { |
| 743 | | reload_interval_timer(device); |
| 626 | reload_interval_timer(); |
| 744 | 627 | // When bit 7 is written the interval register mode is automatically terminated. |
| 745 | | tms9902->LDIR = false; |
| 628 | m_LDIR = false; |
| 746 | 629 | } |
| 747 | 630 | } |
| 748 | 631 | } |
| 749 | | else if (tms9902->LRDR || tms9902->LXDR) |
| 632 | else if (m_LRDR || m_LXDR) |
| 750 | 633 | { |
| 751 | | if (tms9902->LRDR) |
| 634 | if (m_LRDR) |
| 752 | 635 | { // Receive rate register mode. Values written to bits 0-10 are copied |
| 753 | 636 | // into the receive rate register. |
| 754 | 637 | if (offset < 10) |
| 755 | 638 | { |
| 756 | | set_bits16(&tms9902->RDR, mask, (data!=0)); |
| 639 | set_bits16(&m_RDR, mask, (data!=0)); |
| 757 | 640 | } |
| 758 | 641 | else |
| 759 | 642 | { |
| 760 | 643 | // When bit 10 is written the receive register mode is automatically terminated. |
| 761 | | tms9902->RDV8 = (data!=0); |
| 762 | | tms9902->LRDR = false; |
| 763 | | set_receive_data_rate(device); |
| 644 | m_RDV8 = (data!=0); |
| 645 | m_LRDR = false; |
| 646 | set_receive_data_rate(); |
| 764 | 647 | } |
| 765 | 648 | } |
| 766 | | if (tms9902->LXDR) |
| 649 | if (m_LXDR) |
| 767 | 650 | { |
| 768 | 651 | // The transmit rate register can be set together with the receive rate register. |
| 769 | 652 | if (offset < 10) |
| 770 | 653 | { |
| 771 | | set_bits16(&tms9902->XDR, mask, (data!=0)); |
| 654 | set_bits16(&m_XDR, mask, (data!=0)); |
| 772 | 655 | } |
| 773 | 656 | else |
| 774 | 657 | { |
| 775 | 658 | // Note that the transmit rate register is NOT terminated when |
| 776 | 659 | // writing bit 10. This must be done by unsetting bit 11. |
| 777 | | tms9902->XDV8 = (data!=0); |
| 778 | | set_transmit_data_rate(device); |
| 660 | m_XDV8 = (data!=0); |
| 661 | set_transmit_data_rate(); |
| 779 | 662 | } |
| 780 | 663 | } |
| 781 | 664 | } |
| r14513 | r14514 | |
| 784 | 667 | // written to bits 0-7 are transferred into the transmit buffer register. |
| 785 | 668 | if (offset <= 7) |
| 786 | 669 | { |
| 787 | | set_bits8(&tms9902->XBR, mask, (data!=0)); |
| 670 | set_bits8(&m_XBR, mask, (data!=0)); |
| 788 | 671 | |
| 789 | 672 | if (offset == 7) |
| 790 | 673 | { /* transmit */ |
| 791 | | tms9902->XBRE = false; |
| 674 | m_XBRE = false; |
| 792 | 675 | // Spec: When the transmitter is active, the contents of the Transmit |
| 793 | 676 | // Buffer Register are transferred to the Transmit Shift Register |
| 794 | 677 | // each time the previous character has been completely transmitted |
| 795 | 678 | // We need to check XSRE=true as well, as the implementation |
| 796 | 679 | // makes use of a timed transmission, during which XSRE=false |
| 797 | | if (tms9902->XSRE && tms9902->RTSout && tms9902->CTSin && !tms9902->BRKout) |
| 680 | if (m_XSRE && m_RTSout && m_CTSin && !m_BRKout) |
| 798 | 681 | { |
| 799 | | initiate_transmit(device); |
| 682 | initiate_transmit(); |
| 800 | 683 | } |
| 801 | 684 | } |
| 802 | 685 | } |
| r14513 | r14514 | |
| 806 | 689 | switch (offset) |
| 807 | 690 | { |
| 808 | 691 | case 11: |
| 809 | | tms9902->LXDR = (data!=0); |
| 692 | m_LXDR = (data!=0); |
| 810 | 693 | break; |
| 811 | 694 | case 12: |
| 812 | | tms9902->LRDR = (data!=0); |
| 695 | m_LRDR = (data!=0); |
| 813 | 696 | break; |
| 814 | 697 | case 13: |
| 815 | | tms9902->LDIR = (data!=0); |
| 698 | m_LDIR = (data!=0); |
| 816 | 699 | // Spec: Each time LDIR is reset the contents of the Interval |
| 817 | 700 | // Register are loaded into the Interval Timer, thus restarting |
| 818 | 701 | // the timer. |
| 819 | 702 | if (data==0) |
| 820 | | reload_interval_timer(device); |
| 703 | reload_interval_timer(); |
| 821 | 704 | break; |
| 822 | 705 | case 14: |
| 823 | | tms9902->LDCTRL = (data!=0); |
| 706 | m_LDCTRL = (data!=0); |
| 824 | 707 | break; |
| 825 | 708 | case 15: |
| 826 | | tms9902->TSTMD = (data!=0); // Test mode not implemented |
| 709 | m_TSTMD = (data!=0); // Test mode not implemented |
| 827 | 710 | break; |
| 828 | 711 | case 16: |
| 829 | 712 | if (data!=0) |
| 830 | 713 | { |
| 831 | | tms9902->RTSON = true; |
| 832 | | set_rts(device, ASSERT_LINE); |
| 833 | | if (tms9902->CTSin) |
| 714 | m_RTSON = true; |
| 715 | set_rts(ASSERT_LINE); |
| 716 | if (m_CTSin) |
| 834 | 717 | { |
| 835 | | if (tms9902->XSRE && !tms9902->XBRE && !tms9902->BRKout) |
| 836 | | initiate_transmit(device); |
| 837 | | else if (tms9902->BRKON) |
| 838 | | send_break(device, true); |
| 718 | if (m_XSRE && !m_XBRE && !m_BRKout) |
| 719 | initiate_transmit(); |
| 720 | else if (m_BRKON) |
| 721 | send_break(true); |
| 839 | 722 | } |
| 840 | 723 | } |
| 841 | 724 | else |
| 842 | 725 | { |
| 843 | | tms9902->RTSON = false; |
| 844 | | if (tms9902->XBRE && tms9902->XSRE && !tms9902->BRKout) |
| 726 | m_RTSON = false; |
| 727 | if (m_XBRE && m_XSRE && !m_BRKout) |
| 845 | 728 | { |
| 846 | | set_rts(device, CLEAR_LINE); |
| 729 | set_rts(CLEAR_LINE); |
| 847 | 730 | } |
| 848 | 731 | } |
| 849 | 732 | return; |
| 850 | 733 | case 17: |
| 851 | | if (VERBOSE>3) LOG("TMS9902: set BRKON=%d; BRK=%d\n", data, tms9902->BRKout? 1:0); |
| 852 | | tms9902->BRKON = (data!=0); |
| 853 | | if (tms9902->BRKout && data==0) |
| 734 | if (VERBOSE>3) LOG("TMS9902: set BRKON=%d; BRK=%d\n", data, m_BRKout? 1:0); |
| 735 | m_BRKON = (data!=0); |
| 736 | if (m_BRKout && data==0) |
| 854 | 737 | { |
| 855 | 738 | // clear BRK |
| 856 | | tms9902->BRKout = false; |
| 857 | | if ((!tms9902->XBRE) && tms9902->CTSin) |
| 739 | m_BRKout = false; |
| 740 | if ((!m_XBRE) && m_CTSin) |
| 858 | 741 | { |
| 859 | 742 | /* transmit next byte */ |
| 860 | | initiate_transmit(device); |
| 743 | initiate_transmit(); |
| 861 | 744 | } |
| 862 | | else if (!tms9902->RTSON) |
| 745 | else if (!m_RTSON) |
| 863 | 746 | { |
| 864 | 747 | /* clear RTS */ |
| 865 | | set_rts(device, CLEAR_LINE); |
| 748 | set_rts(CLEAR_LINE); |
| 866 | 749 | } |
| 867 | 750 | } |
| 868 | | else if (tms9902->XBRE && tms9902->XSRE && tms9902->RTSout && tms9902->CTSin) |
| 751 | else if (m_XBRE && m_XSRE && m_RTSout && m_CTSin) |
| 869 | 752 | { |
| 870 | | send_break(device, (data!=0)); |
| 753 | send_break(data!=0); |
| 871 | 754 | } |
| 872 | 755 | return; |
| 873 | 756 | case 18: |
| 874 | 757 | // Receiver Interrupt Enable |
| 875 | 758 | // According to spec, (re)setting this flag clears the RBRL flag |
| 876 | 759 | // (the only way to clear the flag!) |
| 877 | | tms9902->RIENB = (data!=0); |
| 878 | | tms9902->RBRL = false; |
| 760 | m_RIENB = (data!=0); |
| 761 | m_RBRL = false; |
| 879 | 762 | if (VERBOSE>4) LOG("TMS9902: set RBRL=0, set RIENB=%d\n", data); |
| 880 | | field_interrupts(device); |
| 763 | field_interrupts(); |
| 881 | 764 | return; |
| 882 | 765 | case 19: |
| 883 | 766 | /* Transmit Buffer Interrupt Enable */ |
| 884 | | tms9902->XBIENB = (data!=0); |
| 767 | m_XBIENB = (data!=0); |
| 885 | 768 | if (VERBOSE>4) LOG("TMS9902: set XBIENB=%d\n", data); |
| 886 | | field_interrupts(device); |
| 769 | field_interrupts(); |
| 887 | 770 | return; |
| 888 | 771 | case 20: |
| 889 | 772 | /* Timer Interrupt Enable */ |
| 890 | | tms9902->TIMENB = (data!=0); |
| 891 | | tms9902->TIMELP = false; |
| 892 | | tms9902->TIMERR = false; |
| 893 | | field_interrupts(device); |
| 773 | m_TIMENB = (data!=0); |
| 774 | m_TIMELP = false; |
| 775 | m_TIMERR = false; |
| 776 | field_interrupts(); |
| 894 | 777 | return; |
| 895 | 778 | case 21: |
| 896 | 779 | /* Data Set Change Interrupt Enable */ |
| 897 | | tms9902->DSCENB = (data!=0); |
| 898 | | tms9902->DSCH = false; |
| 780 | m_DSCENB = (data!=0); |
| 781 | m_DSCH = false; |
| 899 | 782 | if (VERBOSE>4) LOG("TMS9902: set DSCH=0, set DSCENB=%d\n", data); |
| 900 | | field_interrupts(device); |
| 783 | field_interrupts(); |
| 901 | 784 | return; |
| 902 | 785 | case 31: |
| 903 | 786 | /* RESET */ |
| 904 | | reset_uart(device); |
| 787 | reset_uart(); |
| 905 | 788 | return; |
| 906 | 789 | default: |
| 907 | 790 | if (VERBOSE>1) LOG("TMS9902: Writing to undefined flag bit position %d = %01x\n", offset, data); |
| r14513 | r14514 | |
| 912 | 795 | DEVICE_STOP( tms9902 ) |
| 913 | 796 | -------------------------------------------------*/ |
| 914 | 797 | |
| 915 | | static DEVICE_STOP( tms9902 ) |
| 798 | void tms9902_device::device_stop() |
| 916 | 799 | { |
| 917 | | tms9902_t *tms9902 = get_token(device); |
| 918 | | |
| 919 | | if (tms9902->dectimer) |
| 800 | if (m_dectimer) |
| 920 | 801 | { |
| 921 | | tms9902->dectimer->reset(); |
| 922 | | tms9902->dectimer = NULL; |
| 802 | m_dectimer->reset(); |
| 803 | m_dectimer = NULL; |
| 923 | 804 | } |
| 924 | 805 | } |
| 925 | 806 | |
| r14513 | r14514 | |
| 927 | 808 | DEVICE_RESET( tms9902 ) |
| 928 | 809 | -------------------------------------------------*/ |
| 929 | 810 | |
| 930 | | static DEVICE_RESET( tms9902 ) |
| 811 | void tms9902_device::device_reset() |
| 931 | 812 | { |
| 932 | | reset_uart(device); |
| 813 | reset_uart(); |
| 933 | 814 | } |
| 934 | 815 | |
| 935 | | |
| 936 | 816 | /*------------------------------------------------- |
| 937 | 817 | DEVICE_START( tms9902 ) |
| 938 | 818 | -------------------------------------------------*/ |
| 939 | 819 | |
| 940 | | static DEVICE_START( tms9902 ) |
| 820 | void tms9902_device::device_start() |
| 941 | 821 | { |
| 942 | | tms9902_t *tms9902 = get_token(device); |
| 822 | const tms9902_interface *intf = reinterpret_cast<const tms9902_interface *>(static_config()); |
| 943 | 823 | |
| 944 | | assert(device != NULL); |
| 945 | | assert(device->tag() != NULL); |
| 946 | | assert(device->static_config() != NULL); |
| 824 | m_clock_rate = clock(); |
| 947 | 825 | |
| 948 | | tms9902->intf = (const tms9902_interface*)device->static_config(); |
| 826 | int_callback.resolve(intf->int_callback, *this); |
| 827 | rcv_callback.resolve(intf->rcv_callback, *this); |
| 828 | xmit_callback.resolve(intf->xmit_callback, *this); |
| 829 | ctrl_callback.resolve(intf->ctrl_callback, *this); |
| 949 | 830 | |
| 950 | | tms9902->clock_rate = tms9902->intf->clock_rate; |
| 951 | | |
| 952 | | tms9902->dectimer = device->machine().scheduler().timer_alloc(FUNC(decrementer_callback), (void *) device); |
| 953 | | tms9902->recvtimer = device->machine().scheduler().timer_alloc(FUNC(op_callback), (void *) device); |
| 954 | | tms9902->sendtimer = device->machine().scheduler().timer_alloc(FUNC(sender_callback), (void *) device); |
| 831 | m_dectimer = timer_alloc(DECTIMER); |
| 832 | m_recvtimer = timer_alloc(RECVTIMER); |
| 833 | m_sendtimer = timer_alloc(SENDTIMER); |
| 955 | 834 | } |
| 956 | 835 | |
| 836 | const device_type TMS9902 = &device_creator<tms9902_device>; |
| 957 | 837 | |
| 958 | | |
| 959 | | /*------------------------------------------------- |
| 960 | | DEVICE_GET_INFO( tms9902 ) |
| 961 | | -------------------------------------------------*/ |
| 962 | | |
| 963 | | DEVICE_GET_INFO( tms9902 ) |
| 964 | | { |
| 965 | | switch (state) |
| 966 | | { |
| 967 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 968 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tms9902_t); break; |
| 969 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 970 | | |
| 971 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 972 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tms9902); break; |
| 973 | | case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME (tms9902); break; |
| 974 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(tms9902); break; |
| 975 | | |
| 976 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 977 | | case DEVINFO_STR_NAME: strcpy(info->s, "TMS9902"); break; |
| 978 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "TMS9902"); break; |
| 979 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 980 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 981 | | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 982 | | } |
| 983 | | } |
| 984 | | |
| 985 | | DEFINE_LEGACY_DEVICE(TMS9902, tms9902); |
src/mess/machine/ti99/gromport.c
| r14513 | r14514 | |
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | gromport.c |
| 3 | Gromport: the cartridge port of the TI-99/4, TI-99/4A, and |
| 4 | TI-99/8 console. The name refers to the main intended application |
| 5 | scenario, that is, to host cartridges with GROMs. (The other port |
| 6 | of the console is called I/O port.) |
| 4 | 7 | |
| 5 | | *********************************************************************/ |
| 8 | Over the years, many different kinds of cartridges appeared; the |
| 9 | usual cartridge layout contains GROMs and possibly a ROM circuit |
| 10 | for time-critical code (since the GROMs were utterly slow). |
| 6 | 11 | |
| 7 | | #include "emu.h" |
| 8 | | #include "gromport.h" |
| 9 | | #include "grom.h" |
| 10 | | #include "pool.h" |
| 11 | | #include "unzip.h" |
| 12 | | #include "corestr.h" |
| 13 | | #include "xmlfile.h" |
| 14 | | #include "machine/ram.h" |
| 12 | Texas Instruments kept control over all software development by |
| 13 | reserving GROMs and their programming to them and licensees. |
| 15 | 14 | |
| 16 | | /* start of multicart */ |
| 17 | | #define TAG_PCB "pcb" |
| 15 | Interestingly, the OS designers planned for an alternative - |
| 16 | cartridges which can be run with EPROMs only - which provided |
| 17 | a means for third-party authors to create cartridges without |
| 18 | TI license. The last action of TI before their retreat from the |
| 19 | home computer market was to disable this alternative. |
| 18 | 20 | |
| 19 | | DECLARE_LEGACY_IMAGE_DEVICE(MULTICARTSLOT, multicartslot); |
| 21 | Nevertheless, the majority of consoles runs with different kinds of |
| 22 | cartridges; most recent developments by third party include |
| 23 | multi-bank cartridges with storage space up to 128 KiB. |
| 20 | 24 | |
| 21 | | /*************************************************************************** |
| 22 | | TYPE DEFINITIONS |
| 23 | | ***************************************************************************/ |
| 25 | The implementation as shown here goes beyond the simple port |
| 26 | by realizing a "multi-cartridge extender". This is a somewhat |
| 27 | mythical device which was never available for the normal |
| 28 | customer, but there are reports of the existance of such a device |
| 29 | in development labs or demonstrations. |
| 24 | 30 | |
| 25 | | enum _multicart_load_flags |
| 26 | | { |
| 27 | | MULTICART_FLAGS_DONT_LOAD_RESOURCES = 0x00, |
| 28 | | MULTICART_FLAGS_LOAD_RESOURCES = 0x01 |
| 29 | | }; |
| 30 | | typedef enum _multicart_load_flags multicart_load_flags; |
| 31 | The interesting thing about this is that the OS of the console |
| 32 | fully supports this multi-cartridge extender, providing a selection |
| 33 | option on the screen to switch between different plugged-in |
| 34 | cartridges. |
| 31 | 35 | |
| 32 | | enum _multicart_resource_type |
| 33 | | { |
| 34 | | MULTICART_RESOURCE_TYPE_INVALID, |
| 35 | | MULTICART_RESOURCE_TYPE_ROM, |
| 36 | | MULTICART_RESOURCE_TYPE_RAM |
| 37 | | }; |
| 38 | | typedef enum _multicart_resource_type multicart_resource_type; |
| 36 | The switching is possible by decoding address lines that are reserved |
| 37 | for GROM access. GROMs are accessed via four separate addresses |
| 38 | 9800, 9802, 9C00, 9C02. The addressing scheme looks like this: |
| 39 | 39 | |
| 40 | | typedef struct _multicart_resource multicart_resource; |
| 41 | | struct _multicart_resource |
| 42 | | { |
| 43 | | const char * id; |
| 44 | | const char * filename; |
| 45 | | multicart_resource * next; |
| 46 | | multicart_resource_type type; |
| 47 | | UINT32 length; |
| 48 | | void * ptr; |
| 49 | | }; |
| 40 | 1001 1Wxx xxxx xxM0 W = write(1), read(0), M = address(1), data(0) |
| 50 | 41 | |
| 42 | This leaves 8 bits (256 options) which are not decoded inside the |
| 43 | console. As the complete address is routed to the port, some circuit |
| 44 | just needs to decode the xxx lines and turn on the respective slot. |
| 51 | 45 | |
| 52 | | typedef struct _multicart_socket multicart_socket; |
| 53 | | struct _multicart_socket |
| 54 | | { |
| 55 | | const char * id; |
| 56 | | multicart_socket * next; |
| 57 | | const multicart_resource * resource; |
| 58 | | void * ptr; |
| 59 | | }; |
| 46 | One catch must be considered: Some cartridges contain ROMs which are |
| 47 | directly accessed and not via ports. This means that the ROMs must |
| 48 | be activated according to the slot that is selected. |
| 60 | 49 | |
| 50 | Another issue: Each GROM contains an own address counter and an ID. |
| 51 | According to the ID the GROM only delivers data if the address counter |
| 52 | is within the ID area (0 = 0000-1fff, 1=2000-3fff ... 7=e000-ffff). |
| 53 | Thus it is essential that all GROMs stay in sync with their address |
| 54 | counters. We have to route all address settings to all slots and their |
| 55 | GROMs, even when the slot has not been selected before. The selected |
| 56 | just shows its effect when data is read. In this case, only the |
| 57 | data from the selected slot will be delivered. |
| 61 | 58 | |
| 62 | | typedef struct _multicart_private multicart_private; |
| 59 | This may be considered as a design flaw within the complete cartridge system |
| 60 | which eventually led to TI not manufacturing that device for the broad |
| 61 | market. |
| 63 | 62 | |
| 64 | | typedef struct _multicart_t multicart_t; |
| 65 | | struct _multicart_t |
| 66 | | { |
| 67 | | const multicart_resource * resources; |
| 68 | | const multicart_socket * sockets; |
| 69 | | const char * pcb_type; |
| 70 | | const char * gamedrv_name; /* need this to find the path to the nvram files */ |
| 71 | | multicart_private * data; |
| 72 | | }; |
| 63 | -------- |
| 73 | 64 | |
| 74 | | typedef struct _multicartslot_t multicartslot_t; |
| 75 | | struct _multicartslot_t |
| 76 | | { |
| 77 | | device_t *pcb_device; |
| 78 | | multicart_t *mc; |
| 79 | | }; |
| 65 | This implementation also contains the GRAMKracker, a popular device |
| 66 | with persistent RAM and a cartridge slot. With it, cartridge contents |
| 67 | can be read, stored in its RAM, and modified. Moreover, the |
| 68 | console GROMs can be loaded into the device and overrun the data |
| 69 | delivered by the console GROMs. (Take care when changing something |
| 70 | in this emulation - this overrun is emulated by the sequence in which |
| 71 | the devices on the datamux are executed.) |
| 80 | 72 | |
| 73 | -------- |
| 81 | 74 | |
| 82 | | typedef struct _multicartslot_pcb_type multicartslot_pcb_type; |
| 83 | | struct _multicartslot_pcb_type |
| 84 | | { |
| 85 | | const char * name; |
| 86 | | device_type devtype; |
| 87 | | }; |
| 75 | The second part of this file contains the implementation of the |
| 76 | cartridge image format (RPK). |
| 88 | 77 | |
| 78 | Michael Zapf, 2012 |
| 89 | 79 | |
| 90 | | typedef struct _multicartslot_config multicartslot_config; |
| 91 | | struct _multicartslot_config |
| 92 | | { |
| 93 | | const char * extensions; |
| 94 | | device_start_func device_start; |
| 95 | | device_image_load_func device_load; |
| 96 | | device_image_unload_func device_unload; |
| 97 | | multicartslot_pcb_type pcb_types[16]; |
| 98 | | }; |
| 80 | *********************************************************************/ |
| 99 | 81 | |
| 100 | | enum _multicart_open_error |
| 101 | | { |
| 102 | | MCERR_NONE, |
| 103 | | MCERR_NOT_MULTICART, |
| 104 | | MCERR_CORRUPT, |
| 105 | | MCERR_OUT_OF_MEMORY, |
| 106 | | MCERR_XML_ERROR, |
| 107 | | MCERR_INVALID_FILE_REF, |
| 108 | | MCERR_ZIP_ERROR, |
| 109 | | MCERR_MISSING_RAM_LENGTH, |
| 110 | | MCERR_INVALID_RAM_SPEC, |
| 111 | | MCERR_UNKNOWN_RESOURCE_TYPE, |
| 112 | | MCERR_INVALID_RESOURCE_REF, |
| 113 | | MCERR_INVALID_FILE_FORMAT, |
| 114 | | MCERR_MISSING_LAYOUT, |
| 115 | | MCERR_NO_PCB_OR_RESOURCES |
| 116 | | }; |
| 117 | | typedef enum _multicart_open_error multicart_open_error; |
| 82 | #include "gromport.h" |
| 83 | #include "ti99defs.h" |
| 118 | 84 | |
| 119 | | const char *multicart_error_text(multicart_open_error error); |
| 85 | #define VERBOSE 1 |
| 86 | #define LOG logerror |
| 120 | 87 | |
| 121 | | /*************************************************************************** |
| 122 | | PROTOTYPES |
| 123 | | ***************************************************************************/ |
| 88 | #define GROM_AREA 0x9800 |
| 89 | #define GROM_MASK 0xf800 |
| 90 | #define AUTO -1 |
| 124 | 91 | |
| 125 | | /* opens a multicart */ |
| 126 | | multicart_open_error multicart_open(emu_options &options, const char *filename, const char *drvname, multicart_load_flags load_flags, multicart_t **cart); |
| 92 | #define CARTGROM_TAG "grom_contents" |
| 93 | #define CARTROM_TAG "rom_contents" |
| 94 | #define CARTROM2_TAG "rom2_contents" |
| 127 | 95 | |
| 128 | | /* closes a multicart */ |
| 129 | | void multicart_close(emu_options &options, multicart_t *cart); |
| 96 | #define GROM3_TAG "grom3" |
| 97 | #define GROM4_TAG "grom4" |
| 98 | #define GROM5_TAG "grom5" |
| 99 | #define GROM6_TAG "grom6" |
| 100 | #define GROM7_TAG "grom7" |
| 130 | 101 | |
| 131 | | /* accesses the PCB associated with this cartslot */ |
| 132 | | device_t *cartslot_get_pcb(device_t *device); |
| 133 | | |
| 134 | | /* accesses a particular socket */ |
| 135 | | void *cartslot_get_socket(device_t *device, const char *socket_name); |
| 136 | | |
| 137 | | /* accesses a particular socket; gets the length of the associated resource */ |
| 138 | | int cartslot_get_resource_length(device_t *device, const char *socket_name); |
| 139 | | |
| 140 | | #define DECLARE_LEGACY_CART_SLOT_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_cart_slot_device_base) |
| 141 | | #define DEFINE_LEGACY_CART_SLOT_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_cart_slot_device_base) |
| 142 | | |
| 143 | | #define MCFG_MULTICARTSLOT_ADD(_tag) \ |
| 144 | | MCFG_DEVICE_ADD(_tag, MULTICARTSLOT, 0) \ |
| 145 | | |
| 146 | | #define MCFG_MULTICARTSLOT_MODIFY(_tag) \ |
| 147 | | MCFG_DEVICE_MODIFY(_tag) \ |
| 148 | | |
| 149 | | #define MCFG_MULTICARTSLOT_PCBTYPE(_index, _pcb_type_name, _pcb_devtype) \ |
| 150 | | MCFG_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(multicartslot_config, pcb_types, _index, multicartslot_pcb_type, name, _pcb_type_name) \ |
| 151 | | MCFG_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(multicartslot_config, pcb_types, _index, multicartslot_pcb_type, devtype, _pcb_devtype) |
| 152 | | |
| 153 | | #define MCFG_MULTICARTSLOT_START(_start) \ |
| 154 | | MCFG_DEVICE_CONFIG_DATAPTR(multicartslot_config, device_start, DEVICE_START_NAME(_start)) |
| 155 | | |
| 156 | | #define MCFG_MULTICARTSLOT_LOAD(_load) \ |
| 157 | | MCFG_DEVICE_CONFIG_DATAPTR(multicartslot_config, device_load, DEVICE_IMAGE_LOAD_NAME(_load)) |
| 158 | | |
| 159 | | #define MCFG_MULTICARTSLOT_UNLOAD(_unload) \ |
| 160 | | MCFG_DEVICE_CONFIG_DATAPTR(multicartslot_config, device_unload, DEVICE_IMAGE_UNLOAD_NAME(_unload)) |
| 161 | | |
| 162 | | #define MCFG_MULTICARTSLOT_EXTENSION_LIST(_extensions) \ |
| 163 | | MCFG_DEVICE_CONFIG_DATAPTR(multicartslot_config, extensions, _extensions) |
| 164 | | |
| 165 | | |
| 166 | | // ======================> device_cart_slot_interface |
| 167 | | |
| 168 | | // class representing interface-specific live cart_slot |
| 169 | | class device_cart_slot_interface : public device_interface |
| 102 | enum |
| 170 | 103 | { |
| 171 | | public: |
| 172 | | // construction/destruction |
| 173 | | device_cart_slot_interface(const machine_config &mconfig, device_t &device); |
| 174 | | virtual ~device_cart_slot_interface(); |
| 104 | PCB_STANDARD=1, |
| 105 | PCB_PAGED, |
| 106 | PCB_MINIMEM, |
| 107 | PCB_SUPER, |
| 108 | PCB_MBX, |
| 109 | PCB_PAGED379I, |
| 110 | PCB_PAGEDCRU, |
| 111 | PCB_GKRACKER |
| 175 | 112 | }; |
| 176 | 113 | |
| 114 | #define GKSWITCH1_TAG "GKSWITCH1" |
| 115 | #define GKSWITCH2_TAG "GKSWITCH2" |
| 116 | #define GKSWITCH3_TAG "GKSWITCH3" |
| 117 | #define GKSWITCH4_TAG "GKSWITCH4" |
| 118 | #define GKSWITCH5_TAG "GKSWITCH5" |
| 177 | 119 | |
| 178 | | // ======================> legacy_cart_slot_device |
| 120 | /******************************************* |
| 121 | Cartridge PCB types |
| 122 | *******************************************/ |
| 179 | 123 | |
| 180 | | // legacy_cart_slot_device is a legacy_device_base with a cart_slot interface |
| 181 | | class legacy_cart_slot_device_base : public legacy_device_base, |
| 182 | | public device_cart_slot_interface |
| 124 | cartridge_pcb_device::cartridge_pcb_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) |
| 125 | : bus8z_device(mconfig, type, name, tag, owner, clock) |
| 183 | 126 | { |
| 184 | | protected: |
| 185 | | // construction/destruction |
| 186 | | legacy_cart_slot_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config); |
| 187 | | |
| 188 | | public: |
| 189 | | using legacy_device_base::get_legacy_int; |
| 190 | | using legacy_device_base::get_legacy_fct; |
| 191 | | using legacy_device_base::get_legacy_ptr; |
| 192 | | |
| 193 | | // device_cart_slot_interface overrides |
| 194 | | }; |
| 195 | | |
| 196 | | /*************************************************************************** |
| 197 | | TYPE DEFINITIONS |
| 198 | | ***************************************************************************/ |
| 199 | | |
| 200 | | struct _multicart_private |
| 201 | | { |
| 202 | | object_pool * pool; |
| 203 | | zip_file * zip; |
| 204 | | }; |
| 205 | | |
| 206 | | |
| 207 | | typedef struct _multicart_load_state multicart_load_state; |
| 208 | | struct _multicart_load_state |
| 209 | | { |
| 210 | | multicart_t * multicart; |
| 211 | | zip_file * zip; |
| 212 | | xml_data_node * layout_xml; |
| 213 | | xml_data_node * resources_node; |
| 214 | | xml_data_node * pcb_node; |
| 215 | | multicart_resource * resources; |
| 216 | | multicart_socket * sockets; |
| 217 | | }; |
| 218 | | |
| 219 | | static const char error_text[14][30] = |
| 220 | | { |
| 221 | | "no error", |
| 222 | | "not a multicart", |
| 223 | | "module definition corrupt", |
| 224 | | "out of memory", |
| 225 | | "xml format error", |
| 226 | | "invalid file reference", |
| 227 | | "zip file error", |
| 228 | | "missing ram length", |
| 229 | | "invalid ram specification", |
| 230 | | "unknown resource type", |
| 231 | | "invalid resource reference", |
| 232 | | "invalid file format", |
| 233 | | "missing layout", |
| 234 | | "no pcb or resource found" |
| 235 | | }; |
| 236 | | |
| 237 | | const char *multicart_error_text(multicart_open_error error) |
| 238 | | { |
| 239 | | return error_text[(int)error]; |
| 127 | if (VERBOSE>7) LOG("cartridge_pcb_device: common initialization\n"); |
| 128 | for (int i=0; i < 5; i++) m_grom[i] = 0; |
| 129 | m_rom_ptr = 0; |
| 130 | m_rom2_ptr = 0; |
| 131 | m_ram_ptr = 0; |
| 132 | m_grom_size = 0; |
| 133 | m_rom_size = 0; |
| 134 | m_ram_size = 0; |
| 240 | 135 | } |
| 241 | 136 | |
| 242 | | /*************************************************************************** |
| 243 | | INLINE FUNCTIONS |
| 244 | | ***************************************************************************/ |
| 245 | | |
| 246 | | INLINE multicartslot_t *get_token(device_t *device) |
| 137 | void cartridge_pcb_device::device_start(void) |
| 247 | 138 | { |
| 248 | | assert(device != NULL); |
| 249 | | assert(device->type() == MULTICARTSLOT); |
| 250 | | return (multicartslot_t *) downcast<legacy_device_base *>(device)->token(); |
| 251 | 139 | } |
| 252 | 140 | |
| 253 | | |
| 254 | | INLINE const multicartslot_config *get_config(const device_t *device) |
| 141 | cartridge_pcb_standard_device::cartridge_pcb_standard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 142 | : cartridge_pcb_device(mconfig, TICARTPCBSTD, "Standard cartridge PCB", tag, owner, clock) |
| 255 | 143 | { |
| 256 | | assert(device != NULL); |
| 257 | | assert(device->type() == MULTICARTSLOT); |
| 258 | | return (const multicartslot_config *) downcast<const legacy_device_base *>(device)->inline_config(); |
| 259 | 144 | } |
| 260 | 145 | |
| 261 | | |
| 262 | | /*************************************************************************** |
| 263 | | IMPLEMENTATION |
| 264 | | ***************************************************************************/ |
| 265 | | |
| 266 | | /*------------------------------------------------- |
| 267 | | cartslot_get_pcb |
| 268 | | -------------------------------------------------*/ |
| 269 | | |
| 270 | | device_t *cartslot_get_pcb(device_t *device) |
| 146 | cartridge_pcb_paged_device::cartridge_pcb_paged_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 147 | : cartridge_pcb_device(mconfig, TICARTPCBPAG, "Paged cartridge PCB", tag, owner, clock) |
| 271 | 148 | { |
| 272 | | multicartslot_t *cart = get_token(device); |
| 273 | | return cart->pcb_device; |
| 274 | 149 | } |
| 275 | 150 | |
| 276 | | |
| 277 | | /*------------------------------------------------- |
| 278 | | cartslot_get_socket |
| 279 | | -------------------------------------------------*/ |
| 280 | | |
| 281 | | void *cartslot_get_socket(device_t *device, const char *socket_name) |
| 151 | cartridge_pcb_minimem_device::cartridge_pcb_minimem_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 152 | : cartridge_pcb_device(mconfig, TICARTPCBMIN, "MiniMemory cartridge PCB", tag, owner, clock) |
| 282 | 153 | { |
| 283 | | multicartslot_t *cart = get_token(device); |
| 284 | | device_image_interface *image = dynamic_cast<device_image_interface *>(device); |
| 285 | | void *result = NULL; |
| 286 | | |
| 287 | | if (cart->mc != NULL) |
| 288 | | { |
| 289 | | const multicart_socket *socket; |
| 290 | | for (socket = cart->mc->sockets; socket != NULL; socket = socket->next) |
| 291 | | { |
| 292 | | if (!strcmp(socket->id, socket_name)) |
| 293 | | break; |
| 294 | | } |
| 295 | | result = socket ? socket->ptr : NULL; |
| 296 | | } |
| 297 | | else if (socket_name[0] == '\0') |
| 298 | | { |
| 299 | | result = image->ptr(); |
| 300 | | } |
| 301 | | return result; |
| 302 | 154 | } |
| 303 | 155 | |
| 304 | | /*------------------------------------------------- |
| 305 | | cartslot_get_resource_length |
| 306 | | -------------------------------------------------*/ |
| 307 | | |
| 308 | | int cartslot_get_resource_length(device_t *device, const char *socket_name) |
| 156 | cartridge_pcb_superspace_device::cartridge_pcb_superspace_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 157 | : cartridge_pcb_device(mconfig, TICARTPCBMIN, "SuperSpace II cartridge PCB", tag, owner, clock) |
| 309 | 158 | { |
| 310 | | multicartslot_t *cart = get_token(device); |
| 311 | | int result = 0; |
| 312 | | |
| 313 | | if (cart->mc != NULL) |
| 314 | | { |
| 315 | | const multicart_socket *socket; |
| 316 | | |
| 317 | | for (socket = cart->mc->sockets; socket != NULL; socket = socket->next) |
| 318 | | { |
| 319 | | if (!strcmp(socket->id, socket_name)) { |
| 320 | | break; |
| 321 | | } |
| 322 | | } |
| 323 | | if (socket != NULL) |
| 324 | | result = socket->resource->length; |
| 325 | | } |
| 326 | | else |
| 327 | | result = 0; |
| 328 | | |
| 329 | | return result; |
| 330 | 159 | } |
| 331 | | /*------------------------------------------------- |
| 332 | | identify_pcb |
| 333 | | -------------------------------------------------*/ |
| 334 | 160 | |
| 335 | | static const multicartslot_pcb_type *identify_pcb(device_image_interface &image) |
| 161 | cartridge_pcb_mbx_device::cartridge_pcb_mbx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 162 | : cartridge_pcb_device(mconfig, TICARTPCBMIN, "MBX cartridge PCB", tag, owner, clock) |
| 336 | 163 | { |
| 337 | | const multicartslot_config *config = get_config(&image.device()); |
| 338 | | astring pcb_name; |
| 339 | | const multicartslot_pcb_type *pcb_type = NULL; |
| 340 | | multicart_t *mc; |
| 341 | | int i; |
| 342 | | |
| 343 | | if (image.exists()) |
| 344 | | { |
| 345 | | /* try opening this as if it were a multicart */ |
| 346 | | multicart_open_error me = multicart_open(image.device().machine().options(), image.filename(), image.device().machine().system().name, MULTICART_FLAGS_DONT_LOAD_RESOURCES, &mc); |
| 347 | | if (me == MCERR_NONE) |
| 348 | | { |
| 349 | | /* this was a multicart - read from it */ |
| 350 | | pcb_name.cpy(mc->pcb_type); |
| 351 | | multicart_close(image.device().machine().options(), mc); |
| 352 | | } |
| 353 | | else |
| 354 | | { |
| 355 | | if (me != MCERR_NOT_MULTICART) |
| 356 | | fatalerror("multicart error: %s", multicart_error_text(me)); |
| 357 | | } |
| 358 | | |
| 359 | | /* look for PCB type with matching name */ |
| 360 | | for (i = 0; (i < ARRAY_LENGTH(config->pcb_types)) && (config->pcb_types[i].name != NULL); i++) |
| 361 | | { |
| 362 | | if ((config->pcb_types[i].name[0] == '\0') || !strcmp(pcb_name, config->pcb_types[i].name)) |
| 363 | | { |
| 364 | | pcb_type = &config->pcb_types[i]; |
| 365 | | break; |
| 366 | | } |
| 367 | | } |
| 368 | | |
| 369 | | /* check for unknown PCB type */ |
| 370 | | if ((mc != NULL) && (pcb_type == NULL)) |
| 371 | | fatalerror("Unknown PCB type \"%s\"", pcb_name.cstr()); |
| 372 | | } |
| 373 | | else |
| 374 | | { |
| 375 | | /* no device loaded; use the default */ |
| 376 | | pcb_type = (config->pcb_types[0].name != NULL) ? &config->pcb_types[0] : NULL; |
| 377 | | } |
| 378 | | return pcb_type; |
| 379 | 164 | } |
| 380 | 165 | |
| 381 | | /*------------------------------------------------- |
| 382 | | DEVICE_IMAGE_GET_DEVICES(cartslot) |
| 383 | | -------------------------------------------------*/ |
| 384 | | static DEVICE_IMAGE_GET_DEVICES(multicartslot) |
| 166 | cartridge_pcb_paged379i_device::cartridge_pcb_paged379i_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 167 | : cartridge_pcb_device(mconfig, TICARTPCBPGI, "Paged379i cartridge PCB", tag, owner, clock) |
| 385 | 168 | { |
| 386 | | const multicartslot_pcb_type *pcb_type; |
| 387 | | device_t *device = &image.device(); |
| 388 | | |
| 389 | | pcb_type = identify_pcb(image); |
| 390 | | if (pcb_type != NULL) |
| 391 | | { |
| 392 | | image_add_device_with_subdevices(device,pcb_type->devtype,TAG_PCB,0); |
| 393 | | } |
| 169 | m_rom_page = get_paged379i_bank(15); |
| 394 | 170 | } |
| 395 | 171 | |
| 396 | | |
| 397 | | /*------------------------------------------------- |
| 398 | | find_file |
| 399 | | -------------------------------------------------*/ |
| 400 | | |
| 401 | | static const zip_file_header *find_file(zip_file *zip, const char *filename) |
| 172 | cartridge_pcb_pagedcru_device::cartridge_pcb_pagedcru_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 173 | : cartridge_pcb_device(mconfig, TICARTPCBPGC, "PagedCRU cartridge PCB", tag, owner, clock) |
| 402 | 174 | { |
| 403 | | const zip_file_header *header; |
| 404 | | for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) |
| 405 | | { |
| 406 | | if (!core_stricmp(header->filename, filename)) |
| 407 | | return header; |
| 408 | | } |
| 409 | | return NULL; |
| 410 | 175 | } |
| 411 | 176 | |
| 412 | | static const zip_file_header *find_file_crc(zip_file *zip, const char *filename, UINT32 crc) |
| 177 | cartridge_pcb_gramkracker_device::cartridge_pcb_gramkracker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 178 | : cartridge_pcb_device(mconfig, TICARTPCBGRK, "GRAM Kracker cartridge PCB", tag, owner, clock) |
| 413 | 179 | { |
| 414 | | const zip_file_header *header; |
| 415 | | for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) |
| 416 | | { |
| 417 | | // if the CRC and name both match, we're good |
| 418 | | // if the CRC matches and the name doesn't, we're still good |
| 419 | | if ((!core_stricmp(header->filename, filename)) && (header->crc == crc)) |
| 420 | | { |
| 421 | | return header; |
| 422 | | } |
| 423 | | else if (header->crc == crc) |
| 424 | | { |
| 425 | | return header; |
| 426 | | } |
| 427 | | } |
| 428 | | return NULL; |
| 180 | m_grom_address = 0; // for the GROM emulation |
| 181 | for (int i=1; i < 6; i++) m_gk_switch[i] = 0; |
| 429 | 182 | } |
| 430 | 183 | |
| 431 | | /*------------------------------------------------- |
| 432 | | find_pcb_and_resource_nodes |
| 433 | | -------------------------------------------------*/ |
| 184 | /***************************************************************************** |
| 185 | Common methods. |
| 186 | ******************************************************************************/ |
| 434 | 187 | |
| 435 | | static int find_pcb_and_resource_nodes(xml_data_node *layout_xml, |
| 436 | | xml_data_node **pcb_node, xml_data_node **resource_node) |
| 437 | | { |
| 438 | | xml_data_node *romset_node; |
| 439 | | xml_data_node *configuration_node; |
| 188 | /* Read function for this cartridge, CRU. */ |
| 189 | void cartridge_pcb_device::crureadz(offs_t offset, UINT8 *value) { }; |
| 440 | 190 | |
| 441 | | *pcb_node = NULL; |
| 442 | | *resource_node = NULL; |
| 191 | /* Write function for this cartridge, CRU. */ |
| 192 | void cartridge_pcb_device::cruwrite(offs_t offset, UINT8 value) { }; |
| 443 | 193 | |
| 444 | | romset_node = xml_get_sibling(layout_xml->child, "romset"); |
| 445 | | if (romset_node == NULL) |
| 446 | | return FALSE; |
| 447 | | |
| 448 | | configuration_node = xml_get_sibling(romset_node->child, "configuration"); |
| 449 | | if (configuration_node == NULL) |
| 450 | | return FALSE; |
| 451 | | |
| 452 | | *pcb_node = xml_get_sibling(configuration_node->child, "pcb"); |
| 453 | | if (*pcb_node == NULL) |
| 454 | | return FALSE; |
| 455 | | |
| 456 | | *resource_node = xml_get_sibling(romset_node->child, "resources"); |
| 457 | | if (*resource_node == NULL) |
| 458 | | return FALSE; |
| 459 | | |
| 460 | | return TRUE; |
| 461 | | } |
| 462 | | |
| 463 | | |
| 464 | | /*------------------------------------------------- |
| 465 | | get_resource_type |
| 466 | | -------------------------------------------------*/ |
| 467 | | |
| 468 | | static multicart_resource_type get_resource_type(const char *s) |
| 194 | READ8Z_MEMBER( cartridge_pcb_device::gromreadz ) |
| 469 | 195 | { |
| 470 | | multicart_resource_type result; |
| 471 | | if (!strcmp(s, "rom")) |
| 472 | | result = MULTICART_RESOURCE_TYPE_ROM; |
| 473 | | else if (!strcmp(s, "ram")) |
| 474 | | result = MULTICART_RESOURCE_TYPE_RAM; |
| 475 | | else |
| 476 | | result = MULTICART_RESOURCE_TYPE_INVALID; |
| 477 | | return result; |
| 478 | | } |
| 479 | | |
| 480 | | |
| 481 | | /*------------------------------------------------- |
| 482 | | load_rom_resource |
| 483 | | -------------------------------------------------*/ |
| 484 | | |
| 485 | | static multicart_open_error load_rom_resource(multicart_load_state *state, xml_data_node *resource_node, |
| 486 | | multicart_resource *resource) |
| 487 | | { |
| 488 | | const char *file, *crcstr, *sha1; |
| 489 | | const zip_file_header *header; |
| 490 | | zip_error ziperr; |
| 491 | | UINT32 crc; |
| 492 | | |
| 493 | | /* locate the 'file' attribute */ |
| 494 | | file = xml_get_attribute_string(resource_node, "file", NULL); |
| 495 | | if (file == NULL) |
| 496 | | return MCERR_XML_ERROR; |
| 497 | | |
| 498 | | if (!(crcstr = xml_get_attribute_string(resource_node, "crc", NULL))) |
| 196 | for (int i=0; i < 5; i++) |
| 499 | 197 | { |
| 500 | | /* locate the file in the ZIP file */ |
| 501 | | header = find_file(state->zip, file); |
| 502 | | } |
| 503 | | else /* CRC tag is present, use it */ |
| 504 | | { |
| 505 | | crc = strtoul(crcstr, NULL, 16); |
| 506 | | header = find_file_crc(state->zip, file, crc); |
| 507 | | } |
| 508 | | if (header == NULL) |
| 509 | | return MCERR_INVALID_FILE_REF; |
| 510 | | resource->length = header->uncompressed_length; |
| 511 | | |
| 512 | | /* allocate bytes for this resource */ |
| 513 | | resource->ptr = pool_malloc_lib(state->multicart->data->pool, resource->length); |
| 514 | | if (resource->ptr == NULL) |
| 515 | | return MCERR_OUT_OF_MEMORY; |
| 516 | | |
| 517 | | /* and decompress it */ |
| 518 | | ziperr = zip_file_decompress(state->zip, resource->ptr, resource->length); |
| 519 | | if (ziperr != ZIPERR_NONE) |
| 520 | | return MCERR_ZIP_ERROR; |
| 521 | | |
| 522 | | /* check SHA1 now */ |
| 523 | | if ((sha1 = xml_get_attribute_string(resource_node, "sha1", NULL))) |
| 524 | | { |
| 525 | | hash_collection actual_hashes; |
| 526 | | actual_hashes.compute((const UINT8 *)resource->ptr, resource->length, hash_collection::HASH_TYPES_CRC_SHA1); |
| 527 | | |
| 528 | | hash_collection expected_hashes; |
| 529 | | expected_hashes.add_from_string(hash_collection::HASH_SHA1, sha1, strlen(sha1)); |
| 530 | | |
| 531 | | if (actual_hashes != expected_hashes) |
| 198 | if (m_grom[i] != NULL) |
| 532 | 199 | { |
| 533 | | return MCERR_INVALID_FILE_REF; |
| 200 | m_grom[i]->readz(space, offset, value, mem_mask); |
| 534 | 201 | } |
| 535 | 202 | } |
| 536 | | |
| 537 | | return MCERR_NONE; |
| 538 | 203 | } |
| 539 | 204 | |
| 540 | | |
| 541 | | /*------------------------------------------------- |
| 542 | | load_ram_resource |
| 543 | | -------------------------------------------------*/ |
| 544 | | |
| 545 | | static multicart_open_error load_ram_resource(emu_options &options, multicart_load_state *state, xml_data_node *resource_node, |
| 546 | | multicart_resource *resource) |
| 205 | WRITE8_MEMBER( cartridge_pcb_device::gromwrite ) |
| 547 | 206 | { |
| 548 | | const char *length_string; |
| 549 | | const char *ram_type; |
| 550 | | const char *ram_filename; |
| 551 | | |
| 552 | | /* locate the 'length' attribute */ |
| 553 | | length_string = xml_get_attribute_string(resource_node, "length", NULL); |
| 554 | | if (length_string == NULL) |
| 555 | | return MCERR_MISSING_RAM_LENGTH; |
| 556 | | |
| 557 | | /* ...and parse it */ |
| 558 | | resource->length = ram_device::parse_string(length_string); |
| 559 | | if (resource->length <= 0) |
| 560 | | return MCERR_INVALID_RAM_SPEC; |
| 561 | | |
| 562 | | /* allocate bytes for this resource */ |
| 563 | | resource->ptr = pool_malloc_lib(state->multicart->data->pool, resource->length); |
| 564 | | if (resource->ptr == NULL) |
| 565 | | return MCERR_OUT_OF_MEMORY; |
| 566 | | |
| 567 | | /* Is this a persistent RAM resource? Then try to load it. */ |
| 568 | | ram_type = xml_get_attribute_string(resource_node, "type", NULL); |
| 569 | | if (ram_type != NULL) |
| 207 | for (int i=0; i < 5; i++) |
| 570 | 208 | { |
| 571 | | if (strcmp(ram_type, "persistent")==0) |
| 209 | if (m_grom[i] != NULL) |
| 572 | 210 | { |
| 573 | | astring tmp; |
| 574 | | |
| 575 | | /* Get the file name. */ |
| 576 | | ram_filename = xml_get_attribute_string(resource_node, "file", NULL); |
| 577 | | if (ram_filename==NULL) |
| 578 | | return MCERR_XML_ERROR; |
| 579 | | |
| 580 | | astring ram_pathname(state->multicart->gamedrv_name, PATH_SEPARATOR, ram_filename); |
| 581 | | |
| 582 | | /* Save the file name so that we can write the contents on unloading. |
| 583 | | If the RAM resource has no filename, we know that it was volatile only. */ |
| 584 | | resource->filename = pool_strdup_lib(state->multicart->data->pool, ram_pathname.cstr()); |
| 585 | | |
| 586 | | if (resource->filename == NULL) |
| 587 | | return MCERR_OUT_OF_MEMORY; |
| 588 | | |
| 589 | | image_battery_load_by_name(options, resource->filename, resource->ptr, resource->length, 0x00); |
| 211 | m_grom[i]->write(space, offset, data, mem_mask); |
| 590 | 212 | } |
| 591 | | /* else this type is volatile, in which case we just have |
| 592 | | a memory expansion */ |
| 593 | 213 | } |
| 594 | | return MCERR_NONE; |
| 595 | 214 | } |
| 596 | 215 | |
| 597 | | |
| 598 | | /*------------------------------------------------- |
| 599 | | load_resource |
| 600 | | -------------------------------------------------*/ |
| 601 | | |
| 602 | | static multicart_open_error load_resource(emu_options &options, multicart_load_state *state, xml_data_node *resource_node, |
| 603 | | multicart_resource_type resource_type) |
| 604 | | { |
| 605 | | const char *id; |
| 606 | | multicart_open_error err; |
| 607 | | multicart_resource *resource; |
| 608 | | multicart_resource **next_resource; |
| 609 | | |
| 610 | | /* get the 'id' attribute; error if not present */ |
| 611 | | id = xml_get_attribute_string(resource_node, "id", NULL); |
| 612 | | if (id == NULL) |
| 613 | | return MCERR_XML_ERROR; |
| 614 | | |
| 615 | | /* allocate memory for the resource */ |
| 616 | | resource = (multicart_resource *)pool_malloc_lib(state->multicart->data->pool, sizeof(*resource)); |
| 617 | | if (resource == NULL) |
| 618 | | return MCERR_OUT_OF_MEMORY; |
| 619 | | memset(resource, 0, sizeof(*resource)); |
| 620 | | resource->type = resource_type; |
| 621 | | |
| 622 | | /* copy id */ |
| 623 | | resource->id = pool_strdup_lib(state->multicart->data->pool, id); |
| 624 | | if (resource->id == NULL) |
| 625 | | return MCERR_OUT_OF_MEMORY; |
| 626 | | |
| 627 | | switch(resource->type) |
| 628 | | { |
| 629 | | case MULTICART_RESOURCE_TYPE_ROM: |
| 630 | | err = load_rom_resource(state, resource_node, resource); |
| 631 | | if (err != MCERR_NONE) |
| 632 | | return err; |
| 633 | | break; |
| 634 | | |
| 635 | | case MULTICART_RESOURCE_TYPE_RAM: |
| 636 | | err = load_ram_resource(options, state, resource_node, resource); |
| 637 | | if (err != MCERR_NONE) |
| 638 | | return err; |
| 639 | | break; |
| 640 | | |
| 641 | | default: |
| 642 | | return MCERR_UNKNOWN_RESOURCE_TYPE; |
| 643 | | } |
| 644 | | |
| 645 | | /* append the resource */ |
| 646 | | for (next_resource = &state->resources; *next_resource; next_resource = &(*next_resource)->next) |
| 647 | | ; |
| 648 | | *next_resource = resource; |
| 649 | | |
| 650 | | return MCERR_NONE; |
| 651 | | } |
| 652 | | |
| 653 | | |
| 654 | | /*------------------------------------------------- |
| 655 | | load_all_resources |
| 656 | | -------------------------------------------------*/ |
| 657 | | |
| 658 | | static multicart_open_error load_all_resources(emu_options &options, multicart_load_state *state) |
| 659 | | { |
| 660 | | multicart_open_error err; |
| 661 | | xml_data_node *resource_node; |
| 662 | | multicart_resource_type resource_type; |
| 663 | | |
| 664 | | for (resource_node = state->resources_node->child; resource_node != NULL; resource_node = resource_node->next) |
| 665 | | { |
| 666 | | resource_type = get_resource_type(resource_node->name); |
| 667 | | if (resource_type != MULTICART_RESOURCE_TYPE_INVALID) |
| 668 | | { |
| 669 | | err = load_resource(options, state, resource_node, resource_type); |
| 670 | | if (err != MCERR_NONE) |
| 671 | | return err; |
| 672 | | } |
| 673 | | } |
| 674 | | |
| 675 | | state->multicart->resources = state->resources; |
| 676 | | return MCERR_NONE; |
| 677 | | } |
| 678 | | |
| 679 | | /*------------------------------------------------- |
| 680 | | save_ram_resources. This is important for persistent RAM. All |
| 681 | | resources were allocated within the memory pool of this device and will |
| 682 | | be freed on multicart_close. |
| 683 | | -------------------------------------------------*/ |
| 684 | | |
| 685 | | static multicart_open_error save_ram_resources(emu_options &options, multicart_t *cart) |
| 686 | | { |
| 687 | | const multicart_resource *resource; |
| 688 | | |
| 689 | | for (resource = cart->resources; resource != NULL; resource = resource->next) |
| 690 | | { |
| 691 | | if ((resource->type == MULTICART_RESOURCE_TYPE_RAM) && (resource->filename != NULL)) |
| 692 | | { |
| 693 | | image_battery_save_by_name(options, resource->filename, resource->ptr, resource->length); |
| 694 | | } |
| 695 | | } |
| 696 | | return MCERR_NONE; |
| 697 | | } |
| 698 | | |
| 699 | | /*------------------------------------------------- |
| 700 | | load_socket |
| 701 | | -------------------------------------------------*/ |
| 702 | | |
| 703 | | static multicart_open_error load_socket(multicart_load_state *state, xml_data_node *socket_node) |
| 704 | | { |
| 705 | | const char *id; |
| 706 | | const char *uses; |
| 707 | | const multicart_resource *resource; |
| 708 | | multicart_socket *socket; |
| 709 | | multicart_socket **next_socket; |
| 710 | | |
| 711 | | /* get the 'id' and 'uses' attributes; error if not present */ |
| 712 | | id = xml_get_attribute_string(socket_node, "id", NULL); |
| 713 | | uses = xml_get_attribute_string(socket_node, "uses", NULL); |
| 714 | | if ((id == NULL) || (uses == NULL)) |
| 715 | | return MCERR_XML_ERROR; |
| 716 | | |
| 717 | | /* find the resource */ |
| 718 | | for (resource = state->multicart->resources; resource != NULL; resource = resource->next) |
| 719 | | { |
| 720 | | if (!strcmp(uses, resource->id)) |
| 721 | | break; |
| 722 | | } |
| 723 | | if (resource == NULL) |
| 724 | | return MCERR_INVALID_RESOURCE_REF; |
| 725 | | |
| 726 | | /* create the socket */ |
| 727 | | socket = (multicart_socket *)pool_malloc_lib(state->multicart->data->pool, sizeof(*socket)); |
| 728 | | if (socket == NULL) |
| 729 | | return MCERR_OUT_OF_MEMORY; |
| 730 | | memset(socket, 0, sizeof(*socket)); |
| 731 | | socket->resource = resource; |
| 732 | | socket->ptr = resource->ptr; |
| 733 | | |
| 734 | | /* copy id */ |
| 735 | | socket->id = pool_strdup_lib(state->multicart->data->pool, id); |
| 736 | | if (socket->id == NULL) |
| 737 | | return MCERR_OUT_OF_MEMORY; |
| 738 | | |
| 739 | | /* which pointer should I use? */ |
| 740 | | if (resource->ptr != NULL) |
| 741 | | { |
| 742 | | /* use the resource's ptr */ |
| 743 | | socket->ptr = resource->ptr; |
| 744 | | } |
| 745 | | else |
| 746 | | { |
| 747 | | /* allocate bytes for this socket */ |
| 748 | | socket->ptr = pool_malloc_lib(state->multicart->data->pool, resource->length); |
| 749 | | if (socket->ptr == NULL) |
| 750 | | return MCERR_OUT_OF_MEMORY; |
| 751 | | |
| 752 | | /* ...and clear it */ |
| 753 | | memset(socket->ptr, 0xCD, resource->length); |
| 754 | | } |
| 755 | | |
| 756 | | /* append the resource */ |
| 757 | | for (next_socket = &state->sockets; *next_socket; next_socket = &(*next_socket)->next) |
| 758 | | ; |
| 759 | | *next_socket = socket; |
| 760 | | |
| 761 | | return MCERR_NONE; |
| 762 | | } |
| 763 | | |
| 764 | | |
| 765 | | /*------------------------------------------------- |
| 766 | | load_all_sockets |
| 767 | | -------------------------------------------------*/ |
| 768 | | |
| 769 | | static multicart_open_error load_all_sockets(multicart_load_state *state) |
| 770 | | { |
| 771 | | multicart_open_error err; |
| 772 | | xml_data_node *socket_node; |
| 773 | | |
| 774 | | for (socket_node = xml_get_sibling(state->pcb_node->child, "socket"); socket_node != NULL; |
| 775 | | socket_node = xml_get_sibling(socket_node->next, "socket")) |
| 776 | | { |
| 777 | | err = load_socket(state, socket_node); |
| 778 | | if (err != MCERR_NONE) |
| 779 | | return err; |
| 780 | | } |
| 781 | | |
| 782 | | state->multicart->sockets = state->sockets; |
| 783 | | return MCERR_NONE; |
| 784 | | } |
| 785 | | |
| 786 | | |
| 787 | | /*------------------------------------------------- |
| 788 | | multicart_open - opens a multicart |
| 789 | | -------------------------------------------------*/ |
| 790 | | |
| 791 | | multicart_open_error multicart_open(emu_options &options, const char *filename, const char *gamedrv, multicart_load_flags load_flags, multicart_t **cart) |
| 792 | | { |
| 793 | | multicart_open_error err; |
| 794 | | zip_error ziperr; |
| 795 | | object_pool *pool; |
| 796 | | multicart_load_state state = {0, }; |
| 797 | | const zip_file_header *header; |
| 798 | | const char *pcb_type; |
| 799 | | char *layout_text = NULL; |
| 800 | | |
| 801 | | /* allocate an object pool */ |
| 802 | | pool = pool_alloc_lib(NULL); |
| 803 | | if (pool == NULL) |
| 804 | | { |
| 805 | | err = MCERR_OUT_OF_MEMORY; |
| 806 | | goto done; |
| 807 | | } |
| 808 | | |
| 809 | | /* allocate the multicart */ |
| 810 | | state.multicart = (multicart_t*)pool_malloc_lib(pool, sizeof(*state.multicart)); |
| 811 | | if (state.multicart == NULL) |
| 812 | | { |
| 813 | | err = MCERR_OUT_OF_MEMORY; |
| 814 | | goto done; |
| 815 | | } |
| 816 | | memset(state.multicart, 0, sizeof(*state.multicart)); |
| 817 | | |
| 818 | | /* allocate the multicart's private data */ |
| 819 | | state.multicart->data = (multicart_private*)pool_malloc_lib(pool, sizeof(*state.multicart->data)); |
| 820 | | if (state.multicart->data == NULL) |
| 821 | | { |
| 822 | | err = MCERR_OUT_OF_MEMORY; |
| 823 | | goto done; |
| 824 | | } |
| 825 | | memset(state.multicart->data, 0, sizeof(*state.multicart->data)); |
| 826 | | state.multicart->data->pool = pool; |
| 827 | | pool = NULL; |
| 828 | | |
| 829 | | /* open the ZIP file */ |
| 830 | | ziperr = zip_file_open(filename, &state.zip); |
| 831 | | if (ziperr != ZIPERR_NONE) |
| 832 | | { |
| 833 | | err = MCERR_NOT_MULTICART; |
| 834 | | goto done; |
| 835 | | } |
| 836 | | |
| 837 | | /* find the layout.xml file */ |
| 838 | | header = find_file(state.zip, "layout.xml"); |
| 839 | | if (header == NULL) |
| 840 | | { |
| 841 | | err = MCERR_MISSING_LAYOUT; |
| 842 | | goto done; |
| 843 | | } |
| 844 | | |
| 845 | | /* reserve space for the layout text */ |
| 846 | | layout_text = (char*)malloc(header->uncompressed_length + 1); |
| 847 | | if (layout_text == NULL) |
| 848 | | { |
| 849 | | err = MCERR_OUT_OF_MEMORY; |
| 850 | | goto done; |
| 851 | | } |
| 852 | | |
| 853 | | /* uncompress the layout text */ |
| 854 | | ziperr = zip_file_decompress(state.zip, layout_text, header->uncompressed_length); |
| 855 | | if (ziperr != ZIPERR_NONE) |
| 856 | | { |
| 857 | | err = MCERR_ZIP_ERROR; |
| 858 | | goto done; |
| 859 | | } |
| 860 | | layout_text[header->uncompressed_length] = '\0'; |
| 861 | | |
| 862 | | /* parse the layout text */ |
| 863 | | state.layout_xml = xml_string_read(layout_text, NULL); |
| 864 | | if (state.layout_xml == NULL) |
| 865 | | { |
| 866 | | err = MCERR_XML_ERROR; |
| 867 | | goto done; |
| 868 | | } |
| 869 | | |
| 870 | | /* locate the PCB node */ |
| 871 | | if (!find_pcb_and_resource_nodes(state.layout_xml, &state.pcb_node, &state.resources_node)) |
| 872 | | { |
| 873 | | err = MCERR_NO_PCB_OR_RESOURCES; |
| 874 | | goto done; |
| 875 | | } |
| 876 | | |
| 877 | | /* get the PCB resource_type */ |
| 878 | | pcb_type = xml_get_attribute_string(state.pcb_node, "type", ""); |
| 879 | | state.multicart->pcb_type = pool_strdup_lib(state.multicart->data->pool, pcb_type); |
| 880 | | if (state.multicart->pcb_type == NULL) |
| 881 | | { |
| 882 | | err = MCERR_OUT_OF_MEMORY; |
| 883 | | goto done; |
| 884 | | } |
| 885 | | |
| 886 | | state.multicart->gamedrv_name = pool_strdup_lib(state.multicart->data->pool, gamedrv); |
| 887 | | if (state.multicart->gamedrv_name == NULL) |
| 888 | | { |
| 889 | | err = MCERR_OUT_OF_MEMORY; |
| 890 | | goto done; |
| 891 | | } |
| 892 | | |
| 893 | | /* do we have to load resources? */ |
| 894 | | if (load_flags & MULTICART_FLAGS_LOAD_RESOURCES) |
| 895 | | { |
| 896 | | err = load_all_resources(options, &state); |
| 897 | | if (err != MCERR_NONE) |
| 898 | | goto done; |
| 899 | | |
| 900 | | err = load_all_sockets(&state); |
| 901 | | if (err != MCERR_NONE) |
| 902 | | goto done; |
| 903 | | } |
| 904 | | |
| 905 | | err = MCERR_NONE; |
| 906 | | |
| 907 | | done: |
| 908 | | if (pool != NULL) |
| 909 | | pool_free_lib(pool); |
| 910 | | if (state.zip != NULL) |
| 911 | | zip_file_close(state.zip); |
| 912 | | if (layout_text != NULL) |
| 913 | | free(layout_text); |
| 914 | | if (state.layout_xml != NULL) |
| 915 | | xml_file_free(state.layout_xml); |
| 916 | | |
| 917 | | if ((err != MCERR_NONE) && (state.multicart != NULL)) |
| 918 | | { |
| 919 | | multicart_close(options, state.multicart); |
| 920 | | state.multicart = NULL; |
| 921 | | } |
| 922 | | *cart = state.multicart; |
| 923 | | return err; |
| 924 | | } |
| 925 | | |
| 926 | | |
| 927 | | /*------------------------------------------------- |
| 928 | | multicart_close - closes a multicart |
| 929 | | -------------------------------------------------*/ |
| 930 | | |
| 931 | | void multicart_close(emu_options &options, multicart_t *cart) |
| 932 | | { |
| 933 | | save_ram_resources(options, cart); |
| 934 | | pool_free_lib(cart->data->pool); |
| 935 | | } |
| 936 | | |
| 937 | | /*------------------------------------------------- |
| 938 | | DEVICE_START( multicartslot ) |
| 939 | | -------------------------------------------------*/ |
| 940 | | |
| 941 | | static DEVICE_START( multicartslot ) |
| 942 | | { |
| 943 | | const multicartslot_config *config = get_config(device); |
| 944 | | |
| 945 | | /* if this cartridge has a custom DEVICE_START, use it */ |
| 946 | | if (config->device_start != NULL) |
| 947 | | { |
| 948 | | (*config->device_start)(device); |
| 949 | | } |
| 950 | | } |
| 951 | | |
| 952 | | |
| 953 | | /*------------------------------------------------- |
| 954 | | DEVICE_IMAGE_LOAD( cartslot ) |
| 955 | | -------------------------------------------------*/ |
| 956 | | |
| 957 | | static DEVICE_IMAGE_LOAD( multicartslot ) |
| 958 | | { |
| 959 | | device_t *device = &image.device(); |
| 960 | | const multicartslot_config *config = get_config(device); |
| 961 | | |
| 962 | | /* if this cartridge has a custom DEVICE_IMAGE_LOAD, use it */ |
| 963 | | if (config->device_load != NULL) |
| 964 | | return (*config->device_load)(image); |
| 965 | | |
| 966 | | /* otherwise try the normal route */ |
| 967 | | return IMAGE_INIT_PASS; |
| 968 | | } |
| 969 | | |
| 970 | | |
| 971 | | /*------------------------------------------------- |
| 972 | | DEVICE_IMAGE_UNLOAD( multicartslot ) |
| 973 | | -------------------------------------------------*/ |
| 974 | | |
| 975 | | static DEVICE_IMAGE_UNLOAD( multicartslot ) |
| 976 | | { |
| 977 | | device_t *device = &image.device(); |
| 978 | | const multicartslot_config *config = get_config(device); |
| 979 | | |
| 980 | | /* if this cartridge has a custom DEVICE_IMAGE_UNLOAD, use it */ |
| 981 | | if (config->device_unload != NULL) |
| 982 | | { |
| 983 | | (*config->device_unload)(image); |
| 984 | | return; |
| 985 | | } |
| 986 | | } |
| 987 | | /*------------------------------------------------- |
| 988 | | DEVICE_GET_INFO( multicartslot ) |
| 989 | | -------------------------------------------------*/ |
| 990 | | |
| 991 | | DEVICE_GET_INFO( multicartslot ) |
| 992 | | { |
| 993 | | switch(state) |
| 994 | | { |
| 995 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 996 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(multicartslot_t); break; |
| 997 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(multicartslot_config); break; |
| 998 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_CARTSLOT; break; |
| 999 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1000 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 0; break; |
| 1001 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 0; break; |
| 1002 | | case DEVINFO_INT_IMAGE_RESET_ON_LOAD: info->i = 1; break; |
| 1003 | | case DEVINFO_INT_IMAGE_MUST_BE_LOADED: info->i = 0; break; |
| 1004 | | |
| 1005 | | /* --- the following bits of info are returned as pointers to functions --- */ |
| 1006 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(multicartslot); break; |
| 1007 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(multicartslot); break; |
| 1008 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(multicartslot); break; |
| 1009 | | case DEVINFO_FCT_IMAGE_GET_DEVICES: info->f = (genf *) DEVICE_IMAGE_GET_DEVICES_NAME(multicartslot); break; |
| 1010 | | |
| 1011 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1012 | | case DEVINFO_STR_NAME: strcpy(info->s, "MultiCartslot"); break; |
| 1013 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "MultiCartslot"); break; |
| 1014 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1015 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: |
| 1016 | | if ( device && downcast<const legacy_image_device_base *>(device)->inline_config() && get_config(device)->extensions ) |
| 1017 | | { |
| 1018 | | strcpy(info->s, get_config(device)->extensions); |
| 1019 | | } |
| 1020 | | else |
| 1021 | | { |
| 1022 | | strcpy(info->s, "bin"); |
| 1023 | | } |
| 1024 | | break; |
| 1025 | | } |
| 1026 | | } |
| 1027 | | |
| 1028 | | DEFINE_LEGACY_IMAGE_DEVICE(MULTICARTSLOT, multicartslot); |
| 1029 | | |
| 1030 | | //************************************************************************** |
| 1031 | | // DEVICE CARTSLOT INTERFACE |
| 1032 | | //************************************************************************** |
| 1033 | | |
| 1034 | | //------------------------------------------------- |
| 1035 | | // device_cart_slot_interface - constructor |
| 1036 | | //------------------------------------------------- |
| 1037 | | |
| 1038 | | device_cart_slot_interface::device_cart_slot_interface(const machine_config &mconfig, device_t &device) |
| 1039 | | : device_interface(device) |
| 1040 | | { |
| 1041 | | } |
| 1042 | | |
| 1043 | | |
| 1044 | | //------------------------------------------------- |
| 1045 | | // ~device_cart_slot_interface - destructor |
| 1046 | | //------------------------------------------------- |
| 1047 | | |
| 1048 | | device_cart_slot_interface::~device_cart_slot_interface() |
| 1049 | | { |
| 1050 | | } |
| 1051 | | |
| 1052 | | //************************************************************************** |
| 1053 | | // LIVE LEGACY cart_slot DEVICE |
| 1054 | | //************************************************************************** |
| 1055 | | |
| 1056 | | //------------------------------------------------- |
| 1057 | | // legacy_cart_slot_device_base - constructor |
| 1058 | | //------------------------------------------------- |
| 1059 | | |
| 1060 | | legacy_cart_slot_device_base::legacy_cart_slot_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config) |
| 1061 | | : legacy_device_base(mconfig, type, tag, owner, clock, get_config), |
| 1062 | | device_cart_slot_interface(mconfig, *this) |
| 1063 | | { |
| 1064 | | } |
| 1065 | | |
| 1066 | | /* end of multicart */ |
| 1067 | | typedef UINT8 (*read8z_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, UINT8 *value); |
| 1068 | | |
| 1069 | | /* We set the number of slots to 8, although we may have up to 16. From a |
| 1070 | | logical point of view we could have 256, but the operating system only checks |
| 1071 | | the first 16 banks. */ |
| 1072 | | #define NUMBER_OF_CARTRIDGE_SLOTS 8 |
| 1073 | | |
| 1074 | | #define VERBOSE 2 |
| 1075 | | #define LOG logerror |
| 1076 | | |
| 1077 | | typedef int assmfct(device_t *); |
| 1078 | | |
| 1079 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_NONE, ti99_cartridge_pcb_none); |
| 1080 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_STD, ti99_cartridge_pcb_std); |
| 1081 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGED, ti99_cartridge_pcb_paged); |
| 1082 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_MINIMEM, ti99_cartridge_pcb_minimem); |
| 1083 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_SUPER, ti99_cartridge_pcb_super); |
| 1084 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_MBX, ti99_cartridge_pcb_mbx); |
| 1085 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGED379I, ti99_cartridge_pcb_paged379i); |
| 1086 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGEDCRU, ti99_cartridge_pcb_pagedcru); |
| 1087 | | DECLARE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_GRAMKRACKER, ti99_cartridge_pcb_gramkracker); |
| 1088 | | |
| 1089 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_NONE, ti99_cartridge_pcb_none); |
| 1090 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_STD, ti99_cartridge_pcb_std); |
| 1091 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGED, ti99_cartridge_pcb_paged); |
| 1092 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_MINIMEM, ti99_cartridge_pcb_minimem); |
| 1093 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_SUPER, ti99_cartridge_pcb_super); |
| 1094 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_MBX, ti99_cartridge_pcb_mbx); |
| 1095 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGED379I, ti99_cartridge_pcb_paged379i); |
| 1096 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_PAGEDCRU, ti99_cartridge_pcb_pagedcru); |
| 1097 | | DEFINE_LEGACY_CART_SLOT_DEVICE(TI99_CARTRIDGE_PCB_GRAMKRACKER, ti99_cartridge_pcb_gramkracker); |
| 1098 | | |
| 1099 | | /* Generic TI99 cartridge structure. */ |
| 1100 | | struct _cartridge_t |
| 1101 | | { |
| 1102 | | // PCB device associated to this cartridge. If NULL, the slot is empty. |
| 1103 | | device_t *pcb; |
| 1104 | | |
| 1105 | | // ROM page. |
| 1106 | | int rom_page; |
| 1107 | | |
| 1108 | | // RAM page. |
| 1109 | | int ram_page; |
| 1110 | | |
| 1111 | | // GROM buffer size. |
| 1112 | | int grom_size; |
| 1113 | | |
| 1114 | | // ROM buffer size. All banks have equal sizes. |
| 1115 | | int rom_size; |
| 1116 | | |
| 1117 | | // RAM buffer size. All banks have equal sizes. |
| 1118 | | int ram_size; |
| 1119 | | |
| 1120 | | // GROM buffer. |
| 1121 | | UINT8 *grom_ptr; |
| 1122 | | |
| 1123 | | // ROM buffer. |
| 1124 | | UINT8 *rom_ptr; |
| 1125 | | |
| 1126 | | // ROM buffer for the second bank of paged cartridges. |
| 1127 | | UINT8 *rom2_ptr; |
| 1128 | | |
| 1129 | | // RAM buffer. The persistence service is done by the cartridge system. |
| 1130 | | // The RAM space is a consecutive space; all banks are in one buffer. |
| 1131 | | UINT8 *ram_ptr; |
| 1132 | | |
| 1133 | | /* GK support. */ |
| 1134 | | UINT16 grom_address; |
| 1135 | | int waddr_LSB; |
| 1136 | | }; |
| 1137 | | typedef struct _cartridge_t cartridge_t; |
| 1138 | | |
| 1139 | | enum |
| 1140 | | { |
| 1141 | | TI99CARTINFO_FCT_6000_R = DEVINFO_FCT_DEVICE_SPECIFIC, |
| 1142 | | TI99CARTINFO_FCT_6000_W, |
| 1143 | | TI99CARTINFO_FCT_CRU_R, |
| 1144 | | TI99CARTINFO_FCT_CRU_W, |
| 1145 | | TI99CART_FCT_ASSM, |
| 1146 | | TI99CART_FCT_DISASSM |
| 1147 | | }; |
| 1148 | | |
| 1149 | | typedef struct _ti99_multicart_state |
| 1150 | | { |
| 1151 | | // Reserves space for all cartridges. This is also used in the legacy |
| 1152 | | // cartridge system, but only for slot 0. |
| 1153 | | cartridge_t cartridge[NUMBER_OF_CARTRIDGE_SLOTS]; |
| 1154 | | |
| 1155 | | // Determines which slot is currently active. This value is changed when |
| 1156 | | // there are accesses to other GROM base addresses. |
| 1157 | | int active_slot; |
| 1158 | | |
| 1159 | | // Used in order to enforce a special slot. This value is retrieved |
| 1160 | | // from the dipswitch setting. A value of -1 means automatic, that is, |
| 1161 | | // the grom base switch is used. Values 0 .. max refer to the |
| 1162 | | // respective slot. |
| 1163 | | int fixed_slot; |
| 1164 | | |
| 1165 | | // Holds the highest index of a cartridge being plugged in plus one. |
| 1166 | | // If we only have one cartridge inserted, we don't want to get a |
| 1167 | | // selection option, so we just mirror the memory contents. |
| 1168 | | int next_free_slot; |
| 1169 | | |
| 1170 | | /* GK support. */ |
| 1171 | | int gk_slot; |
| 1172 | | int gk_guest_slot; |
| 1173 | | |
| 1174 | | /* Used to cache the switch settings. */ |
| 1175 | | UINT8 gk_switch[8]; |
| 1176 | | |
| 1177 | | /* Ready line */ |
| 1178 | | devcb_resolved_write_line ready; |
| 1179 | | |
| 1180 | | } ti99_multicart_state; |
| 1181 | | |
| 1182 | | #define AUTO -1 |
| 1183 | | |
| 1184 | | /* Access to the pcb. Contained in the token of the pcb instance. */ |
| 1185 | | struct _ti99_pcb_t |
| 1186 | | { |
| 1187 | | /* Read function for this cartridge. */ |
| 1188 | | read8z_device_func read; |
| 1189 | | |
| 1190 | | /* Write function for this cartridge. */ |
| 1191 | | write8_device_func write; |
| 1192 | | |
| 1193 | | /* Read function for this cartridge, CRU. */ |
| 1194 | | read8z_device_func cruread; |
| 1195 | | |
| 1196 | | /* Write function for this cartridge, CRU. */ |
| 1197 | | write8_device_func cruwrite; |
| 1198 | | |
| 1199 | | /* Link up to the cartridge structure which contains this pcb. */ |
| 1200 | | cartridge_t *cartridge; |
| 1201 | | |
| 1202 | | /* Function to assemble this cartridge. */ |
| 1203 | | assmfct *assemble; |
| 1204 | | |
| 1205 | | /* Function to disassemble this cartridge. */ |
| 1206 | | assmfct *disassemble; |
| 1207 | | |
| 1208 | | /* Points to the (max 5) GROM devices. */ |
| 1209 | | device_t *grom[5]; |
| 1210 | | }; |
| 1211 | | typedef struct _ti99_pcb_t ti99_pcb_t; |
| 1212 | | |
| 1213 | | INLINE ti99_multicart_state *get_safe_token(device_t *device) |
| 1214 | | { |
| 1215 | | assert(device != NULL); |
| 1216 | | assert(device->type() == TI99_MULTICART); |
| 1217 | | |
| 1218 | | return (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 1219 | | } |
| 1220 | | |
| 1221 | | INLINE const ti99_multicart_config *get_config(device_t *device) |
| 1222 | | { |
| 1223 | | assert(device != NULL); |
| 1224 | | assert(device->type() == TI99_MULTICART); |
| 1225 | | |
| 1226 | | return (const ti99_multicart_config *) downcast<const legacy_device_base *>(device)->inline_config(); |
| 1227 | | } |
| 1228 | | |
| 1229 | | INLINE ti99_pcb_t *get_safe_pcb_token(device_t *device) |
| 1230 | | { |
| 1231 | | assert(device != NULL); |
| 1232 | | assert(device->type() == TI99_CARTRIDGE_PCB_NONE || |
| 1233 | | device->type() == TI99_CARTRIDGE_PCB_STD || |
| 1234 | | device->type() == TI99_CARTRIDGE_PCB_PAGED || |
| 1235 | | device->type() == TI99_CARTRIDGE_PCB_MINIMEM || |
| 1236 | | device->type() == TI99_CARTRIDGE_PCB_SUPER || |
| 1237 | | device->type() == TI99_CARTRIDGE_PCB_MBX || |
| 1238 | | device->type() == TI99_CARTRIDGE_PCB_PAGED379I || |
| 1239 | | device->type() == TI99_CARTRIDGE_PCB_PAGEDCRU || |
| 1240 | | device->type() == TI99_CARTRIDGE_PCB_GRAMKRACKER); |
| 1241 | | |
| 1242 | | return (ti99_pcb_t *)downcast<legacy_device_base *>(device)->token(); |
| 1243 | | } |
| 1244 | | |
| 1245 | | INLINE multicartslot_t *get_safe_cartslot_token(device_t *device) |
| 1246 | | { |
| 1247 | | assert(device != NULL); |
| 1248 | | assert(device->type() == MULTICARTSLOT); |
| 1249 | | |
| 1250 | | return (multicartslot_t *)downcast<legacy_device_base *>(device)->token(); |
| 1251 | | } |
| 1252 | | |
| 1253 | | static WRITE_LINE_DEVICE_HANDLER( cart_grom_ready ) |
| 1254 | | { |
| 1255 | | device_t *cartdev = device->owner()->owner(); |
| 1256 | | ti99_multicart_state *cartslots = get_safe_token(cartdev); |
| 1257 | | cartslots->ready(state); |
| 1258 | | } |
| 1259 | | |
| 1260 | | /* |
| 1261 | | The console writes the values in this array to cache them. |
| 1262 | | */ |
| 1263 | | void set_gk_switches(device_t *cartsys, int number, int value) |
| 1264 | | { |
| 1265 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1266 | | cartslots->gk_switch[number] = value; |
| 1267 | | } |
| 1268 | | |
| 1269 | | static int get_gk_switch(device_t *cartsys, int number) |
| 1270 | | { |
| 1271 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1272 | | return cartslots->gk_switch[number]; |
| 1273 | | } |
| 1274 | | |
| 1275 | | /* |
| 1276 | | Activates a slot in the multi-cartridge extender. |
| 1277 | | */ |
| 1278 | | static void cartridge_slot_set(device_t *cartsys, UINT8 slotnumber) |
| 1279 | | { |
| 1280 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1281 | | if (VERBOSE>2) |
| 1282 | | if (cartslots->active_slot != slotnumber) LOG("ti99: gromport: Setting cartslot to %d\n", slotnumber); |
| 1283 | | if (cartslots->fixed_slot==AUTO) |
| 1284 | | cartslots->active_slot = slotnumber; |
| 1285 | | else |
| 1286 | | cartslots->active_slot = cartslots->fixed_slot; |
| 1287 | | } |
| 1288 | | |
| 1289 | | static int slot_is_empty(device_t *cartsys, int slotnumber) |
| 1290 | | { |
| 1291 | | cartridge_t *cart; |
| 1292 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1293 | | |
| 1294 | | cart = &cartslots->cartridge[slotnumber]; |
| 1295 | | |
| 1296 | | if ((cart->rom_size==0) && (cart->ram_size==0) && (cart->grom_size==0)) |
| 1297 | | return TRUE; |
| 1298 | | return FALSE; |
| 1299 | | } |
| 1300 | | |
| 1301 | | static void clear_slot(device_t *cartsys, int slotnumber) |
| 1302 | | { |
| 1303 | | cartridge_t *cart; |
| 1304 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1305 | | |
| 1306 | | cart = &cartslots->cartridge[slotnumber]; |
| 1307 | | |
| 1308 | | cart->rom_size = cart->ram_size = cart->grom_size = 0; |
| 1309 | | cart->rom_ptr = NULL; |
| 1310 | | cart->rom2_ptr = NULL; |
| 1311 | | cart->ram_ptr = NULL; |
| 1312 | | } |
| 1313 | | |
| 1314 | | /* |
| 1315 | | Find the index of the cartridge name. We assume the format |
| 1316 | | <name><number>, i.e. the number is the longest string from the right |
| 1317 | | which can be interpreted as a number. |
| 1318 | | */ |
| 1319 | | static int get_index_from_tagname(device_t *image) |
| 1320 | | { |
| 1321 | | const char *tag = image->tag(); |
| 1322 | | int maxlen = strlen(tag); |
| 1323 | | int i; |
| 1324 | | for (i=maxlen-1; i >=0; i--) |
| 1325 | | if (tag[i] < 48 || tag[i] > 57) break; |
| 1326 | | |
| 1327 | | return atoi(tag+i+1); |
| 1328 | | } |
| 1329 | | |
| 1330 | | /* |
| 1331 | | Common routine to assemble cartridges from resources. |
| 1332 | | */ |
| 1333 | | static cartridge_t *assemble_common(device_t *cartslot) |
| 1334 | | { |
| 1335 | | /* Pointer to the cartridge structure. */ |
| 1336 | | cartridge_t *cartridge; |
| 1337 | | device_t *cartsys = cartslot->owner(); |
| 1338 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1339 | | device_t *pcb = cartslot->subdevice("pcb"); |
| 1340 | | ti99_pcb_t *pcb_def; |
| 1341 | | |
| 1342 | | void *socketcont; |
| 1343 | | int reslength; |
| 1344 | | // int i; |
| 1345 | | |
| 1346 | | int slotnumber = get_index_from_tagname(cartslot)-1; |
| 1347 | | assert(slotnumber>=0 && slotnumber<NUMBER_OF_CARTRIDGE_SLOTS); |
| 1348 | | |
| 1349 | | if (VERBOSE>1) LOG("ti99: gromport: mounting cartridge in slot %d\n", slotnumber); |
| 1350 | | |
| 1351 | | /* There is a cartridge in this slot, check the maximum slot number. */ |
| 1352 | | if (cartslots->next_free_slot <= slotnumber) |
| 1353 | | { |
| 1354 | | cartslots->next_free_slot = slotnumber+1; |
| 1355 | | } |
| 1356 | | cartridge = &cartslots->cartridge[slotnumber]; |
| 1357 | | |
| 1358 | | // Get the socket which is retrieved by the multicart instance in |
| 1359 | | // the state of the cartslot instance. |
| 1360 | | socketcont = cartslot_get_socket(cartslot, "grom_socket"); |
| 1361 | | reslength = cartslot_get_resource_length(cartslot, "grom_socket"); |
| 1362 | | if (socketcont != NULL) |
| 1363 | | { |
| 1364 | | cartridge->grom_ptr = (UINT8 *)socketcont; |
| 1365 | | // printf("grom_socket = %lx\n", cartridge->grom_ptr); |
| 1366 | | cartridge->grom_size = reslength; |
| 1367 | | } |
| 1368 | | |
| 1369 | | socketcont = cartslot_get_socket(cartslot, "rom_socket"); |
| 1370 | | reslength = cartslot_get_resource_length(cartslot, "rom_socket"); |
| 1371 | | if (socketcont != NULL) |
| 1372 | | { |
| 1373 | | cartridge->rom_ptr = (UINT8 *)socketcont; |
| 1374 | | cartridge->rom_size = reslength; |
| 1375 | | } |
| 1376 | | |
| 1377 | | socketcont = cartslot_get_socket(cartslot, "rom2_socket"); |
| 1378 | | // reslength = cartslot_get_resource_length(cartslot, "rom2_socket"); /* cannot differ from rom_socket */ |
| 1379 | | if (socketcont != NULL) |
| 1380 | | { |
| 1381 | | cartridge->rom2_ptr = (UINT8 *)socketcont; |
| 1382 | | } |
| 1383 | | |
| 1384 | | socketcont = cartslot_get_socket(cartslot, "ram_socket"); |
| 1385 | | reslength = cartslot_get_resource_length(cartslot, "ram_socket"); |
| 1386 | | if (socketcont != NULL) |
| 1387 | | { |
| 1388 | | cartridge->ram_ptr = (UINT8 *)socketcont; |
| 1389 | | cartridge->ram_size = reslength; |
| 1390 | | } |
| 1391 | | |
| 1392 | | // Register the GROMs |
| 1393 | | pcb_def = get_safe_pcb_token(pcb); |
| 1394 | | for (int i=0; i < 5; i++) pcb_def->grom[i]= NULL; |
| 1395 | | if (cartridge->grom_size > 0) pcb_def->grom[0] = pcb->subdevice("grom_3"); |
| 1396 | | if (cartridge->grom_size > 0x2000) pcb_def->grom[1] = pcb->subdevice("grom_4"); |
| 1397 | | if (cartridge->grom_size > 0x4000) pcb_def->grom[2] = pcb->subdevice("grom_5"); |
| 1398 | | if (cartridge->grom_size > 0x6000) pcb_def->grom[3] = pcb->subdevice("grom_6"); |
| 1399 | | if (cartridge->grom_size > 0x8000) pcb_def->grom[4] = pcb->subdevice("grom_7"); |
| 1400 | | |
| 1401 | | return cartridge; |
| 1402 | | } |
| 1403 | | |
| 1404 | | static void set_pointers(device_t *pcb, int index) |
| 1405 | | { |
| 1406 | | device_t *cartsys = pcb->owner()->owner(); |
| 1407 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1408 | | ti99_pcb_t *pcb_def = get_safe_pcb_token(pcb); |
| 1409 | | |
| 1410 | | pcb_def->read = (read8z_device_func)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CARTINFO_FCT_6000_R); |
| 1411 | | pcb_def->write = (write8_device_func)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CARTINFO_FCT_6000_W); |
| 1412 | | pcb_def->cruread = (read8z_device_func)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CARTINFO_FCT_CRU_R); |
| 1413 | | pcb_def->cruwrite = (write8_device_func)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CARTINFO_FCT_CRU_W); |
| 1414 | | |
| 1415 | | pcb_def->assemble = (assmfct *)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CART_FCT_ASSM); |
| 1416 | | pcb_def->disassemble = (assmfct *)downcast<const legacy_cart_slot_device_base *>(pcb)->get_legacy_fct(TI99CART_FCT_DISASSM); |
| 1417 | | |
| 1418 | | pcb_def->cartridge = &cartslots->cartridge[index]; |
| 1419 | | pcb_def->cartridge->pcb = pcb; |
| 1420 | | } |
| 1421 | | |
| 1422 | 216 | /***************************************************************************** |
| 1423 | | Cartridge type: None |
| 1424 | | This PCB device is just a pseudo device |
| 1425 | | ******************************************************************************/ |
| 1426 | | static DEVICE_START(ti99_pcb_none) |
| 1427 | | { |
| 1428 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 1429 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1430 | | } |
| 1431 | | |
| 1432 | | /***************************************************************************** |
| 1433 | 217 | Cartridge type: Standard |
| 1434 | 218 | Most cartridges are built in this type. Every cartridge may contain |
| 1435 | 219 | GROM between 0 and 40 KiB, and ROM with 8 KiB length, no banking. |
| 1436 | 220 | ******************************************************************************/ |
| 1437 | 221 | |
| 1438 | | static DEVICE_START(ti99_pcb_std) |
| 222 | /* Read function for the standard cartridge. */ |
| 223 | READ8Z_MEMBER(cartridge_pcb_standard_device::readz) |
| 1439 | 224 | { |
| 1440 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 1441 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1442 | | } |
| 1443 | | |
| 1444 | | /* |
| 1445 | | Read handler for the CPU address space of the cartridge |
| 1446 | | Images for this area are found in the rom_sockets. |
| 1447 | | */ |
| 1448 | | static READ8Z_DEVICE_HANDLER( read_cart_std ) |
| 1449 | | { |
| 1450 | | /* device is pcb, owner is cartslot (cartridge is only a part of the state of cartslot) */ |
| 1451 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1452 | | cartridge_t *cartridge = pcb->cartridge; |
| 1453 | | if (cartridge->rom_ptr!=NULL) |
| 225 | if ((offset & GROM_MASK)==GROM_AREA) |
| 226 | gromreadz(space, offset, value, mem_mask); |
| 227 | else |
| 1454 | 228 | { |
| 1455 | | // For TI-99/8 we should plan for 16K cartridges. However, none was produced. Well, just ignore this thought, |
| 1456 | | *value = (cartridge->rom_ptr)[offset & 0x1fff]; |
| 1457 | | // printf("read cartridge rom space (length %04x) %04x = %02x\n", cartridge->rom_size, offset, *value); |
| 229 | if (m_rom_ptr!=NULL) |
| 230 | { |
| 231 | // For TI-99/8 we should plan for 16K cartridges. However, none was ever produced. |
| 232 | // Well, forget about that. |
| 233 | *value = m_rom_ptr[offset & 0x1fff]; |
| 234 | // LOG("read cartridge rom space %04x = %02x\n", offset, *value); |
| 235 | } |
| 1458 | 236 | } |
| 1459 | 237 | } |
| 1460 | 238 | |
| 1461 | | static WRITE8_DEVICE_HANDLER( write_cart_std ) |
| 239 | /* Write function for the standard cartridge. */ |
| 240 | WRITE8_MEMBER(cartridge_pcb_standard_device::write) |
| 1462 | 241 | { |
| 1463 | | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored\n", offset); |
| 1464 | | } |
| 1465 | | |
| 1466 | | /* |
| 1467 | | The standard cartridge assemble routine. We just call the common |
| 1468 | | function here. |
| 1469 | | */ |
| 1470 | | static int assemble_std(device_t *image) |
| 1471 | | { |
| 1472 | | assemble_common(image); |
| 1473 | | return IMAGE_INIT_PASS; |
| 1474 | | } |
| 1475 | | |
| 1476 | | /* |
| 1477 | | Removes pointers and restores the state before plugging in the |
| 1478 | | cartridge. |
| 1479 | | The pointer to the location after the last cartridge is adjusted. |
| 1480 | | As it seems, we can use the same function for the disassembling of all |
| 1481 | | cartridge types. |
| 1482 | | */ |
| 1483 | | static int disassemble_std(device_t *image) |
| 1484 | | { |
| 1485 | | int slotnumber; |
| 1486 | | int i; |
| 1487 | | // cartridge_t *cart; |
| 1488 | | device_t *cartsys = image->owner(); |
| 1489 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1490 | | |
| 1491 | | slotnumber = get_index_from_tagname(image)-1; |
| 1492 | | |
| 1493 | | /* Search the highest remaining cartridge. */ |
| 1494 | | cartslots->next_free_slot = 0; |
| 1495 | | for (i=NUMBER_OF_CARTRIDGE_SLOTS-1; i >= 0; i--) |
| 242 | // LOG("write standard\n"); |
| 243 | if ((offset & GROM_MASK)==GROM_AREA) |
| 244 | gromwrite(space, offset, data, mem_mask); |
| 245 | else |
| 1496 | 246 | { |
| 1497 | | if (i != slotnumber) |
| 1498 | | { |
| 1499 | | if (!slot_is_empty(cartsys, i)) |
| 1500 | | { |
| 1501 | | cartslots->next_free_slot = i+1; |
| 1502 | | break; |
| 1503 | | } |
| 1504 | | } |
| 247 | if (VERBOSE>5) LOG("cartridge_pcb_device: Cannot write to ROM space at %04x\n", offset); |
| 1505 | 248 | } |
| 1506 | | |
| 1507 | | clear_slot(cartsys, slotnumber); |
| 1508 | | |
| 1509 | | return IMAGE_INIT_PASS; |
| 1510 | 249 | } |
| 1511 | 250 | |
| 1512 | 251 | /***************************************************************************** |
| r14513 | r14514 | |
| 1518 | 257 | 6002 = bank 1). |
| 1519 | 258 | ******************************************************************************/ |
| 1520 | 259 | |
| 1521 | | static DEVICE_START(ti99_pcb_paged) |
| 260 | /* Read function for the paged cartridge. */ |
| 261 | READ8Z_MEMBER(cartridge_pcb_paged_device::readz) |
| 1522 | 262 | { |
| 1523 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 1524 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1525 | | } |
| 1526 | | |
| 1527 | | /* |
| 1528 | | Read handler for the CPU address space of the cartridge |
| 1529 | | Images for this area are found in the rom_sockets. |
| 1530 | | */ |
| 1531 | | static READ8Z_DEVICE_HANDLER( read_cart_paged ) |
| 1532 | | { |
| 1533 | | /* device is pcb, owner is cartslot */ |
| 1534 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1535 | | cartridge_t *cartridge = pcb->cartridge; |
| 1536 | | UINT8 *rombank; |
| 1537 | | |
| 1538 | | if (cartridge->rom_page==0) |
| 1539 | | rombank = (UINT8*)cartridge->rom_ptr; |
| 263 | if ((offset & GROM_MASK)==GROM_AREA) |
| 264 | gromreadz(space, offset, value, mem_mask); |
| 1540 | 265 | else |
| 1541 | | rombank = (UINT8*)cartridge->rom2_ptr; |
| 1542 | | |
| 1543 | | if (rombank==NULL) |
| 1544 | 266 | { |
| 1545 | | /* TODO: Check for consistency with the GROM memory handling. */ |
| 1546 | | *value = 0; |
| 267 | if (m_rom_page==0) |
| 268 | { |
| 269 | *value = m_rom_ptr[offset & 0x1fff]; |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | *value = m_rom2_ptr[offset & 0x1fff]; |
| 274 | } |
| 1547 | 275 | } |
| 1548 | | else |
| 1549 | | { |
| 1550 | | *value = rombank[offset & 0x1fff]; |
| 1551 | | } |
| 1552 | 276 | } |
| 1553 | 277 | |
| 1554 | | /* |
| 1555 | | Handle paging. Extended Basic switches between ROM banks by |
| 1556 | | using the value of the LSB of the address where any value |
| 1557 | | is written to. |
| 1558 | | */ |
| 1559 | | static WRITE8_DEVICE_HANDLER( write_cart_paged ) |
| 278 | /* Write function for the paged cartridge. */ |
| 279 | WRITE8_MEMBER(cartridge_pcb_paged_device::write) |
| 1560 | 280 | { |
| 1561 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1562 | | cartridge_t *cartridge = pcb->cartridge; |
| 1563 | | cartridge->rom_page = (offset >> 1) & 1; |
| 1564 | | } |
| 281 | // LOG("write standard\n"); |
| 282 | if ((offset & GROM_MASK)==GROM_AREA) |
| 283 | gromwrite(space, offset, data, mem_mask); |
| 1565 | 284 | |
| 1566 | | /* |
| 1567 | | We require paged modules to have at least those two rom banks. |
| 1568 | | */ |
| 1569 | | static int assemble_paged(device_t *image) |
| 1570 | | { |
| 1571 | | cartridge_t *cart; |
| 1572 | | |
| 1573 | | cart = assemble_common(image); |
| 1574 | | if (cart->rom_ptr==NULL) |
| 1575 | | { |
| 1576 | | if (VERBOSE>1) LOG("ti99: gromport: Missing ROM for paged cartridge"); |
| 1577 | | return IMAGE_INIT_FAIL; |
| 1578 | | } |
| 1579 | | if (cart->rom2_ptr==NULL) |
| 1580 | | { |
| 1581 | | if (VERBOSE>1) LOG("ti99: gromport: Missing second ROM for paged cartridge"); |
| 1582 | | return IMAGE_INIT_FAIL; |
| 1583 | | } |
| 1584 | | |
| 1585 | | return IMAGE_INIT_PASS; |
| 285 | else |
| 286 | m_rom_page = (offset >> 1) & 1; |
| 1586 | 287 | } |
| 1587 | 288 | |
| 289 | |
| 1588 | 290 | /***************************************************************************** |
| 1589 | 291 | Cartridge type: Mini Memory |
| 1590 | 292 | GROM: 6 KiB (occupies G>6000 to G>7800) |
| r14513 | r14514 | |
| 1592 | 294 | persistent RAM: 4 KiB (0x7000-0x7fff) |
| 1593 | 295 | ******************************************************************************/ |
| 1594 | 296 | |
| 1595 | | static DEVICE_START(ti99_pcb_minimem) |
| 297 | /* Read function for the minimem cartridge. */ |
| 298 | READ8Z_MEMBER(cartridge_pcb_minimem_device::readz) |
| 1596 | 299 | { |
| 1597 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1598 | | } |
| 300 | if ((offset & GROM_MASK)==GROM_AREA) |
| 301 | gromreadz(space, offset, value, mem_mask); |
| 1599 | 302 | |
| 1600 | | static READ8Z_DEVICE_HANDLER( read_cart_minimem ) |
| 1601 | | { |
| 1602 | | /* device is pcb, owner is cartslot */ |
| 1603 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1604 | | cartridge_t *cartridge = pcb->cartridge; |
| 1605 | | |
| 1606 | | if ((offset & 0x1000)==0x0000) |
| 1607 | | { |
| 1608 | | *value = (cartridge->rom_ptr==NULL)? 0 : (cartridge->rom_ptr)[offset & 0x0fff]; |
| 1609 | | } |
| 1610 | 303 | else |
| 1611 | 304 | { |
| 1612 | | *value = (cartridge->ram_ptr==NULL)? 0 : (cartridge->ram_ptr)[offset & 0x0fff]; |
| 305 | if ((offset & 0x1000)==0x0000) |
| 306 | { |
| 307 | *value = m_rom_ptr[offset & 0x0fff]; |
| 308 | } |
| 309 | else |
| 310 | { |
| 311 | *value = m_ram_ptr[offset & 0x0fff]; |
| 312 | } |
| 1613 | 313 | } |
| 1614 | 314 | } |
| 1615 | 315 | |
| 1616 | | /* |
| 1617 | | Mini Memory cartridge write operation. RAM is located at 0x7000. |
| 1618 | | */ |
| 1619 | | static WRITE8_DEVICE_HANDLER( write_cart_minimem ) |
| 316 | /* Write function for the minimem cartridge. */ |
| 317 | WRITE8_MEMBER(cartridge_pcb_minimem_device::write) |
| 1620 | 318 | { |
| 1621 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1622 | | cartridge_t *cartridge = pcb->cartridge; |
| 319 | // LOG("write standard\n"); |
| 320 | if ((offset & GROM_MASK)==GROM_AREA) |
| 321 | gromwrite(space, offset, data, mem_mask); |
| 1623 | 322 | |
| 1624 | | if ((offset & 0x1000)==0x0000) |
| 1625 | | { |
| 1626 | | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 1627 | | } |
| 1628 | 323 | else |
| 1629 | 324 | { |
| 1630 | | if (cartridge->ram_ptr==NULL) |
| 325 | if ((offset & 0x1000)==0x0000) |
| 1631 | 326 | { |
| 1632 | | if (VERBOSE>1) LOG("ti99: gromport: No cartridge RAM at address %04x", offset); |
| 1633 | | /* TODO: Check for consistency with the GROM memory handling. */ |
| 327 | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 1634 | 328 | } |
| 1635 | 329 | else |
| 1636 | 330 | { |
| 1637 | | (cartridge->ram_ptr)[offset & 0x0fff] = data; |
| 331 | m_ram_ptr[offset & 0x0fff] = data; |
| 1638 | 332 | } |
| 1639 | 333 | } |
| 1640 | 334 | } |
| 1641 | 335 | |
| 1642 | | static int assemble_minimem(device_t *image) |
| 1643 | | { |
| 1644 | | cartridge_t *cart; |
| 1645 | | |
| 1646 | | cart = assemble_common(image); |
| 1647 | | if (cart->grom_size==0) |
| 1648 | | { |
| 1649 | | if (VERBOSE>1) LOG("ti99: gromport: Missing GROM for Mini Memory"); |
| 1650 | | // should not fail here because there may be variations of |
| 1651 | | // cartridges which do not use all parts |
| 1652 | | // return IMAGE_INIT_FAIL; |
| 1653 | | } |
| 1654 | | if (cart->rom_size==0) |
| 1655 | | { |
| 1656 | | if (VERBOSE>1) LOG("ti99: gromport: Missing ROM for Mini Memory"); |
| 1657 | | // return IMAGE_INIT_FAIL; |
| 1658 | | } |
| 1659 | | if (cart->ram_size==0) |
| 1660 | | { |
| 1661 | | if (VERBOSE>1) LOG("ti99: gromport: Missing RAM for Mini Memory"); |
| 1662 | | // return IMAGE_INIT_FAIL; |
| 1663 | | } |
| 1664 | | |
| 1665 | | return IMAGE_INIT_PASS; |
| 1666 | | } |
| 1667 | | |
| 1668 | 336 | /***************************************************************************** |
| 1669 | 337 | Cartridge type: SuperSpace II |
| 1670 | 338 | SuperSpace cartridge type. SuperSpace is intended as a user-definable |
| r14513 | r14514 | |
| 1682 | 350 | Switching the bank is done via CRU write |
| 1683 | 351 | ******************************************************************************/ |
| 1684 | 352 | |
| 1685 | | static DEVICE_START(ti99_pcb_super) |
| 353 | /* Read function for the super cartridge. */ |
| 354 | READ8Z_MEMBER(cartridge_pcb_superspace_device::readz) |
| 1686 | 355 | { |
| 1687 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 356 | if ((offset & GROM_MASK)==GROM_AREA) |
| 357 | gromreadz(space, offset, value, mem_mask); |
| 358 | else |
| 359 | { |
| 360 | if (m_ram_ptr==NULL) |
| 361 | { |
| 362 | *value = 0; |
| 363 | } |
| 364 | else |
| 365 | { |
| 366 | offs_t boffset = (m_ram_page << 13) | (offset & 0x1fff); |
| 367 | *value = m_ram_ptr[boffset]; |
| 368 | } |
| 369 | } |
| 1688 | 370 | } |
| 1689 | 371 | |
| 1690 | | /* |
| 1691 | | The CRU read handler. The CRU is a serial interface in the console. |
| 1692 | | Using the CRU we can switch the banks in the SuperSpace cartridge. |
| 1693 | | */ |
| 1694 | | static READ8Z_DEVICE_HANDLER( read_cart_cru ) |
| 372 | /* Write function for the super cartridge. */ |
| 373 | WRITE8_MEMBER(cartridge_pcb_superspace_device::write) |
| 1695 | 374 | { |
| 1696 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1697 | | cartridge_t *cartridge = pcb->cartridge; |
| 375 | if ((offset & GROM_MASK)==GROM_AREA) |
| 376 | gromwrite(space, offset, data, mem_mask); |
| 377 | else |
| 378 | { |
| 379 | if ((offset & 0x1000)==0x0000) |
| 380 | { |
| 381 | if (VERBOSE>1) LOG("ti99: gromport: Write access to cartridge ROM at address %04x ignored", offset); |
| 382 | } |
| 383 | else |
| 384 | { |
| 385 | offs_t boffset = (m_ram_page << 13) | (offset & 0x1fff); |
| 386 | m_ram_ptr[boffset] = data; |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | void cartridge_pcb_superspace_device::crureadz(offs_t offset, UINT8 *value) |
| 392 | { |
| 1698 | 393 | // offset is the bit number. The CRU base address is already divided by 2. |
| 1699 | 394 | |
| 1700 | 395 | // ram_page contains the bank number. We have a maximum of |
| r14513 | r14514 | |
| 1718 | 413 | // BNKS1 LDCR R1,0 Switch Banks |
| 1719 | 414 | // SRL R0,1 Restore Bank Number (optional) |
| 1720 | 415 | // RT |
| 1721 | | if (VERBOSE>1) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 1722 | | if ((offset & 1) == 0 || offset > 7) |
| 416 | |
| 417 | // Our implementation in MESS always gets 8 bits in one go. Also, the address |
| 418 | // is twice the bit number. That is, the offset value is always a multiple |
| 419 | // of 0x10. |
| 420 | |
| 421 | if (VERBOSE>2) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 422 | if ((offset & 0xfff0) != 0x0800) |
| 1723 | 423 | *value = 0; |
| 1724 | 424 | |
| 1725 | 425 | // CRU addresses are only 1 bit wide. Bytes are transferred from LSB |
| 1726 | 426 | // to MSB. That is, 8 bit are eight consecutive addresses. */ |
| 1727 | | *value = (cartridge->ram_page == (offset-1)/2); |
| 427 | *value = (m_ram_page == (offset-1)/2); |
| 1728 | 428 | } |
| 1729 | 429 | |
| 1730 | | static WRITE8_DEVICE_HANDLER( write_cart_cru ) |
| 430 | void cartridge_pcb_superspace_device::cruwrite(offs_t offset, UINT8 data) |
| 1731 | 431 | { |
| 1732 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1733 | | cartridge_t *cartridge = pcb->cartridge; |
| 1734 | 432 | // data is bit |
| 1735 | 433 | // offset is address |
| 1736 | | if (VERBOSE>1) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 1737 | | if (offset < 8) |
| 434 | if (VERBOSE>2) LOG("ti99: gromport: Superspace: CRU accessed at %04x\n", offset); |
| 435 | |
| 436 | if (offset < 16) |
| 1738 | 437 | { |
| 1739 | 438 | if (data != 0) |
| 1740 | | cartridge->ram_page = (offset-1)/2; |
| 439 | m_ram_page = (offset-2)/4; |
| 1741 | 440 | } |
| 1742 | 441 | } |
| 1743 | 442 | |
| 1744 | | /* |
| 1745 | | SuperSpace RAM read operation. RAM is located at 0x6000 to 0x7fff |
| 1746 | | as 4 banks of 8 KiB each |
| 1747 | | */ |
| 1748 | | static READ8Z_DEVICE_HANDLER( read_cart_super ) |
| 1749 | | { |
| 1750 | | /* device is pcb, owner is cartslot */ |
| 1751 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1752 | | cartridge_t *cartridge = pcb->cartridge; |
| 1753 | | offs_t boffset; |
| 1754 | | |
| 1755 | | if (cartridge->ram_ptr==NULL) |
| 1756 | | { |
| 1757 | | *value = 0; |
| 1758 | | } |
| 1759 | | else |
| 1760 | | { |
| 1761 | | boffset = cartridge->ram_page * 0x2000 + (offset & 0x1fff); |
| 1762 | | *value = (cartridge->ram_ptr)[boffset]; |
| 1763 | | } |
| 1764 | | } |
| 1765 | | |
| 1766 | | /* |
| 1767 | | SuperSpace RAM write operation. RAM is located at 0x6000 to 0x7fff |
| 1768 | | as 4 banks of 8 KiB each |
| 1769 | | */ |
| 1770 | | static WRITE8_DEVICE_HANDLER( write_cart_super ) |
| 1771 | | { |
| 1772 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1773 | | cartridge_t *cartridge = pcb->cartridge; |
| 1774 | | offs_t boffset; |
| 1775 | | |
| 1776 | | if (cartridge->ram_ptr==NULL) |
| 1777 | | { |
| 1778 | | if (VERBOSE>1) LOG("ti99: gromport: No cartridge RAM at address %04x", offset); |
| 1779 | | } |
| 1780 | | else |
| 1781 | | { |
| 1782 | | boffset = cartridge->ram_page * 0x2000 + (offset & 0x1fff); |
| 1783 | | (cartridge->ram_ptr)[boffset] = data; |
| 1784 | | } |
| 1785 | | } |
| 1786 | | |
| 1787 | | static int assemble_super(device_t *image) |
| 1788 | | { |
| 1789 | | cartridge_t *cart; |
| 1790 | | |
| 1791 | | cart = assemble_common(image); |
| 1792 | | if (cart->ram_size==0) |
| 1793 | | { |
| 1794 | | if (VERBOSE>1) LOG("ti99: gromport: Missing RAM for SuperSpace"); |
| 1795 | | return IMAGE_INIT_FAIL; |
| 1796 | | } |
| 1797 | | return IMAGE_INIT_PASS; |
| 1798 | | } |
| 1799 | | |
| 1800 | 443 | /***************************************************************************** |
| 1801 | 444 | Cartridge type: MBX |
| 1802 | 445 | GROM: up to 40 KiB |
| r14513 | r14514 | |
| 1809 | 452 | not emulated yet. |
| 1810 | 453 | ******************************************************************************/ |
| 1811 | 454 | |
| 1812 | | static DEVICE_START(ti99_pcb_mbx) |
| 455 | /* Read function for the mbx cartridge. */ |
| 456 | READ8Z_MEMBER(cartridge_pcb_mbx_device::readz) |
| 1813 | 457 | { |
| 1814 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1815 | | } |
| 1816 | | |
| 1817 | | static READ8Z_DEVICE_HANDLER( read_cart_mbx ) |
| 1818 | | { |
| 1819 | | /* device is pcb, owner is cartslot */ |
| 1820 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1821 | | cartridge_t *cartridge = pcb->cartridge; |
| 1822 | | |
| 1823 | | if ((offset & 0x1c00)==0x0c00) |
| 1824 | | { |
| 1825 | | // This is the RAM area which overrides any ROM. There is no |
| 1826 | | // known banking behavior for the RAM, so we must assume that |
| 1827 | | // there is only one bank. |
| 1828 | | if (cartridge->ram_ptr != NULL) |
| 1829 | | *value = (cartridge->ram_ptr)[offset & 0x03ff]; |
| 1830 | | } |
| 458 | if ((offset & GROM_MASK)==GROM_AREA) |
| 459 | gromreadz(space, offset, value, mem_mask); |
| 1831 | 460 | else |
| 1832 | 461 | { |
| 1833 | | if (cartridge->rom_ptr != NULL) |
| 1834 | | *value = (cartridge->rom_ptr)[(offset & 0x1fff)+ cartridge->rom_page*0x2000]; |
| 462 | if ((offset & 0x1c00)==0x0c00) |
| 463 | { |
| 464 | // This is the RAM area which overrides any ROM. There is no |
| 465 | // known banking behavior for the RAM, so we must assume that |
| 466 | // there is only one bank. |
| 467 | if (m_ram_ptr != NULL) |
| 468 | *value = m_ram_ptr[offset & 0x03ff]; |
| 469 | } |
| 470 | else |
| 471 | { |
| 472 | *value = m_rom_ptr[(offset & 0x1fff) | (m_rom_page<<13)]; |
| 473 | } |
| 1835 | 474 | } |
| 1836 | 475 | } |
| 1837 | 476 | |
| 1838 | | /* |
| 1839 | | MBX write operation. |
| 1840 | | */ |
| 1841 | | static WRITE8_DEVICE_HANDLER( write_cart_mbx ) |
| 477 | /* Write function for the super cartridge. */ |
| 478 | WRITE8_MEMBER(cartridge_pcb_mbx_device::write) |
| 1842 | 479 | { |
| 1843 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1844 | | cartridge_t *cartridge = pcb->cartridge; |
| 1845 | | |
| 1846 | | if (offset == 0x6ffe) |
| 480 | if ((offset & GROM_MASK)==GROM_AREA) |
| 481 | gromwrite(space, offset, data, mem_mask); |
| 482 | else |
| 1847 | 483 | { |
| 1848 | | cartridge->rom_page = data & 1; |
| 1849 | | return; |
| 1850 | | } |
| 484 | if (offset == 0x6ffe) |
| 485 | { |
| 486 | m_rom_page = data & 1; |
| 487 | return; |
| 488 | } |
| 1851 | 489 | |
| 1852 | | if ((offset & 0x1c00)==0x0c00) |
| 1853 | | { |
| 1854 | | if (cartridge->ram_ptr == NULL) return; |
| 1855 | | cartridge->ram_ptr[offset & 0x03ff] = data; |
| 490 | if ((offset & 0x1c00)==0x0c00) |
| 491 | { |
| 492 | if (m_ram_ptr == NULL) return; |
| 493 | m_ram_ptr[offset & 0x03ff] = data; |
| 494 | } |
| 1856 | 495 | } |
| 1857 | 496 | } |
| 1858 | 497 | |
| 1859 | | |
| 1860 | | static int assemble_mbx(device_t *image) |
| 1861 | | { |
| 1862 | | assemble_common(image); |
| 1863 | | return IMAGE_INIT_PASS; |
| 1864 | | } |
| 1865 | | |
| 1866 | 498 | /***************************************************************************** |
| 1867 | 499 | Cartridge type: paged379i |
| 1868 | 500 | This cartridge consists of one 16 KiB, 32 KiB, 64 KiB, or 128 KiB EEPROM |
| r14513 | r14514 | |
| 1892 | 524 | >601C 1 / 1 / 1 / 1 |
| 1893 | 525 | >601E 0 / 0 / 0 / 0 |
| 1894 | 526 | |
| 527 | The paged379i cartrige does not have any GROMs. |
| 1895 | 528 | ******************************************************************************/ |
| 1896 | 529 | |
| 1897 | | static DEVICE_START(ti99_pcb_paged379i) |
| 1898 | | { |
| 1899 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 1900 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 1901 | | } |
| 1902 | | |
| 1903 | 530 | /* |
| 1904 | | Read handler for the CPU address space of the cartridge |
| 1905 | | Images for this area are found in the rom_sockets. |
| 1906 | | */ |
| 1907 | | static READ8Z_DEVICE_HANDLER( read_cart_paged379i ) |
| 1908 | | { |
| 1909 | | /* device is pcb, owner is cartslot */ |
| 1910 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1911 | | cartridge_t *cartridge = pcb->cartridge; |
| 1912 | | |
| 1913 | | if (cartridge->rom_ptr!=NULL) |
| 1914 | | { |
| 1915 | | *value = (cartridge->rom_ptr)[cartridge->rom_page*0x2000 + (offset & 0x1fff)]; |
| 1916 | | } |
| 1917 | | } |
| 1918 | | |
| 1919 | | /* |
| 1920 | 531 | Determines which bank to set, depending on the size of the ROM. This is |
| 1921 | 532 | some magic code that actually represents different PCB versions. |
| 1922 | 533 | */ |
| 1923 | | static void set_paged379i_bank(cartridge_t *cartridge, int rompage) |
| 534 | int cartridge_pcb_paged379i_device::get_paged379i_bank(int rompage) |
| 1924 | 535 | { |
| 1925 | 536 | int mask = 0; |
| 1926 | | if (cartridge->rom_size > 16384) |
| 537 | if (m_rom_size > 16384) |
| 1927 | 538 | { |
| 1928 | | if (cartridge->rom_size > 32768) |
| 539 | if (m_rom_size > 32768) |
| 1929 | 540 | { |
| 1930 | | if (cartridge->rom_size > 65536) |
| 541 | if (m_rom_size > 65536) |
| 1931 | 542 | mask = 15; |
| 1932 | 543 | else |
| 1933 | 544 | mask = 7; |
| r14513 | r14514 | |
| 1938 | 549 | else |
| 1939 | 550 | mask = 1; |
| 1940 | 551 | |
| 1941 | | cartridge->rom_page = rompage & mask; |
| 552 | return rompage & mask; |
| 1942 | 553 | } |
| 1943 | 554 | |
| 1944 | | /* |
| 1945 | | Handle paging. We use a LS379 latch for storing the page number. On this |
| 1946 | | PCB, the inverted output of the latch is used, so the order of pages |
| 1947 | | is reversed. (No problem as long as the memory dump is kept exactly |
| 1948 | | in the way it is stored in the EPROM.) |
| 1949 | | The latch can store a value of 4 bits. We adjust the number of |
| 1950 | | significant bits by the size of the memory dump (16K, 32K, 64K). |
| 1951 | | */ |
| 1952 | | static WRITE8_DEVICE_HANDLER( write_cart_paged379i ) |
| 1953 | | { |
| 1954 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 1955 | | cartridge_t *cartridge = pcb->cartridge; |
| 1956 | 555 | |
| 1957 | | // Bits: 011x xxxx xxxb bbbx |
| 1958 | | // x = don't care, bbbb = bank |
| 1959 | | set_paged379i_bank(cartridge, 15 - ((offset>>1) & 15)); |
| 556 | /* Read function for the paged379i cartridge. */ |
| 557 | READ8Z_MEMBER(cartridge_pcb_paged379i_device::readz) |
| 558 | { |
| 559 | if ((offset & 0xe000)==0x6000) |
| 560 | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 1960 | 561 | } |
| 1961 | 562 | |
| 1962 | | /* |
| 1963 | | Paged379i modules have one EPROM dump. |
| 1964 | | */ |
| 1965 | | static int assemble_paged379i(device_t *image) |
| 563 | /* Write function for the paged379i cartridge. Only used to set the bank. */ |
| 564 | WRITE8_MEMBER(cartridge_pcb_paged379i_device::write) |
| 1966 | 565 | { |
| 1967 | | cartridge_t *cart; |
| 1968 | | |
| 1969 | | cart = assemble_common(image); |
| 1970 | | if (cart->rom_ptr==NULL) |
| 566 | // Bits: 0110 0000 000b bbbx |
| 567 | // x = don't care, bbbb = bank |
| 568 | if ((offset & 0xffe0)==0x6000) |
| 1971 | 569 | { |
| 1972 | | if (VERBOSE>1) LOG("ti99: gromport: Missing ROM for paged cartridge"); |
| 1973 | | return IMAGE_INIT_FAIL; |
| 570 | // Set bank |
| 571 | m_rom_page = get_paged379i_bank(15 - ((offset>>1) & 15)); |
| 1974 | 572 | } |
| 1975 | | set_paged379i_bank(cart, 15); |
| 1976 | | return IMAGE_INIT_PASS; |
| 1977 | 573 | } |
| 1978 | 574 | |
| 1979 | 575 | /***************************************************************************** |
| r14513 | r14514 | |
| 1995 | 591 | 6 >2000 = 0010 0000 0000 0000 |
| 1996 | 592 | 7 >8000 = 1000 0000 0000 0000 |
| 1997 | 593 | |
| 594 | No GROMs used in this type. |
| 1998 | 595 | ******************************************************************************/ |
| 1999 | 596 | |
| 2000 | | static DEVICE_START(ti99_pcb_pagedcru) |
| 597 | /* Read function for the pagedcru cartridge. */ |
| 598 | READ8Z_MEMBER(cartridge_pcb_pagedcru_device::readz) |
| 2001 | 599 | { |
| 2002 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 2003 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 600 | if ((offset & 0xe000)==0x6000) |
| 601 | *value = m_rom_ptr[(m_rom_page<<13) | (offset & 0x1fff)]; |
| 2004 | 602 | } |
| 2005 | 603 | |
| 2006 | | /* |
| 2007 | | Read handler for the CPU address space of the cartridge |
| 2008 | | Images for this area are found in the rom_sockets. |
| 2009 | | */ |
| 2010 | | static READ8Z_DEVICE_HANDLER( read_cart_pagedcru ) |
| 604 | /* Write function for the pagedcru cartridge. No effect. */ |
| 605 | WRITE8_MEMBER(cartridge_pcb_pagedcru_device::write) |
| 2011 | 606 | { |
| 2012 | | /* device is pcb, owner is cartslot */ |
| 2013 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 2014 | | cartridge_t *cartridge = pcb->cartridge; |
| 2015 | | |
| 2016 | | if (cartridge->rom_ptr!=NULL) |
| 2017 | | { |
| 2018 | | *value = (cartridge->rom_ptr)[cartridge->rom_page*0x2000 + (offset & 0x1fff)]; |
| 2019 | | } |
| 2020 | | } |
| 2021 | | |
| 2022 | | /* |
| 2023 | | This type of cartridge does not support writing to the EPROM address |
| 2024 | | space. |
| 2025 | | */ |
| 2026 | | static WRITE8_DEVICE_HANDLER( write_cart_pagedcru ) |
| 2027 | | { |
| 2028 | 607 | return; |
| 2029 | 608 | } |
| 2030 | 609 | |
| 2031 | | /* |
| 2032 | | The CRU read handler. The CRU is a serial interface in the console. |
| 2033 | | Using the CRU we can switch the banks in the SuperSpace cartridge. |
| 2034 | | For documentation see the corresponding cru function above. Note we are |
| 2035 | | using rom_page here. |
| 2036 | | */ |
| 2037 | | static READ8Z_DEVICE_HANDLER( read_cart_cru_paged ) |
| 610 | void cartridge_pcb_pagedcru_device::crureadz(offs_t offset, UINT8 *value) |
| 2038 | 611 | { |
| 2039 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 2040 | | cartridge_t *cartridge = pcb->cartridge; |
| 2041 | | |
| 2042 | | int page = cartridge->rom_page; |
| 612 | int page = m_rom_page; |
| 2043 | 613 | if ((offset & 0xf800)==0x0800) |
| 2044 | 614 | { |
| 2045 | | int bit = (offset & 0x001e)/2; |
| 615 | int bit = (offset & 0x001e)>>1; |
| 2046 | 616 | if (bit != 0) |
| 2047 | 617 | { |
| 2048 | 618 | page = page-(bit/2); // 4 page flags per 8 bits |
| r14513 | r14514 | |
| 2051 | 621 | } |
| 2052 | 622 | } |
| 2053 | 623 | |
| 2054 | | static WRITE8_DEVICE_HANDLER( write_cart_cru_paged ) |
| 624 | void cartridge_pcb_pagedcru_device::cruwrite(offs_t offset, UINT8 data) |
| 2055 | 625 | { |
| 2056 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 2057 | | cartridge_t *cartridge = pcb->cartridge; |
| 2058 | | |
| 2059 | 626 | if ((offset & 0xf800)==0x0800) |
| 2060 | 627 | { |
| 2061 | | int bit = (offset & 0x001e)/2; |
| 628 | int bit = (offset & 0x001e)>>1; |
| 2062 | 629 | if (data != 0 && bit > 0) |
| 2063 | 630 | { |
| 2064 | | cartridge->rom_page = (bit-1)/2; |
| 631 | m_rom_page = (bit-1)/2; |
| 2065 | 632 | } |
| 2066 | 633 | } |
| 2067 | 634 | } |
| 2068 | 635 | |
| 2069 | | /* |
| 2070 | | Pagedcru modules have one EPROM dump. |
| 2071 | | */ |
| 2072 | | static int assemble_pagedcru(device_t *image) |
| 2073 | | { |
| 2074 | | cartridge_t *cart; |
| 636 | /***************************************************************************** |
| 637 | Cartridge type: GRAMKracker |
| 2075 | 638 | |
| 2076 | | cart = assemble_common(image); |
| 2077 | | if (cart->rom_ptr==NULL) |
| 2078 | | { |
| 2079 | | if (VERBOSE>1) LOG("ti99: gromport: Missing ROM for pagedcru cartridge"); |
| 2080 | | return IMAGE_INIT_FAIL; |
| 2081 | | } |
| 2082 | | cart->rom_page = 0; |
| 2083 | | return IMAGE_INIT_PASS; |
| 2084 | | } |
| 639 | The GK is a big cartridge that fits into the same slot as any other |
| 640 | cartridge but which offers a set of switches, an own cartridge slot, |
| 641 | and buffered RAM inside. Also, it has a built-in ROM called "LOADER". |
| 2085 | 642 | |
| 2086 | | /***************************************************************************** |
| 2087 | | Cartridge type: gramkracker |
| 2088 | | ******************************************************************************/ |
| 643 | Its primary use is to allow the user to copy cartridge contents into the |
| 644 | buffered RAM and to modify it there. That way, ROM cartridges can be |
| 645 | customized. |
| 2089 | 646 | |
| 2090 | | static DEVICE_START(ti99_pcb_gramkracker) |
| 647 | The 80 KiB of the GK are allocated as follows |
| 648 | 00000 - 01fff: GRAM 0 |
| 649 | 02000 - 03fff: GRAM 1 (alternatively, the loader GROM appears here) |
| 650 | 04000 - 05fff: GRAM 2 |
| 651 | 06000 - 0ffff: GRAM 3-7 (alternatively, the guest GROMs appear here) |
| 652 | 10000 - 11fff: RAM 1 |
| 653 | 12000 - 13fff: RAM 2 |
| 654 | |
| 655 | The GK emulates GROMs, but without a readable address counter. Thus it |
| 656 | relies on the console GROMs being still in place. |
| 657 | Also, the GK does not implement a GROM buffer. |
| 658 | |
| 659 | We need to implement a complete second path of handling as it differs |
| 660 | from the multi-cart extender. Eventually, the multi-cart extender and |
| 661 | the GK should be implemented as separate slot devices. |
| 662 | |
| 663 | The GK cartridge type is in fact the internal LOADER ROM. In order to use |
| 664 | the GK, the cartridge must be plugged into one slot, and the "guest" |
| 665 | cartridge of the GK must be plugged into any other slot. Also, the DIP |
| 666 | switch of the multi-cart extender must be set to "GRAM Kracker". |
| 667 | *****************************************************************************/ |
| 668 | |
| 669 | enum |
| 2091 | 670 | { |
| 2092 | | /* device is ti99_cartslot:cartridge:pcb */ |
| 2093 | | // printf("DEVICE_START(ti99_pcb_pagedcru), tag of device=%s\n", device->tag()); |
| 2094 | | set_pointers(device, get_index_from_tagname(device->owner())-1); |
| 671 | CART_AUTO = 0, |
| 672 | CART_1, |
| 673 | CART_2, |
| 674 | CART_3, |
| 675 | CART_4, |
| 676 | CART_GK = 15 |
| 677 | }; |
| 678 | |
| 679 | enum |
| 680 | { |
| 681 | GK_OFF = 0, |
| 682 | GK_NORMAL = 1, |
| 683 | GK_GRAM0 = 0, |
| 684 | GK_OPSYS = 1, |
| 685 | GK_GRAM12 = 0, |
| 686 | GK_TIBASIC = 1, |
| 687 | GK_BANK1 = 0, |
| 688 | GK_WP = 1, |
| 689 | GK_BANK2 = 2, |
| 690 | GK_LDON = 0, |
| 691 | GK_LDOFF = 1 |
| 692 | }; |
| 693 | |
| 694 | void cartridge_pcb_gramkracker_device::set_gk_guest(cartridge_device* guest) |
| 695 | { |
| 696 | m_gk_guest = guest; |
| 2095 | 697 | } |
| 2096 | 698 | |
| 2097 | 699 | /* |
| 2098 | | The GRAM Kracker contains one GROM and several buffered RAM chips |
| 700 | Read function for the GRAMKracker cartridge. |
| 2099 | 701 | */ |
| 2100 | | static int assemble_gramkracker(device_t *image) |
| 702 | READ8Z_MEMBER(cartridge_pcb_gramkracker_device::readz) |
| 2101 | 703 | { |
| 2102 | | cartridge_t *cart; |
| 2103 | | int id,i; |
| 704 | if ((offset & GROM_MASK) == GROM_AREA) |
| 705 | { |
| 706 | // Reads from the GRAM space of the GRAM Kracker. |
| 707 | // m_gk_slot is the slot where the GK module is plugged in |
| 708 | // m_gk_guest_slot is the slot where the cartridge is plugged in |
| 2104 | 709 | |
| 2105 | | device_t *cartsys = image->owner(); |
| 2106 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 710 | // The GK does not have a readable address counter, but the console |
| 711 | // GROMs will keep our address counter up to date. That is |
| 712 | // exactly what happens in the real machine. |
| 713 | // (The console GROMs are not accessed here but directly via the datamux |
| 714 | // so we can just return without doing anything) |
| 715 | if ((offset & 0x0002)!=0) return; |
| 2107 | 716 | |
| 2108 | | cart = assemble_common(image); |
| 717 | int id = ((m_grom_address & 0xe000)>>13)&0x07; |
| 718 | switch (id) |
| 719 | { |
| 720 | case 0: |
| 721 | // GRAM 0. Only return a value if switch 2 is in GRAM0 position. |
| 722 | if (m_gk_switch[2]==GK_GRAM0) |
| 723 | *value = m_ram_ptr[m_grom_address]; |
| 724 | break; |
| 725 | case 1: |
| 726 | // If the loader is turned on, return loader contents. |
| 727 | if (m_gk_switch[5]==GK_LDON) |
| 728 | { |
| 729 | // The only ROM contained in the GK box is the loader |
| 730 | // Adjust the address |
| 731 | *value = m_grom_ptr[m_grom_address & 0x1fff]; |
| 732 | } |
| 733 | else |
| 734 | { |
| 735 | // Loader off |
| 736 | // GRAM 1. Only return a value if switch 3 is in GRAM12 position. |
| 737 | // Otherwise, the console GROM 1 will respond (not here; it is the grom_device |
| 738 | // whose output would then not be overwritten) |
| 739 | if (m_gk_switch[3]==GK_GRAM12) |
| 740 | *value = m_ram_ptr[m_grom_address]; |
| 741 | } |
| 742 | break; |
| 743 | case 2: |
| 744 | // GRAM 2. Only return a value if switch 3 is in GRAM12 position. |
| 745 | if (m_gk_switch[3]==GK_GRAM12) |
| 746 | *value = m_ram_ptr[m_grom_address]; |
| 747 | break; |
| 748 | default: |
| 749 | // Cartridge space (0x6000 - 0xffff) |
| 750 | // When a cartridge is installed, it overrides the GK contents |
| 751 | // but only if it has GROMs |
| 752 | bool guest_has_grom = false; |
| 2109 | 753 | |
| 2110 | | if (cart->grom_ptr==NULL) |
| 2111 | | { |
| 2112 | | if (VERBOSE>1) LOG("ti99: gromport: Missing loader GROM for GRAM Kracker system"); |
| 2113 | | return IMAGE_INIT_FAIL; |
| 2114 | | } |
| 754 | if (m_gk_guest != NULL) |
| 755 | { |
| 756 | guest_has_grom = (m_gk_guest->has_grom()); |
| 757 | // Note that we only have ONE real cartridge and the GK; |
| 758 | // we need not access all slots. |
| 759 | if (guest_has_grom) |
| 760 | { |
| 761 | m_gk_guest->readz(space, offset, value, mem_mask); // read from guest |
| 762 | } |
| 763 | } |
| 764 | if (!guest_has_grom && (m_gk_switch[1]==GK_NORMAL)) |
| 765 | *value = m_ram_ptr[m_grom_address]; // use the GK memory |
| 766 | } |
| 2115 | 767 | |
| 2116 | | if (cart->ram_size < 81920) |
| 2117 | | { |
| 2118 | | if (VERBOSE>1) LOG("ti99: gromport: Missing or insufficient RAM for GRAM Kracker system"); |
| 2119 | | return IMAGE_INIT_FAIL; |
| 2120 | | } |
| 768 | // The GK GROM emulation does not wrap at 8K boundaries. |
| 769 | m_grom_address = (m_grom_address + 1) & 0xffff; |
| 2121 | 770 | |
| 2122 | | // Get slot number |
| 2123 | | id = get_index_from_tagname(image); |
| 2124 | | cartslots->gk_slot = id-1; |
| 2125 | | cartslots->gk_guest_slot = -1; |
| 2126 | | // The first cartridge that is still plugged in is the "guest" of the |
| 2127 | | // GRAM Kracker |
| 2128 | | for (i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 771 | // Reset the write address flipflop. |
| 772 | m_waddr_LSB = false; |
| 773 | } |
| 774 | else |
| 2129 | 775 | { |
| 2130 | | if (!slot_is_empty(cartsys, i) && (i != cartslots->gk_slot)) |
| 776 | if (m_gk_guest != NULL) |
| 2131 | 777 | { |
| 2132 | | cartslots->gk_guest_slot = i; |
| 2133 | | break; |
| 778 | // Read from the guest cartridge. |
| 779 | m_gk_guest->readz(space, offset, value, mem_mask); |
| 2134 | 780 | } |
| 781 | else |
| 782 | { |
| 783 | // Reads from the RAM space of the GRAM Kracker. |
| 784 | if (m_gk_switch[1] == GK_OFF) return; // just don't do anything |
| 785 | switch (m_gk_switch[4]) |
| 786 | { |
| 787 | // RAM is stored behind the GRAM area |
| 788 | case GK_BANK1: |
| 789 | *value = m_ram_ptr[offset+0x10000 - 0x6000]; |
| 790 | |
| 791 | case GK_BANK2: |
| 792 | *value = m_ram_ptr[offset+0x12000 - 0x6000]; |
| 793 | |
| 794 | default: |
| 795 | // Switch in middle position (WP, implies auto-select according to the page flag) |
| 796 | if (m_ram_page==0) |
| 797 | *value = m_ram_ptr[offset+0x10000 - 0x6000]; |
| 798 | else |
| 799 | *value = m_ram_ptr[offset+0x12000 - 0x6000]; |
| 800 | } |
| 801 | } |
| 2135 | 802 | } |
| 2136 | | return IMAGE_INIT_PASS; |
| 2137 | 803 | } |
| 2138 | 804 | |
| 2139 | 805 | /* |
| 2140 | | Unplugs the GRAM Kracker. The "guest" is still plugged in, but will be |
| 2141 | | treated as normal. |
| 806 | See above. |
| 2142 | 807 | */ |
| 2143 | | static int disassemble_gramkracker(device_t *cartslot) |
| 808 | WRITE8_MEMBER(cartridge_pcb_gramkracker_device::write) |
| 2144 | 809 | { |
| 2145 | | device_t *cartsys = cartslot->owner(); |
| 2146 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 810 | // write to the guest cartridge if present |
| 811 | if (m_gk_guest != NULL) |
| 812 | { |
| 813 | m_gk_guest->write(space, offset, data, mem_mask); |
| 814 | } |
| 2147 | 815 | |
| 2148 | | //int slotnumber = get_index_from_tagname(cartslot)-1; |
| 2149 | | //assert(slotnumber>=0 && slotnumber<NUMBER_OF_CARTRIDGE_SLOTS); |
| 816 | if ((offset & GROM_MASK) == GROM_AREA) |
| 817 | { |
| 818 | // Writes to the GRAM space of the GRAM Kracker. |
| 819 | if ((offset & 0x0002)==0x0002) |
| 820 | { |
| 821 | // Set address |
| 822 | if (m_waddr_LSB == true) |
| 823 | { |
| 824 | // Accept low address byte (second write) |
| 825 | m_grom_address = (m_grom_address & 0xff00) | data; |
| 826 | m_waddr_LSB = false; |
| 827 | } |
| 828 | else |
| 829 | { |
| 830 | // Accept high address byte (first write) |
| 831 | m_grom_address = (m_grom_address & 0x00ff) | (data << 8); |
| 832 | m_waddr_LSB = true; |
| 833 | } |
| 834 | } |
| 835 | else |
| 836 | { |
| 837 | // Write data byte to GRAM area. |
| 2150 | 838 | |
| 2151 | | cartslots->gk_slot = -1; |
| 2152 | | cartslots->gk_guest_slot = -1; |
| 839 | // According to manual: |
| 840 | // Writing to GRAM 0: switch 2 set to GRAM 0 + Write protect switch (4) in 1 or 2 position |
| 841 | // Writing to GRAM 1: switch 3 set to GRAM 1-2 + Loader off (5); write prot has no effect |
| 842 | // Writing to GRAM 2: switch 3 set to GRAM 1-2 (write prot has no effect) |
| 843 | // Writing to GRAM 3-7: switch 1 set to GK_NORMAL, no cartridge inserted |
| 844 | // GK_NORMAL switch has no effect on GRAM 0-2 |
| 845 | int id = ((m_grom_address & 0xe000)>>13)&0x07; |
| 846 | switch (id) |
| 847 | { |
| 848 | case 0: |
| 849 | if (m_gk_switch[2]==GK_GRAM0 && m_gk_switch[4]!=GK_WP) |
| 850 | m_ram_ptr[m_grom_address] = data; |
| 851 | break; |
| 852 | case 1: |
| 853 | if (m_gk_switch[3]==GK_GRAM12 && m_gk_switch[5]==GK_LDOFF) |
| 854 | m_ram_ptr[m_grom_address] = data; |
| 855 | break; |
| 856 | case 2: |
| 857 | if (m_gk_switch[3]==GK_GRAM12) |
| 858 | m_ram_ptr[m_grom_address] = data; |
| 859 | break; |
| 860 | default: |
| 861 | if (m_gk_switch[1]==GK_NORMAL && m_gk_guest != NULL) |
| 862 | m_ram_ptr[m_grom_address] = data; |
| 863 | break; |
| 864 | } |
| 865 | // The GK GROM emulation does not wrap at 8K boundaries. |
| 866 | m_grom_address = (m_grom_address + 1) & 0xffff; |
| 2153 | 867 | |
| 2154 | | return disassemble_std(cartslot); |
| 2155 | | } |
| 868 | // Reset the write address flipflop. |
| 869 | m_waddr_LSB = false; |
| 870 | } |
| 871 | } |
| 872 | else |
| 873 | { |
| 874 | // Write to the RAM space of the GRAM Kracker. |
| 875 | if (m_gk_guest == NULL) |
| 876 | { |
| 877 | if (m_gk_switch[1] == GK_OFF) return; // just don't do anything |
| 878 | switch (m_gk_switch[4]) |
| 879 | { |
| 880 | // RAM is stored behind the GRAM area |
| 881 | case GK_BANK1: |
| 882 | m_ram_ptr[offset+0x10000 - 0x6000] = data; |
| 883 | break; |
| 2156 | 884 | |
| 885 | case GK_BANK2: |
| 886 | m_ram_ptr[offset+0x12000 - 0x6000] = data; |
| 887 | break; |
| 2157 | 888 | |
| 2158 | | /***************************************************************************** |
| 2159 | | Device metadata |
| 2160 | | ******************************************************************************/ |
| 889 | default: |
| 890 | // Switch in middle position (WP, implies auto-select according to the page flag) |
| 891 | // This is handled like in Extended Basic (using addresses) |
| 892 | m_ram_page = (offset >> 1) & 1; |
| 893 | break; |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | } |
| 2161 | 898 | |
| 2162 | 899 | /* |
| 2163 | | Get the pointer to the GROM data from the cartridge. Called by the GROM. |
| 900 | Read cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 2164 | 901 | */ |
| 2165 | | static UINT8 *get_grom_ptr(device_t *device) |
| 902 | void cartridge_pcb_gramkracker_device::crureadz(offs_t offset, UINT8 *value) |
| 2166 | 903 | { |
| 2167 | | ti99_pcb_t *pcb = get_safe_pcb_token(device); |
| 2168 | | return pcb->cartridge->grom_ptr; |
| 904 | if (m_gk_guest != NULL) m_gk_guest->crureadz(offset, value); |
| 2169 | 905 | } |
| 2170 | 906 | |
| 2171 | | static MACHINE_CONFIG_FRAGMENT(ti99_cart_common) |
| 2172 | | MCFG_GROM_ADD_P( "grom_3", 3, get_grom_ptr, 0x0000, 0x1800, cart_grom_ready ) |
| 2173 | | MCFG_GROM_ADD_P( "grom_4", 4, get_grom_ptr, 0x2000, 0x1800, cart_grom_ready ) |
| 2174 | | MCFG_GROM_ADD_P( "grom_5", 5, get_grom_ptr, 0x4000, 0x1800, cart_grom_ready ) |
| 2175 | | MCFG_GROM_ADD_P( "grom_6", 6, get_grom_ptr, 0x6000, 0x1800, cart_grom_ready ) |
| 2176 | | MCFG_GROM_ADD_P( "grom_7", 7, get_grom_ptr, 0x8000, 0x1800, cart_grom_ready ) |
| 2177 | | MACHINE_CONFIG_END |
| 2178 | | |
| 2179 | | static DEVICE_GET_INFO(ti99_cart_common) |
| 907 | /* |
| 908 | Write cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 909 | */ |
| 910 | void cartridge_pcb_gramkracker_device::cruwrite(offs_t offset, UINT8 data) |
| 2180 | 911 | { |
| 2181 | | switch(state) |
| 2182 | | { |
| 2183 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2184 | | case DEVINFO_INT_TOKEN_BYTES: |
| 2185 | | info->i = sizeof(ti99_pcb_t); |
| 2186 | | break; |
| 2187 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: |
| 2188 | | info->i = 0; |
| 2189 | | break; |
| 912 | if (m_gk_guest != NULL) m_gk_guest->cruwrite(offset, data); |
| 913 | } |
| 2190 | 914 | |
| 2191 | | case DEVINFO_PTR_MACHINE_CONFIG: |
| 2192 | | info->machine_config = MACHINE_CONFIG_NAME(ti99_cart_common); |
| 2193 | | break; |
| 915 | /***************************************************************************** |
| 916 | A cartridge. In fact, just the empty cartridge, as the image to be loaded |
| 917 | will be included as the PCB. |
| 918 | *****************************************************************************/ |
| 2194 | 919 | |
| 2195 | | /* --- the following bits of info are returned as pointers to functions --- */ |
| 2196 | | case DEVINFO_FCT_START: |
| 2197 | | info->start = DEVICE_START_NAME(ti99_pcb_std); |
| 2198 | | break; |
| 2199 | | case DEVINFO_FCT_STOP: |
| 2200 | | /* Nothing */ |
| 2201 | | break; |
| 2202 | | case DEVINFO_FCT_RESET: |
| 2203 | | /* Nothing */ |
| 2204 | | break; |
| 2205 | | case TI99CARTINFO_FCT_6000_R: |
| 2206 | | info->f = (genf *) read_cart_std; break; |
| 920 | static const pcb_type pcbdefs[] = |
| 921 | { |
| 922 | { PCB_STANDARD, "standard" }, |
| 923 | { PCB_PAGED, "paged" }, |
| 924 | { PCB_MINIMEM, "minimem" }, |
| 925 | { PCB_SUPER, "super" }, |
| 926 | { PCB_MBX, "mbx" }, |
| 927 | { PCB_PAGED379I, "paged379i" }, |
| 928 | { PCB_PAGEDCRU, "pagedcru" }, |
| 929 | { PCB_GKRACKER, "gramkracker" }, |
| 930 | { 0, NULL} |
| 931 | }; |
| 2207 | 932 | |
| 2208 | | case TI99CARTINFO_FCT_6000_W: |
| 2209 | | info->f = (genf *) write_cart_std; break; |
| 933 | cartridge_device::cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 934 | : bus8z_device(mconfig, TICARTRIDGE, "TI-99 cartridge", tag, owner, clock), |
| 935 | device_image_interface(mconfig, *this), |
| 936 | m_pcb(NULL) |
| 937 | { |
| 938 | m_shortname = "cartridge"; |
| 939 | } |
| 2210 | 940 | |
| 2211 | | case TI99CARTINFO_FCT_CRU_R: |
| 2212 | | /* Nothing */ |
| 2213 | | break; |
| 941 | void cartridge_device::device_start() |
| 942 | { |
| 943 | if (VERBOSE>7) LOG("cartridge_device: device_start\n"); |
| 944 | } |
| 2214 | 945 | |
| 2215 | | case TI99CARTINFO_FCT_CRU_W: |
| 2216 | | /* Nothing */ |
| 2217 | | break; |
| 2218 | | |
| 2219 | | case TI99CART_FCT_ASSM: |
| 2220 | | info->f = (genf *) assemble_std; |
| 2221 | | break; |
| 2222 | | |
| 2223 | | case TI99CART_FCT_DISASSM: |
| 2224 | | info->f = (genf *) disassemble_std; |
| 2225 | | break; |
| 2226 | | |
| 2227 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2228 | | case DEVINFO_STR_NAME: |
| 2229 | | strcpy(info->s, "TI99 standard cartridge pcb"); |
| 2230 | | break; |
| 2231 | | case DEVINFO_STR_FAMILY: |
| 2232 | | strcpy(info->s, "TI99 cartridge pcb"); |
| 2233 | | break; |
| 2234 | | case DEVINFO_STR_VERSION: |
| 2235 | | strcpy(info->s, "1.0"); |
| 2236 | | break; |
| 2237 | | case DEVINFO_STR_SOURCE_FILE: |
| 2238 | | strcpy(info->s, __FILE__); |
| 2239 | | break; |
| 2240 | | case DEVINFO_STR_CREDITS: |
| 2241 | | /* Nothing */ |
| 2242 | | break; |
| 2243 | | } |
| 946 | void cartridge_device::device_stop() |
| 947 | { |
| 948 | if (VERBOSE>7) LOG("cartridge_device: device_stop\n"); |
| 2244 | 949 | } |
| 2245 | 950 | |
| 2246 | | DEVICE_GET_INFO(ti99_cartridge_pcb_none) |
| 951 | void cartridge_device::device_reset() |
| 2247 | 952 | { |
| 2248 | | switch(state) |
| 953 | if (m_type==PCB_GKRACKER) |
| 2249 | 954 | { |
| 2250 | | case DEVINFO_FCT_START: |
| 2251 | | info->start = DEVICE_START_NAME(ti99_pcb_none); |
| 2252 | | break; |
| 2253 | | |
| 2254 | | case DEVINFO_STR_NAME: |
| 2255 | | strcpy(info->s, "TI99 empty cartridge"); |
| 2256 | | break; |
| 2257 | | |
| 2258 | | // Don't create GROMs |
| 2259 | | case DEVINFO_PTR_MACHINE_CONFIG: |
| 2260 | | break; |
| 2261 | | |
| 2262 | | default: |
| 2263 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2264 | | break; |
| 955 | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 956 | pcb->m_gk_switch[1] = input_port_read(*owner(), GKSWITCH1_TAG); |
| 957 | pcb->m_gk_switch[2] = input_port_read(*owner(), GKSWITCH2_TAG); |
| 958 | pcb->m_gk_switch[3] = input_port_read(*owner(), GKSWITCH3_TAG); |
| 959 | pcb->m_gk_switch[4] = input_port_read(*owner(), GKSWITCH4_TAG); |
| 960 | pcb->m_gk_switch[5] = input_port_read(*owner(), GKSWITCH5_TAG); |
| 2265 | 961 | } |
| 2266 | 962 | } |
| 2267 | 963 | |
| 2268 | | DEVICE_GET_INFO(ti99_cartridge_pcb_std) |
| 964 | void cartridge_device::device_config_complete() |
| 2269 | 965 | { |
| 2270 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 966 | if (VERBOSE>8) LOG("cartridge_device: device_config_complete\n"); |
| 967 | update_names(); |
| 2271 | 968 | } |
| 2272 | 969 | |
| 2273 | | DEVICE_GET_INFO(ti99_cartridge_pcb_paged) |
| 970 | void cartridge_device::prepare_cartridge() |
| 2274 | 971 | { |
| 2275 | | switch(state) |
| 2276 | | { |
| 2277 | | case DEVINFO_FCT_START: |
| 2278 | | info->start = DEVICE_START_NAME(ti99_pcb_paged); |
| 2279 | | break; |
| 972 | int rom2_length; |
| 2280 | 973 | |
| 2281 | | case TI99CART_FCT_ASSM: |
| 2282 | | info->f = (genf *) assemble_paged; |
| 2283 | | break; |
| 974 | UINT8* grom_ptr; |
| 2284 | 975 | |
| 2285 | | case TI99CARTINFO_FCT_6000_R: |
| 2286 | | info->f = (genf *) read_cart_paged; |
| 2287 | | break; |
| 976 | const memory_region *regg; |
| 977 | const memory_region *regr; |
| 978 | const memory_region *regr2; |
| 2288 | 979 | |
| 2289 | | case TI99CARTINFO_FCT_6000_W: |
| 2290 | | info->f = (genf *) write_cart_paged; |
| 2291 | | break; |
| 980 | m_pcb->m_grom_size = m_rpk->get_resource_length("grom_socket"); |
| 2292 | 981 | |
| 2293 | | case DEVINFO_STR_NAME: |
| 2294 | | strcpy(info->s, "TI99 paged cartridge pcb"); |
| 2295 | | break; |
| 982 | if (m_pcb->m_grom_size > 0) |
| 983 | { |
| 984 | regg = subregion("grom_contents"); |
| 985 | grom_ptr = (UINT8*)m_rpk->get_contents_of_socket("grom_socket"); |
| 986 | memcpy(regg->base(), grom_ptr, m_pcb->m_grom_size); |
| 2296 | 987 | |
| 2297 | | default: |
| 2298 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2299 | | break; |
| 988 | if (m_type==PCB_GKRACKER) |
| 989 | { |
| 990 | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 991 | pcb->m_grom_ptr = grom_ptr; |
| 992 | } |
| 993 | |
| 994 | // Find the GROMs and keep their pointers |
| 995 | m_pcb->m_grom[0] = static_cast<ti99_grom_device*>(subdevice(GROM3_TAG)); |
| 996 | if (m_pcb->m_grom_size > 0x2000) m_pcb->m_grom[1] = static_cast<ti99_grom_device*>(subdevice(GROM4_TAG)); |
| 997 | if (m_pcb->m_grom_size > 0x4000) m_pcb->m_grom[2] = static_cast<ti99_grom_device*>(subdevice(GROM5_TAG)); |
| 998 | if (m_pcb->m_grom_size > 0x6000) m_pcb->m_grom[3] = static_cast<ti99_grom_device*>(subdevice(GROM6_TAG)); |
| 999 | if (m_pcb->m_grom_size > 0x8000) m_pcb->m_grom[4] = static_cast<ti99_grom_device*>(subdevice(GROM7_TAG)); |
| 2300 | 1000 | } |
| 2301 | | } |
| 2302 | 1001 | |
| 2303 | | DEVICE_GET_INFO(ti99_cartridge_pcb_minimem) |
| 2304 | | { |
| 2305 | | switch(state) |
| 1002 | m_pcb->m_rom_size = m_rpk->get_resource_length("rom_socket"); |
| 1003 | if (m_pcb->m_rom_size > 0) |
| 2306 | 1004 | { |
| 2307 | | case DEVINFO_FCT_START: |
| 2308 | | info->start = DEVICE_START_NAME(ti99_pcb_minimem); |
| 2309 | | break; |
| 1005 | regr = subregion("rom_contents"); |
| 1006 | m_pcb->m_rom_ptr = (UINT8*)m_rpk->get_contents_of_socket("rom_socket"); |
| 1007 | memcpy(regr->base(), m_pcb->m_rom_ptr, m_pcb->m_rom_size); |
| 1008 | } |
| 2310 | 1009 | |
| 2311 | | case TI99CART_FCT_ASSM: |
| 2312 | | info->f = (genf *) assemble_minimem; |
| 2313 | | break; |
| 2314 | | case TI99CARTINFO_FCT_6000_R: |
| 2315 | | info->f = (genf *) read_cart_minimem; |
| 2316 | | break; |
| 2317 | | case TI99CARTINFO_FCT_6000_W: |
| 2318 | | info->f = (genf *) write_cart_minimem; |
| 2319 | | break; |
| 1010 | rom2_length = m_rpk->get_resource_length("rom2_socket"); |
| 1011 | if (rom2_length > 0) |
| 1012 | { |
| 1013 | // sizes do not differ between rom and rom2 |
| 1014 | regr2 = subregion("rom2_contents"); |
| 1015 | m_pcb->m_rom2_ptr = (UINT8*)m_rpk->get_contents_of_socket("rom2_socket"); |
| 1016 | memcpy(regr2->base(), m_pcb->m_rom2_ptr, rom2_length); |
| 1017 | } |
| 2320 | 1018 | |
| 2321 | | case DEVINFO_STR_NAME: |
| 2322 | | strcpy(info->s, "TI99 MiniMemory cartridge pcb"); |
| 2323 | | break; |
| 2324 | | |
| 2325 | | default: |
| 2326 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2327 | | break; |
| 1019 | m_pcb->m_ram_size = m_rpk->get_resource_length("ram_socket"); |
| 1020 | if (m_pcb->m_ram_size > 0) |
| 1021 | { |
| 1022 | // TODO: Consider to use a region as well. If so, do not forget to memcpy. |
| 1023 | m_pcb->m_ram_ptr = (UINT8*)m_rpk->get_contents_of_socket("ram_socket"); |
| 2328 | 1024 | } |
| 2329 | 1025 | } |
| 2330 | 1026 | |
| 2331 | | DEVICE_GET_INFO(ti99_cartridge_pcb_super) |
| 1027 | bool cartridge_device::has_grom() |
| 2332 | 1028 | { |
| 2333 | | switch(state) |
| 2334 | | { |
| 2335 | | case DEVINFO_FCT_START: |
| 2336 | | info->start = DEVICE_START_NAME(ti99_pcb_super); |
| 2337 | | break; |
| 2338 | | |
| 2339 | | case TI99CART_FCT_ASSM: |
| 2340 | | info->f = (genf *) assemble_super; |
| 2341 | | break; |
| 2342 | | case TI99CARTINFO_FCT_6000_R: |
| 2343 | | info->f = (genf *) read_cart_super; |
| 2344 | | break; |
| 2345 | | case TI99CARTINFO_FCT_6000_W: |
| 2346 | | info->f = (genf *) write_cart_super; |
| 2347 | | break; |
| 2348 | | case TI99CARTINFO_FCT_CRU_R: |
| 2349 | | info->f = (genf *) read_cart_cru; |
| 2350 | | break; |
| 2351 | | case TI99CARTINFO_FCT_CRU_W: |
| 2352 | | info->f = (genf *) write_cart_cru; |
| 2353 | | break; |
| 2354 | | |
| 2355 | | // Don't create GROMs |
| 2356 | | case DEVINFO_PTR_MACHINE_CONFIG: |
| 2357 | | break; |
| 2358 | | |
| 2359 | | case DEVINFO_STR_NAME: |
| 2360 | | strcpy(info->s, "TI99 SuperSpace cartridge pcb"); |
| 2361 | | break; |
| 2362 | | |
| 2363 | | default: |
| 2364 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2365 | | break; |
| 2366 | | } |
| 1029 | assert (m_pcb != NULL); |
| 1030 | return (m_pcb->m_grom_size>0); |
| 2367 | 1031 | } |
| 2368 | 1032 | |
| 2369 | | DEVICE_GET_INFO(ti99_cartridge_pcb_mbx) |
| 1033 | void cartridge_device::set_gk_guest(cartridge_device* guest) |
| 2370 | 1034 | { |
| 2371 | | switch(state) |
| 2372 | | { |
| 2373 | | case DEVINFO_FCT_START: |
| 2374 | | info->start = DEVICE_START_NAME(ti99_pcb_mbx); |
| 2375 | | break; |
| 1035 | assert (m_pcb != NULL); |
| 1036 | assert (m_rpk->get_type()==PCB_GKRACKER); |
| 2376 | 1037 | |
| 2377 | | case TI99CART_FCT_ASSM: |
| 2378 | | info->f = (genf *) assemble_mbx; |
| 2379 | | break; |
| 2380 | | case TI99CARTINFO_FCT_6000_R: |
| 2381 | | info->f = (genf *) read_cart_mbx; |
| 2382 | | break; |
| 2383 | | case TI99CARTINFO_FCT_6000_W: |
| 2384 | | info->f = (genf *) write_cart_mbx; |
| 2385 | | break; |
| 2386 | | |
| 2387 | | case DEVINFO_STR_NAME: |
| 2388 | | strcpy(info->s, "TI99 MBX cartridge pcb"); |
| 2389 | | break; |
| 2390 | | |
| 2391 | | default: |
| 2392 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2393 | | break; |
| 2394 | | } |
| 1038 | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 1039 | pcb->set_gk_guest(guest); |
| 2395 | 1040 | } |
| 2396 | 1041 | |
| 2397 | | DEVICE_GET_INFO(ti99_cartridge_pcb_paged379i) |
| 1042 | void cartridge_device::set_switch(int swtch, int val) |
| 2398 | 1043 | { |
| 2399 | | switch(state) |
| 2400 | | { |
| 2401 | | case DEVINFO_FCT_START: |
| 2402 | | info->start = DEVICE_START_NAME(ti99_pcb_paged379i); |
| 2403 | | break; |
| 1044 | assert (m_pcb != NULL); |
| 1045 | assert (m_rpk->get_type()==PCB_GKRACKER); |
| 1046 | cartridge_pcb_gramkracker_device* pcb = static_cast<cartridge_pcb_gramkracker_device*>(m_pcb); |
| 1047 | pcb->m_gk_switch[swtch] = val; |
| 1048 | } |
| 2404 | 1049 | |
| 2405 | | case TI99CART_FCT_ASSM: |
| 2406 | | info->f = (genf *) assemble_paged379i; break; |
| 2407 | 1050 | |
| 2408 | | case TI99CARTINFO_FCT_6000_R: |
| 2409 | | info->f = (genf *) read_cart_paged379i; |
| 2410 | | break; |
| 1051 | bool cartridge_device::call_load() |
| 1052 | { |
| 1053 | // File name is in m_basename |
| 1054 | // return true = error |
| 1055 | if (VERBOSE>8) LOG("cartridge_device: loading\n"); |
| 1056 | rpk_reader *reader = new rpk_reader(pcbdefs); |
| 2411 | 1057 | |
| 2412 | | case TI99CARTINFO_FCT_6000_W: |
| 2413 | | info->f = (genf *) write_cart_paged379i; |
| 2414 | | break; |
| 1058 | astring ntag(tag(), ":PCB"); |
| 1059 | const char* mytag = ntag.cstr(); |
| 2415 | 1060 | |
| 2416 | | case DEVINFO_STR_NAME: |
| 2417 | | strcpy(info->s, "TI99 paged379i cartridge pcb"); |
| 2418 | | break; |
| 1061 | gromport_device *gp = static_cast<gromport_device*>(owner()); |
| 1062 | int slot = get_index_from_tagname(); |
| 2419 | 1063 | |
| 2420 | | default: |
| 2421 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2422 | | break; |
| 2423 | | } |
| 2424 | | } |
| 2425 | | |
| 2426 | | DEVICE_GET_INFO(ti99_cartridge_pcb_pagedcru) |
| 2427 | | { |
| 2428 | | switch(state) |
| 1064 | try |
| 2429 | 1065 | { |
| 2430 | | case DEVINFO_FCT_START: |
| 2431 | | info->start = DEVICE_START_NAME(ti99_pcb_pagedcru); |
| 1066 | m_rpk = reader->open(machine().options(), m_basename, machine().system().name); |
| 1067 | m_type = m_rpk->get_type(); |
| 1068 | switch (m_type) |
| 1069 | { |
| 1070 | case PCB_STANDARD: |
| 1071 | if (VERBOSE>6) LOG("cartridge_device: standard PCB\n"); |
| 1072 | m_pcb = static_cast<cartridge_pcb_standard_device*>(&machine().add_dynamic_device(*this, TICARTPCBSTD, mytag, 0)); |
| 2432 | 1073 | break; |
| 2433 | | |
| 2434 | | case TI99CART_FCT_ASSM: |
| 2435 | | info->f = (genf *) assemble_pagedcru; |
| 1074 | case PCB_PAGED: |
| 1075 | if (VERBOSE>6) LOG("cartridge_device: paged PCB\n"); |
| 1076 | m_pcb = static_cast<cartridge_pcb_paged_device*>(&machine().add_dynamic_device(*this, TICARTPCBPAG, mytag, 0)); |
| 2436 | 1077 | break; |
| 2437 | | |
| 2438 | | case TI99CARTINFO_FCT_6000_R: |
| 2439 | | info->f = (genf *) read_cart_pagedcru; |
| 1078 | case PCB_MINIMEM: |
| 1079 | if (VERBOSE>6) LOG("cartridge_device: minimem PCB\n"); |
| 1080 | m_pcb = static_cast<cartridge_pcb_minimem_device*>(&machine().add_dynamic_device(*this, TICARTPCBMIN, mytag, 0)); |
| 2440 | 1081 | break; |
| 2441 | | |
| 2442 | | case TI99CARTINFO_FCT_6000_W: |
| 2443 | | info->f = (genf *) write_cart_pagedcru; |
| 1082 | case PCB_SUPER: |
| 1083 | if (VERBOSE>6) LOG("cartridge_device: superspace PCB\n"); |
| 1084 | m_pcb = static_cast<cartridge_pcb_superspace_device*>(&machine().add_dynamic_device(*this, TICARTPCBSUP, mytag, 0)); |
| 2444 | 1085 | break; |
| 2445 | | |
| 2446 | | case TI99CARTINFO_FCT_CRU_R: |
| 2447 | | info->f = (genf *) read_cart_cru_paged; |
| 1086 | case PCB_MBX: |
| 1087 | if (VERBOSE>6) LOG("cartridge_device: MBX PCB\n"); |
| 1088 | m_pcb = static_cast<cartridge_pcb_mbx_device*>(&machine().add_dynamic_device(*this, TICARTPCBMBX, mytag, 0)); |
| 2448 | 1089 | break; |
| 2449 | | case TI99CARTINFO_FCT_CRU_W: |
| 2450 | | info->f = (genf *) write_cart_cru_paged; |
| 1090 | case PCB_PAGED379I: |
| 1091 | if (VERBOSE>6) LOG("cartridge_device: Paged379i PCB\n"); |
| 1092 | m_pcb = static_cast<cartridge_pcb_paged379i_device*>(&machine().add_dynamic_device(*this, TICARTPCBPGI, mytag, 0)); |
| 2451 | 1093 | break; |
| 2452 | | |
| 2453 | | case DEVINFO_STR_NAME: |
| 2454 | | strcpy(info->s, "TI99 pagedcru cartridge pcb"); |
| 1094 | case PCB_PAGEDCRU: |
| 1095 | if (VERBOSE>6) LOG("cartridge_device: PagedCRU PCB\n"); |
| 1096 | m_pcb = static_cast<cartridge_pcb_pagedcru_device*>(&machine().add_dynamic_device(*this, TICARTPCBPGC, mytag, 0)); |
| 2455 | 1097 | break; |
| 2456 | | |
| 2457 | | default: |
| 2458 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 1098 | case PCB_GKRACKER: |
| 1099 | if (VERBOSE>6) LOG("cartridge_device: GRAMKracker PCB\n"); |
| 1100 | m_pcb = static_cast<cartridge_pcb_gramkracker_device*>(&machine().add_dynamic_device(*this, TICARTPCBGRK, mytag, 0)); |
| 1101 | gp->set_gk_slot(slot); |
| 2459 | 1102 | break; |
| 1103 | } |
| 1104 | |
| 1105 | prepare_cartridge(); |
| 1106 | m_pcb->set_machine(machine()); // TODO: Feels like a hack. |
| 1107 | gp->change_slot(true, slot); |
| 1108 | |
| 1109 | machine().schedule_hard_reset(); // could be configurable by DIP switch, simulating taping the RESET line |
| 2460 | 1110 | } |
| 1111 | catch (rpk_exception& err) |
| 1112 | { |
| 1113 | LOG("Failed to load cartridge '%s': %s\n", basename(), err.to_string()); |
| 1114 | m_rpk = NULL; |
| 1115 | m_err = IMAGE_ERROR_INVALIDIMAGE; |
| 1116 | return true; |
| 1117 | } |
| 1118 | return false; |
| 2461 | 1119 | } |
| 2462 | 1120 | |
| 2463 | | DEVICE_GET_INFO(ti99_cartridge_pcb_gramkracker) |
| 1121 | void cartridge_device::call_unload() |
| 2464 | 1122 | { |
| 2465 | | switch(state) |
| 1123 | if (VERBOSE>6) LOG("cartridge_device: unloading from %s\n", tag()); |
| 1124 | |
| 1125 | gromport_device *gp = static_cast<gromport_device*>(owner()); |
| 1126 | int slot = get_index_from_tagname(); |
| 1127 | if (slot == gp->m_gk_slot) |
| 2466 | 1128 | { |
| 2467 | | case DEVINFO_FCT_START: |
| 2468 | | info->start = DEVICE_START_NAME(ti99_pcb_gramkracker); |
| 2469 | | break; |
| 1129 | gp->m_gk_slot = -1; // Remove GRAMKracker slot index |
| 1130 | // seems to be no way to change the dip switch except by keyboard |
| 1131 | } |
| 2470 | 1132 | |
| 2471 | | case TI99CART_FCT_ASSM: |
| 2472 | | info->f = (genf *) assemble_gramkracker; |
| 2473 | | break; |
| 1133 | if (m_rpk != NULL) |
| 1134 | { |
| 1135 | // Transfer RAM contents back into socket structure |
| 1136 | /* if (m_pcb->m_ram_size > 0) |
| 1137 | { |
| 1138 | UINT8* ram_ptr; |
| 1139 | ram_ptr = (UINT8*)m_rpk->get_contents_of_socket("ram_socket"); |
| 1140 | memcpy(ram_ptr, m_pcb->m_ram_ptr, m_pcb->m_ram_size); |
| 1141 | } */ |
| 1142 | m_rpk->close(); // will write NVRAM contents |
| 1143 | delete m_rpk; |
| 1144 | } |
| 2474 | 1145 | |
| 2475 | | case TI99CART_FCT_DISASSM: |
| 2476 | | info->f = (genf *) disassemble_gramkracker; |
| 2477 | | break; |
| 1146 | // TODO: How can we remove the dynamically added device? |
| 1147 | m_pcb = NULL; |
| 1148 | gp->change_slot(false, get_index_from_tagname()); |
| 1149 | } |
| 2478 | 1150 | |
| 2479 | | case DEVINFO_STR_NAME: |
| 2480 | | strcpy(info->s, "TI99 GRAM Kracker system"); |
| 2481 | | break; |
| 1151 | READ8Z_MEMBER(cartridge_device::readz) |
| 1152 | { |
| 1153 | assert(m_pcb != NULL); |
| 1154 | m_pcb->readz(space, offset, value, mem_mask); |
| 1155 | } |
| 2482 | 1156 | |
| 2483 | | default: |
| 2484 | | DEVICE_GET_INFO_CALL(ti99_cart_common); |
| 2485 | | break; |
| 2486 | | } |
| 1157 | WRITE8_MEMBER(cartridge_device::write) |
| 1158 | { |
| 1159 | assert(m_pcb != NULL); |
| 1160 | m_pcb->write(space, offset, data, mem_mask); |
| 2487 | 1161 | } |
| 2488 | 1162 | |
| 2489 | | /***************************************************************************** |
| 2490 | | The cartridge handling of the multi-cartridge system. |
| 2491 | | Every cartridge contains a PCB device. The memory handlers delegate the calls |
| 2492 | | to the respective handlers of the cartridges. |
| 2493 | | ******************************************************************************/ |
| 2494 | | /* |
| 2495 | | Initialize a cartridge. Each cartridge contains a PCB device. |
| 2496 | | */ |
| 2497 | | static DEVICE_START( ti99_cartridge ) |
| 1163 | void cartridge_device::crureadz(offs_t offset, UINT8 *value) |
| 2498 | 1164 | { |
| 2499 | | multicartslot_t *cart = get_safe_cartslot_token(device); |
| 1165 | assert(m_pcb != NULL); |
| 1166 | m_pcb->crureadz(offset, value); |
| 1167 | } |
| 2500 | 1168 | |
| 2501 | | /* find the PCB device */ |
| 2502 | | cart->pcb_device = device->subdevice(TAG_PCB); |
| 1169 | void cartridge_device::cruwrite(offs_t offset, UINT8 data) |
| 1170 | { |
| 1171 | assert(m_pcb != NULL); |
| 1172 | m_pcb->cruwrite(offset, data); |
| 2503 | 1173 | } |
| 2504 | 1174 | |
| 2505 | 1175 | /* |
| 2506 | | Load the cartridge image files. Apart from reading, we set pointers |
| 2507 | | to the image files so that during runtime we do not need search |
| 2508 | | operations. |
| 1176 | Find the index of the cartridge name. We assume the format |
| 1177 | <name><number>, i.e. the number is the longest string from the right |
| 1178 | which can be interpreted as a number. Subtract 1. |
| 2509 | 1179 | */ |
| 2510 | | static DEVICE_IMAGE_LOAD( ti99_cartridge ) |
| 1180 | int cartridge_device::get_index_from_tagname() |
| 2511 | 1181 | { |
| 2512 | | device_t *pcbdev = cartslot_get_pcb(&image.device()); |
| 2513 | | // device_t *cartsys = image.device().owner(); |
| 2514 | | // ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1182 | const char *mytag = tag(); |
| 1183 | int maxlen = strlen(mytag); |
| 1184 | int i; |
| 1185 | for (i=maxlen-1; i >=0; i--) |
| 1186 | if (mytag[i] < 48 || mytag[i] > 57) break; |
| 2515 | 1187 | |
| 2516 | | int result; |
| 1188 | return atoi(mytag+i+1)-1; |
| 1189 | } |
| 2517 | 1190 | |
| 2518 | | if (pcbdev != NULL) |
| 2519 | | { |
| 2520 | | /* If we are here, we have a multicart. */ |
| 2521 | | ti99_pcb_t *pcb = get_safe_pcb_token(pcbdev); |
| 2522 | | multicartslot_t *cart = get_safe_cartslot_token(&image.device()); |
| 1191 | static GROM_CONFIG(grom3_config) |
| 1192 | { |
| 1193 | false, 3, CARTGROM_TAG, 0x0000, 0x1800, false, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gromport_device, ready_line) |
| 1194 | }; |
| 1195 | static GROM_CONFIG(grom4_config) |
| 1196 | { |
| 1197 | false, 4, CARTGROM_TAG, 0x2000, 0x1800, false, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gromport_device, ready_line) |
| 1198 | }; |
| 1199 | static GROM_CONFIG(grom5_config) |
| 1200 | { |
| 1201 | false, 5, CARTGROM_TAG, 0x4000, 0x1800, false, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gromport_device, ready_line) |
| 1202 | }; |
| 1203 | static GROM_CONFIG(grom6_config) |
| 1204 | { |
| 1205 | false, 6, CARTGROM_TAG, 0x6000, 0x1800, false, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gromport_device, ready_line) |
| 1206 | }; |
| 1207 | static GROM_CONFIG(grom7_config) |
| 1208 | { |
| 1209 | false, 7, CARTGROM_TAG, 0x8000, 0x1800, false, DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gromport_device, ready_line) |
| 1210 | }; |
| 2523 | 1211 | |
| 2524 | | /* try opening this as a multicart */ |
| 2525 | | // This line requires that cartslot_t be included in cartslot.h, |
| 2526 | | // otherwise one cannot make use of multicart handling within such a |
| 2527 | | // custom LOAD function. |
| 2528 | | multicart_open_error me = multicart_open(image.device().machine().options(), image.filename(), image.device().machine().system().name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc); |
| 2529 | | if (VERBOSE>1) LOG("ti99: gromport: opened %s as cartridge\n", image.filename()); |
| 2530 | | // Now that we have loaded the image files, let the PCB put them all |
| 2531 | | // together. This means we put the images in a structure which allows |
| 2532 | | // for a quick access by the memory handlers. Every PCB defines an |
| 2533 | | // own assembly method. |
| 2534 | | if (me == MCERR_NONE) |
| 2535 | | result = pcb->assemble(image); |
| 2536 | | else |
| 2537 | | fatalerror("Error loading multicart: %s", multicart_error_text(me)); |
| 2538 | | } |
| 2539 | | else |
| 2540 | | { |
| 2541 | | fatalerror("Error loading multicart: no pcb found."); |
| 2542 | | } |
| 2543 | | return result; |
| 1212 | /* |
| 1213 | The GROM devices on a cartridge. |
| 1214 | */ |
| 1215 | static MACHINE_CONFIG_FRAGMENT( cartridge_groms ) |
| 1216 | MCFG_GROM_ADD( GROM3_TAG, grom3_config ) |
| 1217 | MCFG_GROM_ADD( GROM4_TAG, grom4_config ) |
| 1218 | MCFG_GROM_ADD( GROM5_TAG, grom5_config ) |
| 1219 | MCFG_GROM_ADD( GROM6_TAG, grom6_config ) |
| 1220 | MCFG_GROM_ADD( GROM7_TAG, grom7_config ) |
| 1221 | MACHINE_CONFIG_END |
| 1222 | |
| 1223 | machine_config_constructor cartridge_device::device_mconfig_additions() const |
| 1224 | { |
| 1225 | return MACHINE_CONFIG_NAME( cartridge_groms ); |
| 2544 | 1226 | } |
| 2545 | 1227 | |
| 2546 | 1228 | /* |
| 2547 | | This is called when the cartridge is unplugged (or the emulator is |
| 2548 | | stopped). |
| 1229 | Memory area for one cartridge. |
| 2549 | 1230 | */ |
| 2550 | | static DEVICE_IMAGE_UNLOAD( ti99_cartridge ) |
| 1231 | ROM_START( cartridge_memory ) |
| 1232 | ROM_REGION(0xa000, CARTGROM_TAG, 0) |
| 1233 | ROM_FILL(0x0000, 0xa000, 0x00) |
| 1234 | ROM_REGION(0x2000, CARTROM_TAG, 0) |
| 1235 | ROM_FILL(0x0000, 0x2000, 0x00) |
| 1236 | ROM_REGION(0x2000, CARTROM2_TAG, 0) |
| 1237 | ROM_FILL(0x0000, 0x2000, 0x00) |
| 1238 | ROM_END |
| 1239 | |
| 1240 | const rom_entry *cartridge_device::device_rom_region() const |
| 2551 | 1241 | { |
| 2552 | | device_t *pcbdev; |
| 2553 | | //ti99_multicart_state *cartslots = get_safe_token(image.device().owner()); |
| 1242 | return ROM_NAME( cartridge_memory ); |
| 1243 | } |
| 2554 | 1244 | |
| 2555 | | if (downcast<legacy_device_base *>(&image.device())->token() == NULL) |
| 2556 | | { |
| 2557 | | // This means something went wrong during the pcb |
| 2558 | | // identification (e.g. one of the cartridge files was not |
| 2559 | | // found). We do not need to (and cannot) unload the cartridge. |
| 2560 | | return; |
| 2561 | | } |
| 2562 | | pcbdev = cartslot_get_pcb(image); |
| 1245 | void gromport_device::set_gk_slot(int slot) |
| 1246 | { |
| 1247 | if (VERBOSE>5) LOG("gromport_device: Setting slot %d as GK slot.\n", slot); |
| 1248 | m_gk_slot = slot; |
| 1249 | } |
| 2563 | 1250 | |
| 2564 | | if (pcbdev != NULL) |
| 1251 | void gromport_device::find_gk_guest() |
| 1252 | { |
| 1253 | // The first slot which contains a cartridge (not the GK) is the guest of the GK |
| 1254 | for (int i=0; i < m_numcart; i++) |
| 2565 | 1255 | { |
| 2566 | | ti99_pcb_t *pcb = get_safe_pcb_token(pcbdev); |
| 2567 | | multicartslot_t *cart = get_safe_cartslot_token(&image.device()); |
| 2568 | | |
| 2569 | | if (cart->mc != NULL) |
| 1256 | if (i==m_gk_slot) continue; |
| 1257 | if (m_cartridge[i]->is_available()) |
| 2570 | 1258 | { |
| 2571 | | /* Remove pointers and de-big-endianize RAM contents. */ |
| 2572 | | pcb->disassemble(image); |
| 2573 | | |
| 2574 | | // Close the multicart; all RAM resources will be |
| 2575 | | // written to disk |
| 2576 | | multicart_close(image.device().machine().options(),cart->mc); |
| 2577 | | cart->mc = NULL; |
| 2578 | | |
| 1259 | m_cartridge[m_gk_slot]->set_gk_guest(m_cartridge[i]); |
| 1260 | if (VERBOSE>5) LOG("gromport_device: Setting slot %d as guest slot.\n", i); |
| 1261 | return; |
| 2579 | 1262 | } |
| 2580 | 1263 | } |
| 1264 | m_cartridge[m_gk_slot]->set_gk_guest(NULL); |
| 2581 | 1265 | } |
| 2582 | 1266 | |
| 2583 | 1267 | /***************************************************************************** |
| 2584 | | The overall multi-cartridge slot system. It contains instances of |
| 2585 | | cartridges which contain PCB devices. The memory handlers delegate the calls |
| 2586 | | to the respective handlers of the cartridges. |
| 1268 | The complete multi-port cartridge system. Hosts up to four cartridges |
| 1269 | at this time. |
| 1270 | *****************************************************************************/ |
| 2587 | 1271 | |
| 2588 | | Note that the term "multi-cartridge system" and "multicart" are not the same: |
| 2589 | | A "multicart" may contain multiple resources, organized on a PCB. The multi- |
| 2590 | | cart system may thus host multiple multicarts. |
| 1272 | gromport_device::gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1273 | : bus8z_device(mconfig, GROMPORT, "TI-99 multi-cartridge extender", tag, owner, clock) |
| 1274 | { |
| 1275 | m_gk_slot = -1; |
| 1276 | } |
| 2591 | 1277 | |
| 2592 | | Actually, the name of the device should be changed (however, the device name |
| 2593 | | length is limited) |
| 2594 | | ******************************************************************************/ |
| 2595 | | |
| 2596 | | static READ8Z_DEVICE_HANDLER( ti99_cart_gk_rz ); |
| 2597 | | static WRITE8_DEVICE_HANDLER( ti99_cart_gk_w ); |
| 2598 | | static void cartridge_gram_kracker_writeg(device_t *cartsys, int offset, UINT8 data); |
| 2599 | | static void cartridge_gram_kracker_readg(device_t *device, UINT8 *value); |
| 2600 | | static READ8Z_DEVICE_HANDLER( ti99_cart_cru_gk_rz ); |
| 2601 | | static WRITE8_DEVICE_HANDLER( ti99_cart_cru_gk_w ); |
| 2602 | | |
| 2603 | 1278 | /* |
| 2604 | | Instantiation of a multicart system for the TI family. |
| 2605 | | */ |
| 2606 | | static DEVICE_START(ti99_multicart) |
| 2607 | | { |
| 2608 | | int i; |
| 2609 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2610 | | const ti99_multicart_config* cartconf = (const ti99_multicart_config*)get_config(device); |
| 1279 | Activates a slot in the multi-cartridge extender. |
| 1280 | Setting the slot is done by accessing the GROM ports using a |
| 1281 | specific address: |
| 2611 | 1282 | |
| 2612 | | cartslots->active_slot = 0; |
| 2613 | | cartslots->next_free_slot = 0; |
| 1283 | slot 0: 0x9800 (0x9802, 0x9c00, 0x9c02) : cartridge1 |
| 1284 | slot 1: 0x9804 (0x9806, 0x9c04, 0x9c06) : cartridge2 |
| 1285 | ... |
| 1286 | slot 15: 0x983c (0x983e, 0x9c3c, 0x9c3e) : cartridge16 |
| 2614 | 1287 | |
| 2615 | | for (i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 2616 | | { |
| 2617 | | cartslots->cartridge[i].pcb = NULL; |
| 2618 | | clear_slot(device, i); |
| 2619 | | } |
| 1288 | Scheme: |
| 2620 | 1289 | |
| 2621 | | devcb_write_line ready = DEVCB_LINE(cartconf->ready); |
| 1290 | 1001 1Wxx xxxx xxM0 (M=mode; M=0: data, M=1: address; W=write) |
| 2622 | 1291 | |
| 2623 | | cartslots->ready.resolve(ready, *device); |
| 1292 | The following addresses are theoretically available, but the |
| 1293 | built-in OS does not use them; i.e. cartridges will not be |
| 1294 | included in the selection list, and their features will not be |
| 1295 | found by lookup, but they could be accessed directly by user |
| 1296 | programs. |
| 1297 | slot 16: 0x9840 (0x9842, 0x9c40, 0x9c42) |
| 1298 | ... |
| 1299 | slot 255: 0x9bfc (0x9bfe, 0x9ffc, 0x9ffe) |
| 2624 | 1300 | |
| 2625 | | cartslots->gk_slot = -1; |
| 2626 | | cartslots->gk_guest_slot = -1; |
| 1301 | Setting the GROM base should select one cartridge, but the ROMs in the |
| 1302 | CPU space must also be switched. As there is no known special mechanism |
| 1303 | we assume that by switching the GROM base, the ROM is automatically |
| 1304 | switched. |
| 2627 | 1305 | |
| 2628 | | // The cartslot system is initialized now. The cartridges themselves |
| 2629 | | // need to check whether their parts are available. |
| 2630 | | } |
| 1306 | Caution: This means that cartridges which do not have at least one |
| 1307 | GROM cannot be switched with this mechanism. |
| 2631 | 1308 | |
| 2632 | | static DEVICE_STOP(ti99_multicart) |
| 2633 | | { |
| 2634 | | // printf("DEVICE_STOP(ti99_multicart)\n"); |
| 2635 | | } |
| 1309 | We assume that the slot number is already calculated in the caller: |
| 1310 | slotnumber>=0 && slotnumber<=255 |
| 2636 | 1311 | |
| 2637 | | static DEVICE_RESET(ti99_multicart) |
| 1312 | NOTE: The OS will stop searching when it finds slots 1 and 2 empty. |
| 1313 | Interestingly, cartridge subroutines are found nevertheless, even when |
| 1314 | the cartridge is plugged into a higher slot. |
| 1315 | */ |
| 1316 | void gromport_device::set_slot(int slotnumber) |
| 2638 | 1317 | { |
| 2639 | | // Consider to propagate RESET to cartridges. |
| 2640 | | // However, schematics do not reveal any pin for resetting a cartridge; |
| 2641 | | // the reset line is an input used when plugging in a cartridge. |
| 1318 | if (VERBOSE>7) |
| 1319 | if (m_active_slot != slotnumber) LOG("ti99: gromport: Setting cartslot to %d\n", slotnumber); |
| 2642 | 1320 | |
| 2643 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2644 | | int slotnumber = input_port_read(device->machine(), "CARTSLOT"); |
| 2645 | | cartslots->fixed_slot = slotnumber-1; /* auto = -1 */ |
| 1321 | if (m_fixed_slot==AUTO) |
| 1322 | m_active_slot = slotnumber; |
| 1323 | else |
| 1324 | m_active_slot = m_fixed_slot; |
| 2646 | 1325 | } |
| 2647 | 1326 | |
| 2648 | | /* |
| 2649 | | Accesses the ROM regions of the cartridge for reading. |
| 2650 | | */ |
| 2651 | | READ8Z_DEVICE_HANDLER( gromportr_rz ) |
| 1327 | int gromport_device::get_active_slot(bool changebase, offs_t offset) |
| 2652 | 1328 | { |
| 2653 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2654 | | int slot = cartslots->active_slot; |
| 2655 | | cartridge_t *cart; |
| 2656 | | |
| 2657 | | // Handle GRAM Kracker |
| 2658 | | // We could also consider to use a flag, but input_port_read uses |
| 2659 | | // a hashtable, so this should not be too slow |
| 2660 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 1329 | int slot; |
| 1330 | if (changebase) |
| 2661 | 1331 | { |
| 2662 | | ti99_cart_gk_rz(device, offset, value); |
| 2663 | | return; |
| 1332 | if ((offset & GROM_MASK) == GROM_AREA) |
| 1333 | { |
| 1334 | set_slot((offset>>2) & 0x00ff); |
| 1335 | } |
| 2664 | 1336 | } |
| 1337 | slot = m_active_slot; |
| 2665 | 1338 | |
| 2666 | | /* Sanity check. Higher slots are always empty. */ |
| 2667 | | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2668 | | return; |
| 1339 | // Here we have a design flaw in the operating system of the TI. |
| 1340 | // The system iterates through all banks to check for multiple cartridges. |
| 1341 | // If we do not have a multi-cart system, each bank shows the same contents |
| 1342 | // since there is no decoding of the bank information. |
| 1343 | // This brings us into trouble here: If only slot 1 is occupied, slot 2 |
| 1344 | // would deliver zeros only. This differs from slot 1, so we get a |
| 1345 | // meaningless selection option. |
| 1346 | // |
| 1347 | // If we have only one cartridge in slot 1, we pretend that we have a |
| 1348 | // single-slot system. The slot variable is forced to the first slot. |
| 2669 | 1349 | |
| 2670 | | // Same as above (GROM read) |
| 2671 | | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 1350 | if (m_fixed_slot==AUTO && m_next_free_slot==1) |
| 2672 | 1351 | slot=0; |
| 2673 | 1352 | |
| 2674 | | cart = &cartslots->cartridge[slot]; |
| 1353 | return slot; |
| 1354 | } |
| 2675 | 1355 | |
| 2676 | | if (!slot_is_empty(device, slot)) |
| 1356 | void gromport_device::change_slot(bool inserted, int index) |
| 1357 | { |
| 1358 | if (inserted) |
| 2677 | 1359 | { |
| 2678 | | // printf("try it on slot %d\n", slot); |
| 2679 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 2680 | | (*pcbdef->read)(cart->pcb, offset, value); |
| 1360 | if (VERBOSE>6) LOG("gromport_device: Inserted into slot %d\n", index); |
| 1361 | if (m_next_free_slot <= index) |
| 1362 | m_next_free_slot = index+1; |
| 2681 | 1363 | } |
| 1364 | else |
| 1365 | { |
| 1366 | if (VERBOSE>6) LOG("gromport_device: Removed from slot %d\n", index); |
| 1367 | for (int i=NUMBER_OF_CARTRIDGE_SLOTS-1; i>=0; i--) |
| 1368 | { |
| 1369 | if (m_cartridge[i]->is_available()) |
| 1370 | { |
| 1371 | m_next_free_slot = index+1; |
| 1372 | break; |
| 1373 | } |
| 1374 | } |
| 1375 | } |
| 1376 | if (VERBOSE>6) LOG("Next free slot: %d\n", m_next_free_slot); |
| 1377 | |
| 1378 | if (m_gk_slot != -1) find_gk_guest(); |
| 2682 | 1379 | } |
| 2683 | 1380 | |
| 2684 | | /* |
| 2685 | | Accesses the ROM regions of the cartridge for writing. |
| 2686 | | */ |
| 2687 | | WRITE8_DEVICE_HANDLER( gromportr_w ) |
| 1381 | /**************************************************** |
| 1382 | Memory space (ROM, GROM) |
| 1383 | ****************************************************/ |
| 1384 | READ8Z_MEMBER(gromport_device::readz) |
| 2688 | 1385 | { |
| 2689 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2690 | | int slot = cartslots->active_slot; |
| 2691 | | cartridge_t *cart; |
| 2692 | | |
| 2693 | | // Handle GRAM Kracker |
| 2694 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 2695 | | ti99_cart_gk_w(device, offset, data); |
| 2696 | | |
| 2697 | | /* Sanity check. Higher slots are always empty. */ |
| 2698 | | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 1386 | // GRAMKracker support |
| 1387 | // We *could* check the DIP switch, but this would only introduce another |
| 1388 | // source of confusion when the GRAMKracker is plugged in, but the switch |
| 1389 | // is not set. |
| 1390 | // The check for the presence of the GK using the index is safer. |
| 1391 | if ((m_gk_slot != -1) /*&& (input_port_read(*this, "CARTSLOT")==CART_GK) */) |
| 1392 | { |
| 1393 | m_cartridge[m_gk_slot]->readz(space, offset, value, mem_mask); |
| 2699 | 1394 | return; |
| 1395 | } |
| 2700 | 1396 | |
| 2701 | | /* Same as above (READ16). */ |
| 2702 | | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2703 | | slot=0; |
| 1397 | int slot = get_active_slot(true, offset); |
| 2704 | 1398 | |
| 2705 | | cart = &cartslots->cartridge[slot]; |
| 2706 | | |
| 2707 | | if (!slot_is_empty(device, slot)) |
| 1399 | // If we have a GROM access, we need to send the read request to all |
| 1400 | // attached cartridges so the slot is irrelevant here. Each GROM |
| 1401 | // contains an internal address counter, and we must make sure they all stay in sync. |
| 1402 | if ((offset & GROM_MASK) == GROM_AREA) |
| 2708 | 1403 | { |
| 2709 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 2710 | | (*pcbdef->write)(cart->pcb, offset, data); |
| 1404 | for (int i=0; i < m_numcart; i++) |
| 1405 | { |
| 1406 | if (m_cartridge[i]->is_available()) |
| 1407 | { |
| 1408 | UINT8 newval = *value; |
| 1409 | m_cartridge[i]->readz(space, offset, &newval, mem_mask); |
| 1410 | if (i==slot) |
| 1411 | { |
| 1412 | *value = newval; |
| 1413 | } |
| 1414 | } |
| 1415 | } |
| 2711 | 1416 | } |
| 1417 | else |
| 1418 | { |
| 1419 | if (slot < m_numcart && m_cartridge[slot]->is_available()) |
| 1420 | { |
| 1421 | m_cartridge[slot]->readz(space, offset, value, mem_mask); |
| 1422 | } |
| 1423 | } |
| 2712 | 1424 | } |
| 2713 | 1425 | |
| 2714 | | /* |
| 2715 | | Set the address pointer value or write to GRAM (if available). |
| 2716 | | */ |
| 2717 | | WRITE8_DEVICE_HANDLER(gromportg_w) |
| 1426 | WRITE8_MEMBER(gromport_device::write) |
| 2718 | 1427 | { |
| 2719 | | // int slot; |
| 2720 | | cartridge_t *cartridge; |
| 2721 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2722 | | |
| 2723 | | // Set the cart slot. |
| 2724 | | // 1001 1wbb bbbb bbr0 |
| 2725 | | |
| 2726 | | cartridge_slot_set(device, (UINT8)((offset>>2) & 0x00ff)); |
| 2727 | | // slot = cartslots->active_slot; |
| 2728 | | |
| 2729 | | // if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2730 | | // slot=0; |
| 2731 | | |
| 2732 | | // Handle the GRAM Kracker |
| 2733 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 1428 | // GRAMKracker support |
| 1429 | if ((m_gk_slot != -1) /*&& (input_port_read(*this, "CARTSLOT")==CART_GK)*/) |
| 2734 | 1430 | { |
| 2735 | | cartridge_gram_kracker_writeg(device, offset, data); |
| 1431 | m_cartridge[m_gk_slot]->write(space, offset, data, mem_mask); |
| 2736 | 1432 | return; |
| 2737 | 1433 | } |
| 2738 | 1434 | |
| 2739 | | // We need to send the write request to all attached cartridges |
| 2740 | | // so the slot is irrelevant here. (We don't have GRAM cartridges, |
| 2741 | | // anyway, so it's just used for setting the adddress) |
| 2742 | | for (int j=0; j < NUMBER_OF_CARTRIDGE_SLOTS; j++) |
| 1435 | int slot = get_active_slot(true, offset); |
| 1436 | |
| 1437 | // Same issue as above (read) |
| 1438 | // We don't have GRAM cartridges, anyway, so it's just used for setting the address. |
| 1439 | if ((offset & GROM_MASK) == GROM_AREA) |
| 2743 | 1440 | { |
| 2744 | | cartridge = &cartslots->cartridge[j]; |
| 2745 | | // Send the request to all mounted GROMs |
| 2746 | | if (cartridge->pcb!=NULL) |
| 1441 | for (int i=0; i < m_numcart; i++) |
| 2747 | 1442 | { |
| 2748 | | for (int i=0; i < 5; i++) |
| 1443 | if (m_cartridge[i]->is_available()) |
| 2749 | 1444 | { |
| 2750 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cartridge->pcb); |
| 2751 | | if (pcbdef->grom[i]!=NULL) |
| 2752 | | ti99grom_w(pcbdef->grom[i], offset, data); |
| 1445 | m_cartridge[i]->write(space, offset, data, mem_mask); |
| 2753 | 1446 | } |
| 2754 | 1447 | } |
| 2755 | 1448 | } |
| 1449 | else |
| 1450 | { |
| 1451 | if (slot < m_numcart && m_cartridge[slot]->is_available()) |
| 1452 | { |
| 1453 | // LOG("try it on slot %d\n", slot); |
| 1454 | m_cartridge[slot]->write(space, offset, data, mem_mask); |
| 1455 | } |
| 1456 | } |
| 2756 | 1457 | } |
| 2757 | 1458 | |
| 2758 | 1459 | /* |
| 2759 | | GROM access. Nota bene: We only react to the request if there is a GROM |
| 2760 | | at the selected bank with the currently selected ID. If not, just do |
| 2761 | | nothing; do not return a value. |
| 2762 | | (We must not return a value since all GROMs are connected in parallel, so |
| 2763 | | returning a 0, for instance, will spoil the processing of other GROMs.) |
| 1460 | Called from the cartriges. |
| 2764 | 1461 | */ |
| 2765 | | READ8Z_DEVICE_HANDLER(gromportg_rz) |
| 1462 | WRITE_LINE_MEMBER(gromport_device::ready_line) |
| 2766 | 1463 | { |
| 2767 | | int slot; |
| 2768 | | cartridge_t *cartridge; |
| 2769 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1464 | m_ready(state); |
| 1465 | } |
| 2770 | 1466 | |
| 2771 | | // Set the cart slot. Bit pattern: |
| 2772 | | // 1001 1wbb bbbb bbr0 |
| 2773 | | |
| 2774 | | cartridge_slot_set(device, (UINT8)((offset>>2) & 0x00ff)); |
| 2775 | | |
| 2776 | | // Handle the GRAM Kracker |
| 2777 | | // BTW, the GK does not have a readable address counter, but the console |
| 2778 | | // GROMs will keep our address counter up to date. That is |
| 2779 | | // exactly what happens in the real machine. |
| 2780 | | // (The console GROMs are not accessed here but directly via the datamux |
| 2781 | | // so we can just return without doing anything) |
| 2782 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 1467 | /**************************************************** |
| 1468 | CRU interface |
| 1469 | ****************************************************/ |
| 1470 | void gromport_device::crureadz(offs_t offset, UINT8 *value) |
| 1471 | { |
| 1472 | // GRAMKracker support |
| 1473 | if ((m_gk_slot != -1) /* && (input_port_read(*this, "CARTSLOT")==CART_GK)*/) |
| 2783 | 1474 | { |
| 2784 | | if ((offset & 0x0002)==0) cartridge_gram_kracker_readg(device, value); |
| 1475 | m_cartridge[m_gk_slot]->crureadz(offset, value); |
| 2785 | 1476 | return; |
| 2786 | 1477 | } |
| 2787 | 1478 | |
| 2788 | | slot = cartslots->active_slot; |
| 1479 | int slot = get_active_slot(false, offset); |
| 2789 | 1480 | |
| 2790 | | // This fixes a minor issue: The selection mechanism of the console |
| 2791 | | // concludes that there are multiple cartridges plugged in when it |
| 2792 | | // checks the different GROM bases and finds different data. Empty |
| 2793 | | // slots should return 0 at all addresses, but when we have only |
| 2794 | | // one cartridge, this entails that the second cartridge is |
| 2795 | | // different (all zeros), and so we get a meaningless selection |
| 2796 | | // option between cartridge 1 and 1 and 1 ... |
| 2797 | | // |
| 2798 | | // So if next_free_slot==1, we have one cartridge in slot 0. |
| 2799 | | // In that case we trick the OS to believe that the addressed |
| 2800 | | // cartridge appears at all locations which causes it to assume a |
| 2801 | | // standard single cartslot. |
| 1481 | /* Sanity check. Higher slots are always empty. */ |
| 1482 | if (slot >= m_numcart) |
| 1483 | return; |
| 2802 | 1484 | |
| 2803 | | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2804 | | slot=0; |
| 2805 | | |
| 2806 | | // We need to send the read request to all cartriges so that |
| 2807 | | // the internal address counters stay in sync. However, we only respect |
| 2808 | | // the return of the selected cartridge. |
| 2809 | | for (int j=0; j < NUMBER_OF_CARTRIDGE_SLOTS; j++) |
| 1485 | if (m_cartridge[slot]->is_available()) |
| 2810 | 1486 | { |
| 2811 | | // Select the cartridge which the multicart system is currently pointing at |
| 2812 | | cartridge = &cartslots->cartridge[j]; |
| 2813 | | // Send the request to all mounted GROMs on this PCB |
| 2814 | | if (cartridge->pcb!=NULL) |
| 2815 | | { |
| 2816 | | for (int i=0; i < 5; i++) |
| 2817 | | { |
| 2818 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cartridge->pcb); |
| 2819 | | if (pcbdef->grom[i]!=NULL) |
| 2820 | | { |
| 2821 | | UINT8 newvalue = *value; |
| 2822 | | ti99grom_rz(pcbdef->grom[i], offset, &newvalue); |
| 2823 | | if (j==slot) |
| 2824 | | { |
| 2825 | | *value = newvalue; |
| 2826 | | } |
| 2827 | | } |
| 2828 | | } |
| 2829 | | } |
| 1487 | m_cartridge[slot]->crureadz(offset, value); |
| 2830 | 1488 | } |
| 2831 | 1489 | } |
| 2832 | 1490 | |
| 2833 | | /* |
| 2834 | | CRU interface to cartridges, used only by SuperSpace and Pagedcru |
| 2835 | | style cartridges. |
| 2836 | | The SuperSpace has a CRU-based memory mapper. It is accessed via the |
| 2837 | | cartridge slot on CRU base >0800. |
| 2838 | | */ |
| 2839 | | READ8Z_DEVICE_HANDLER( gromportc_rz ) |
| 1491 | void gromport_device::cruwrite(offs_t offset, UINT8 data) |
| 2840 | 1492 | { |
| 2841 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2842 | | cartridge_t *cart; |
| 2843 | | |
| 2844 | | int slot = cartslots->active_slot; |
| 2845 | | |
| 2846 | | // Handle GRAM Kracker |
| 2847 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 1493 | // GRAMKracker support |
| 1494 | if ((m_gk_slot != -1) /*&& (input_port_read(*this, "CARTSLOT")==CART_GK)*/) |
| 2848 | 1495 | { |
| 2849 | | ti99_cart_cru_gk_rz(device, offset, value); |
| 1496 | m_cartridge[m_gk_slot]->cruwrite(offset, data); |
| 2850 | 1497 | return; |
| 2851 | 1498 | } |
| 2852 | 1499 | |
| 1500 | int slot = get_active_slot(true, offset); |
| 1501 | |
| 2853 | 1502 | /* Sanity check. Higher slots are always empty. */ |
| 2854 | | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 1503 | if (slot >= m_numcart) |
| 2855 | 1504 | return; |
| 2856 | 1505 | |
| 2857 | | /* Same as above (READ16). */ |
| 2858 | | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2859 | | slot=0; |
| 1506 | if (m_cartridge[slot]->is_available()) |
| 1507 | { |
| 1508 | m_cartridge[slot]->cruwrite(offset, data); |
| 1509 | } |
| 1510 | } |
| 2860 | 1511 | |
| 2861 | | cart = &cartslots->cartridge[slot]; |
| 1512 | /**************************************************** |
| 1513 | Device management |
| 1514 | ****************************************************/ |
| 1515 | void gromport_device::device_start(void) |
| 1516 | { |
| 1517 | // Resolve the callback line |
| 1518 | const gromport_config *intf = reinterpret_cast<const gromport_config *>(static_config()); |
| 1519 | m_ready.resolve(intf->ready, *this); |
| 2862 | 1520 | |
| 2863 | | if (!slot_is_empty(device, slot)) |
| 1521 | // Add the cartridges to the list |
| 1522 | device_iterator *iter = new device_iterator(*this, 1); |
| 1523 | |
| 1524 | int i = 0; |
| 1525 | cartridge_device *cart = static_cast<cartridge_device*>(iter->first()); |
| 1526 | |
| 1527 | // Skip the first node (it's the gromport) |
| 1528 | cart = static_cast<cartridge_device*>(iter->next()); |
| 1529 | while (cart != NULL) |
| 2864 | 1530 | { |
| 2865 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 2866 | | if (pcbdef->cruread != NULL) |
| 2867 | | (*pcbdef->cruread)(cart->pcb, offset, value); |
| 1531 | m_cartridge[i++] = cart; |
| 1532 | // LOG("tag = %s\n", cart->tag()); |
| 1533 | cart = static_cast<cartridge_device*>(iter->next()); |
| 2868 | 1534 | } |
| 1535 | m_numcart = i; |
| 1536 | m_next_free_slot = 0; |
| 1537 | m_active_slot = 0; |
| 2869 | 1538 | } |
| 2870 | 1539 | |
| 2871 | | /* |
| 2872 | | Write cartridge mapper CRU interface (SuperSpace, Pagedcru) |
| 2873 | | */ |
| 2874 | | WRITE8_DEVICE_HANDLER( gromportc_w ) |
| 1540 | void gromport_device::device_stop(void) |
| 2875 | 1541 | { |
| 2876 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2877 | | cartridge_t *cart; |
| 1542 | } |
| 2878 | 1543 | |
| 2879 | | int slot = cartslots->active_slot; |
| 1544 | void gromport_device::device_reset(void) |
| 1545 | { |
| 1546 | m_active_slot = 0; |
| 1547 | m_fixed_slot = input_port_read(*this, "CARTSLOT") - 1; |
| 1548 | } |
| 2880 | 1549 | |
| 2881 | | // Handle GRAM Kracker |
| 2882 | | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine(), "CARTSLOT")==CART_GK)) |
| 1550 | INPUT_CHANGED_MEMBER( gromport_device::gk_changed ) |
| 1551 | { |
| 1552 | if (VERBOSE>7) LOG("gromport: input changed %d - %d\n", (int)((UINT64)param & 0x07), newval); |
| 1553 | if (m_gk_slot != -1) |
| 2883 | 1554 | { |
| 2884 | | ti99_cart_cru_gk_w(device, offset, data); |
| 2885 | | return; |
| 1555 | m_cartridge[m_gk_slot]->set_switch((UINT64)param & 0x07, newval); // param is a pointer type |
| 2886 | 1556 | } |
| 1557 | } |
| 2887 | 1558 | |
| 2888 | | /* Sanity check. Higher slots are always empty. */ |
| 2889 | | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2890 | | return; |
| 1559 | INPUT_PORTS_START(gromport_device) |
| 1560 | PORT_START( "CARTSLOT" ) |
| 1561 | PORT_DIPNAME( 0x0f, 0x00, "Multi-cartridge slot" ) |
| 1562 | PORT_DIPSETTING( 0x00, "Auto" ) |
| 1563 | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 1564 | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 1565 | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 1566 | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 1567 | PORT_DIPSETTING( 0x0f, "GRAM Kracker" ) |
| 2891 | 1568 | |
| 2892 | | /* Same as above (READ16). */ |
| 2893 | | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2894 | | slot=0; |
| 1569 | PORT_START( GKSWITCH1_TAG ) |
| 1570 | PORT_DIPNAME( 0x01, 0x01, "GK switch 1" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 1) |
| 1571 | PORT_DIPSETTING( 0x00, "GK Off" ) |
| 1572 | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 2895 | 1573 | |
| 2896 | | cart = &cartslots->cartridge[slot]; |
| 1574 | PORT_START( GKSWITCH2_TAG ) |
| 1575 | PORT_DIPNAME( 0x01, 0x01, "GK switch 2" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 2) |
| 1576 | PORT_DIPSETTING( 0x00, "GRAM 0" ) |
| 1577 | PORT_DIPSETTING( 0x01, "Op Sys" ) |
| 2897 | 1578 | |
| 2898 | | if (!slot_is_empty(device, slot)) |
| 2899 | | { |
| 2900 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 2901 | | if (pcbdef->cruwrite != NULL) |
| 2902 | | (*pcbdef->cruwrite)(cart->pcb, offset, data); |
| 2903 | | } |
| 1579 | PORT_START( GKSWITCH3_TAG ) |
| 1580 | PORT_DIPNAME( 0x01, 0x01, "GK switch 3" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 3) |
| 1581 | PORT_DIPSETTING( 0x00, "GRAM 1-2" ) |
| 1582 | PORT_DIPSETTING( 0x01, "TI BASIC" ) |
| 1583 | |
| 1584 | PORT_START( GKSWITCH4_TAG ) |
| 1585 | PORT_DIPNAME( 0x03, 0x01, "GK switch 4" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 4) |
| 1586 | PORT_DIPSETTING( 0x00, "Bank 1" ) |
| 1587 | PORT_DIPSETTING( 0x01, "W/P" ) |
| 1588 | PORT_DIPSETTING( 0x02, "Bank 2" ) |
| 1589 | |
| 1590 | PORT_START( GKSWITCH5_TAG ) |
| 1591 | PORT_DIPNAME( 0x01, 0x00, "GK switch 5" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED_MEMBER(DEVICE_SELF, gromport_device, gk_changed, 5) |
| 1592 | PORT_DIPSETTING( 0x00, "Loader On" ) |
| 1593 | PORT_DIPSETTING( 0x01, "Loader Off" ) |
| 1594 | INPUT_PORTS_END |
| 1595 | |
| 1596 | static MACHINE_CONFIG_FRAGMENT(gromport_device) |
| 1597 | MCFG_DEVICE_ADD("cartridge1", TICARTRIDGE, 0) |
| 1598 | MCFG_DEVICE_ADD("cartridge2", TICARTRIDGE, 0) |
| 1599 | MCFG_DEVICE_ADD("cartridge3", TICARTRIDGE, 0) |
| 1600 | MCFG_DEVICE_ADD("cartridge4", TICARTRIDGE, 0) |
| 1601 | MACHINE_CONFIG_END |
| 1602 | |
| 1603 | machine_config_constructor gromport_device::device_mconfig_additions() const |
| 1604 | { |
| 1605 | return MACHINE_CONFIG_NAME( gromport_device ); |
| 2904 | 1606 | } |
| 2905 | 1607 | |
| 2906 | | /***************************************************************************** |
| 2907 | | GramKracker support |
| 2908 | | The 80 KiB of the GK are allocated as follows |
| 2909 | | 00000 - 01fff: GRAM 0 |
| 2910 | | 02000 - 03fff: GRAM 1 (alternatively, the loader GROM appears here) |
| 2911 | | 04000 - 05fff: GRAM 2 |
| 2912 | | 06000 - 0ffff: GRAM 3-7 (alternatively, the guest GROMs appear here) |
| 2913 | | 10000 - 11fff: RAM 1 |
| 2914 | | 12000 - 13fff: RAM 2 |
| 1608 | ioport_constructor gromport_device::device_input_ports() const |
| 1609 | { |
| 1610 | return INPUT_PORTS_NAME(gromport_device); |
| 1611 | } |
| 2915 | 1612 | |
| 2916 | | The GK emulates GROMs, but without a readable address counter. Thus it |
| 2917 | | relies on the console GROMs being still in place (compare with the HSGPL). |
| 2918 | | Also, the GK does not implement a GROM buffer. |
| 2919 | | ******************************************************************************/ |
| 1613 | const device_type GROMPORT = &device_creator<gromport_device>; |
| 1614 | const device_type TICARTRIDGE = &device_creator<cartridge_device>; |
| 2920 | 1615 | |
| 1616 | const device_type TICARTPCBSTD = &device_creator<cartridge_pcb_standard_device>; |
| 1617 | const device_type TICARTPCBPAG = &device_creator<cartridge_pcb_paged_device>; |
| 1618 | const device_type TICARTPCBMIN = &device_creator<cartridge_pcb_minimem_device>; |
| 1619 | const device_type TICARTPCBSUP = &device_creator<cartridge_pcb_superspace_device>; |
| 1620 | const device_type TICARTPCBMBX = &device_creator<cartridge_pcb_mbx_device>; |
| 1621 | const device_type TICARTPCBPGI = &device_creator<cartridge_pcb_paged379i_device>; |
| 1622 | const device_type TICARTPCBPGC = &device_creator<cartridge_pcb_pagedcru_device>; |
| 1623 | const device_type TICARTPCBGRK = &device_creator<cartridge_pcb_gramkracker_device>; |
| 1624 | |
| 1625 | /***************************************************************************************************************** |
| 1626 | ****************************************************************************************************************** |
| 1627 | RPK format support |
| 1628 | |
| 1629 | A RPK file ("rompack") contains a collection of dump files and a layout |
| 1630 | file that defines the kind of circuit board (PCB) used in the cartridge |
| 1631 | and the mapping of dumps to sockets on the board. |
| 1632 | |
| 1633 | Example: |
| 1634 | <?xml version="1.0" encoding="utf-8"?> |
| 1635 | <romset> |
| 1636 | <resources> |
| 1637 | <rom id="gromimage" file="ed-assmg.bin" /> |
| 1638 | </resources> |
| 1639 | <configuration> |
| 1640 | <pcb type="standard"> |
| 1641 | <socket id="grom_socket" uses="gromimage"/> |
| 1642 | </pcb> |
| 1643 | </configuration> |
| 1644 | </romset> |
| 1645 | |
| 1646 | DTD: |
| 1647 | <!ELEMENT romset (resources, configuration)> |
| 1648 | <!ELEMENT resources (rom|ram)+> |
| 1649 | <!ELEMENT rom EMPTY> |
| 1650 | <!ELEMENT ram EMPTY> |
| 1651 | <!ELEMENT configuration (pcb)> |
| 1652 | <!ELEMENT pcb (socket)+> |
| 1653 | <!ELEMENT socket EMPTY> |
| 1654 | <!ATTLIST romset version CDATA #IMPLIED> |
| 1655 | <!ATTLIST rom id ID #REQUIRED |
| 1656 | <!ATTLIST rom file CDATA #REQUIRED> |
| 1657 | <!ATTLIST rom crc CDATA #IMPLIED> |
| 1658 | <!ATTLIST rom sha1 CDATA #IMPLIED> |
| 1659 | <!ATTLIST ram id ID #REQUIRED> |
| 1660 | <!ATTLIST ram type (volatile|persistent) #IMPLIED> |
| 1661 | <!ATTLIST ram store (internal|external) #IMPLIED> |
| 1662 | <!ATTLIST ram file CDATA #IMPLIED> |
| 1663 | <!ATTLIST ram length CDATA #REQUIRED> |
| 1664 | <!ATTLIST pcb type CDATA #REQUIRED> |
| 1665 | <!ATTLIST socket id ID #REQUIRED> |
| 1666 | <!ATTLIST socket uses IDREF #REQUIRED> |
| 1667 | |
| 1668 | ****************************************************************************/ |
| 1669 | |
| 1670 | #include "unzip.h" |
| 1671 | #include "xmlfile.h" |
| 1672 | |
| 1673 | /**************************************** |
| 1674 | RPK class |
| 1675 | ****************************************/ |
| 2921 | 1676 | /* |
| 2922 | | Reads from the GRAM space of the GRAM Kracker. |
| 1677 | Constructor. |
| 2923 | 1678 | */ |
| 2924 | | static void cartridge_gram_kracker_readg(device_t *cartsys, UINT8 *value) |
| 1679 | rpk::rpk(emu_options& options, const char* sysname) |
| 1680 | :m_options(options), |
| 1681 | m_system_name(sysname) |
| 2925 | 1682 | { |
| 2926 | | // gk_slot is the slot where the GK module is plugged in |
| 2927 | | // gk_guest_slot is the slot where the cartridge is plugged in |
| 1683 | m_sockets.reset(); |
| 1684 | }; |
| 2928 | 1685 | |
| 2929 | | cartridge_t *gromkrackerbox, *gkguestcart; |
| 2930 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1686 | rpk::~rpk() |
| 1687 | { |
| 1688 | if (VERBOSE>6) LOG("Destroy RPK\n"); |
| 1689 | } |
| 2931 | 1690 | |
| 2932 | | // Not null, since this is only called when there is really a GK module |
| 2933 | | gromkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 1691 | /* |
| 1692 | Deliver the contents of the socket by name of the socket. |
| 1693 | */ |
| 1694 | void* rpk::get_contents_of_socket(const char *socket_name) |
| 1695 | { |
| 1696 | rpk_socket *socket = m_sockets.find(socket_name); |
| 1697 | if (socket==NULL) return NULL; |
| 1698 | return socket->get_contents(); |
| 1699 | } |
| 2934 | 1700 | |
| 2935 | | if ((gromkrackerbox->grom_address & 0xe000) == 0x0000) |
| 2936 | | { |
| 2937 | | // GRAM 0. Only return a value if switch 2 is in GRAM0 position. |
| 2938 | | if (get_gk_switch(cartsys, 2)==GK_GRAM0) |
| 2939 | | *value = (gromkrackerbox->ram_ptr)[gromkrackerbox->grom_address]; |
| 2940 | | } |
| 1701 | /* |
| 1702 | Deliver the length of the contents of the socket by name of the socket. |
| 1703 | */ |
| 1704 | int rpk::get_resource_length(const char *socket_name) |
| 1705 | { |
| 1706 | rpk_socket *socket = m_sockets.find(socket_name); |
| 1707 | if (socket==NULL) return 0; |
| 1708 | return socket->get_content_length(); |
| 1709 | } |
| 2941 | 1710 | |
| 2942 | | if ((gromkrackerbox->grom_address & 0xe000) == 0x2000) |
| 1711 | void rpk::add_socket(const char* id, rpk_socket *newsock) |
| 1712 | { |
| 1713 | m_sockets.append(id, *newsock); |
| 1714 | } |
| 1715 | |
| 1716 | /*------------------------------------------------- |
| 1717 | rpk_close - closes a rpk |
| 1718 | Saves the contents of the NVRAMs and frees all memory. |
| 1719 | -------------------------------------------------*/ |
| 1720 | |
| 1721 | void rpk::close() |
| 1722 | { |
| 1723 | // Save the NVRAM contents |
| 1724 | rpk_socket *socket = m_sockets.first(); |
| 1725 | while (socket != NULL) |
| 2943 | 1726 | { |
| 2944 | | // If the loader is turned on, return loader contents. |
| 2945 | | if (get_gk_switch(cartsys, 5)==GK_LDON) |
| 1727 | if (socket->persistent_ram()) |
| 2946 | 1728 | { |
| 2947 | | // The only ROM contained in the GK box is the loader |
| 2948 | | *value = gromkrackerbox->grom_ptr[gromkrackerbox->grom_address & 0x1fff]; |
| 1729 | image_battery_save_by_name(m_options, socket->get_pathname(), socket->get_contents(), socket->get_content_length()); |
| 2949 | 1730 | } |
| 2950 | | else |
| 2951 | | { |
| 2952 | | // Loader off |
| 2953 | | // GRAM 1. Only return a value if switch 3 is in GRAM12 position. |
| 2954 | | // Otherwise, the console GROM 1 will respond (at another location) |
| 2955 | | if (get_gk_switch(cartsys, 3)==GK_GRAM12) |
| 2956 | | *value = (gromkrackerbox->ram_ptr)[gromkrackerbox->grom_address]; |
| 2957 | | } |
| 1731 | socket->cleanup(); |
| 1732 | socket = socket->m_next; |
| 2958 | 1733 | } |
| 1734 | } |
| 2959 | 1735 | |
| 2960 | | if ((gromkrackerbox->grom_address & 0xe000) == 0x4000) |
| 2961 | | { |
| 2962 | | // GRAM 2. Only return a value if switch 3 is in GRAM12 position. |
| 2963 | | if (get_gk_switch(cartsys, 3)==GK_GRAM12) |
| 2964 | | *value = (gromkrackerbox->ram_ptr)[gromkrackerbox->grom_address]; |
| 2965 | | } |
| 1736 | /************************************************************** |
| 1737 | RPK socket (location in the PCB where a chip is plugged in; |
| 1738 | not a network socket) |
| 1739 | ***************************************************************/ |
| 2966 | 1740 | |
| 2967 | | if (((gromkrackerbox->grom_address & 0xe000) == 0x6000) || |
| 2968 | | ((gromkrackerbox->grom_address & 0x8000) == 0x8000)) |
| 2969 | | { |
| 2970 | | // Cartridge space |
| 2971 | | // When a cartridge is installed, it overrides the GK contents |
| 2972 | | // but only if it has GROMs |
| 2973 | | int cartwithgrom = FALSE; |
| 2974 | | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 1741 | rpk_socket::rpk_socket(const char* id, int length, void* contents, const char *pathname) |
| 1742 | : m_id(id), m_length(length), m_next(NULL), m_contents(contents), m_pathname(pathname) |
| 1743 | { |
| 1744 | }; |
| 2975 | 1745 | |
| 2976 | | // Send the request to all mounted GROMs |
| 2977 | | if (gkguestcart->pcb!=NULL) |
| 1746 | rpk_socket::rpk_socket(const char* id, int length, void* contents) |
| 1747 | : m_id(id), m_length(length), m_next(NULL), m_contents(contents), m_pathname(NULL) |
| 1748 | { |
| 1749 | }; |
| 1750 | |
| 1751 | /* |
| 1752 | Locate a file in the ZIP container |
| 1753 | */ |
| 1754 | const zip_file_header* rpk_reader::find_file(zip_file *zip, const char *filename, UINT32 crc) |
| 1755 | { |
| 1756 | const zip_file_header *header; |
| 1757 | for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) |
| 1758 | { |
| 1759 | // We don't check for CRC == 0. |
| 1760 | if (crc != 0) |
| 2978 | 1761 | { |
| 2979 | | for (int i=0; i < 5; i++) |
| 1762 | // if the CRC and name both match, we're good |
| 1763 | // if the CRC matches and the name doesn't, we're still good |
| 1764 | if (header->crc == crc) |
| 1765 | return header; |
| 1766 | } |
| 1767 | else |
| 1768 | { |
| 1769 | if (core_stricmp(header->filename, filename)==0) |
| 2980 | 1770 | { |
| 2981 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 2982 | | if (pcbdef->grom[i]!=NULL) |
| 2983 | | { |
| 2984 | | ti99grom_rz(pcbdef->grom[i], 0x9800, value); |
| 2985 | | cartwithgrom = TRUE; |
| 2986 | | } |
| 1771 | return header; |
| 2987 | 1772 | } |
| 2988 | 1773 | } |
| 2989 | | if (!cartwithgrom && get_gk_switch(cartsys, 1)==GK_NORMAL) |
| 2990 | | { |
| 2991 | | *value = (gromkrackerbox->ram_ptr)[gromkrackerbox->grom_address]; |
| 2992 | | } |
| 2993 | 1774 | } |
| 2994 | | |
| 2995 | | // The GK GROM emulation does not wrap at 8K boundaries. |
| 2996 | | gromkrackerbox->grom_address = (gromkrackerbox->grom_address+1) & 0xffff; |
| 2997 | | |
| 2998 | | /* Reset the write address flipflop. */ |
| 2999 | | gromkrackerbox->waddr_LSB = FALSE; |
| 1775 | return NULL; |
| 3000 | 1776 | } |
| 3001 | 1777 | |
| 3002 | 1778 | /* |
| 3003 | | Writes to the GRAM space of the GRAM Kracker. |
| 1779 | Load a rom resource and put it in a pcb socket instance. |
| 3004 | 1780 | */ |
| 3005 | | static void cartridge_gram_kracker_writeg(device_t *cartsys, int offset, UINT8 data) |
| 1781 | rpk_socket* rpk_reader::load_rom_resource(zip_file* zip, xml_data_node* rom_resource_node, const char* socketname) |
| 3006 | 1782 | { |
| 3007 | | // gk_slot is the slot where the GK module is plugged in |
| 3008 | | // gk_guest_slot is the slot where the cartridge is plugged in |
| 3009 | | cartridge_t *gramkrackerbox; |
| 3010 | | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 1783 | const char* file; |
| 1784 | const char* crcstr; |
| 1785 | const char* sha1; |
| 1786 | zip_error ziperr; |
| 1787 | UINT32 crc; |
| 1788 | int length; |
| 1789 | void* contents; |
| 1790 | const zip_file_header *header; |
| 3011 | 1791 | |
| 3012 | | // This is only called when there is really a GK module |
| 3013 | | gramkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 1792 | // find the file attribute (required) |
| 1793 | file = xml_get_attribute_string(rom_resource_node, "file", NULL); |
| 1794 | if (file == NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<rom> must have a 'file' attribute"); |
| 3014 | 1795 | |
| 3015 | | if ((offset & 0x0002)==0x0002) |
| 1796 | if (VERBOSE>6) LOG("gromport/RPK: Loading ROM contents for socket '%s' from file %s\n", socketname, file); |
| 1797 | |
| 1798 | // check for crc |
| 1799 | crcstr = xml_get_attribute_string(rom_resource_node, "crc", NULL); |
| 1800 | if (crcstr==NULL) |
| 3016 | 1801 | { |
| 3017 | | // Set address |
| 3018 | | if (gramkrackerbox->waddr_LSB) |
| 3019 | | { |
| 3020 | | /* Accept low byte (2nd write) */ |
| 3021 | | gramkrackerbox->grom_address = (gramkrackerbox->grom_address & 0xff00) | data; |
| 3022 | | gramkrackerbox->waddr_LSB = FALSE; |
| 3023 | | } |
| 3024 | | else |
| 3025 | | { |
| 3026 | | /* Accept high byte (1st write) */ |
| 3027 | | gramkrackerbox->grom_address = ((data<<8) & 0xff00) | (gramkrackerbox->grom_address & 0x00ff); |
| 3028 | | gramkrackerbox->waddr_LSB = TRUE; |
| 3029 | | } |
| 1802 | // no CRC, just find the file in the RPK |
| 1803 | header = find_file(zip, file, 0); |
| 3030 | 1804 | } |
| 3031 | 1805 | else |
| 3032 | 1806 | { |
| 3033 | | // According to manual: |
| 3034 | | // Writing to GRAM 0: switch 2 set to GRAM 0 + Write protect switch (4) in 1 or 2 position |
| 3035 | | // Writing to GRAM 1: switch 3 set to GRAM 1-2 + Loader off (5); write prot has no effect |
| 3036 | | // Writing to GRAM 2: switch 1 set to GRAM 1-2 (write prot has no effect) |
| 3037 | | // Writing to GRAM 3-7: switch set to GK_NORMAL, no cartridge inserted |
| 3038 | | // GK_NORMAL switch has no effect on GRAM 0-2 |
| 3039 | | if (((gramkrackerbox->grom_address & 0xe000)==0x0000 && get_gk_switch(cartsys, 2)==GK_GRAM0 && get_gk_switch(cartsys, 4)!=GK_WP) |
| 3040 | | || ((gramkrackerbox->grom_address & 0xe000)==0x2000 && get_gk_switch(cartsys, 3)==GK_GRAM12 && get_gk_switch(cartsys, 5)==GK_LDOFF) |
| 3041 | | || ((gramkrackerbox->grom_address & 0xe000)==0x4000 && get_gk_switch(cartsys, 3)==GK_GRAM12) |
| 3042 | | || ((gramkrackerbox->grom_address & 0xe000)==0x6000 && get_gk_switch(cartsys, 1)==GK_NORMAL && cartslots->gk_guest_slot==-1) |
| 3043 | | || ((gramkrackerbox->grom_address & 0x8000)==0x8000 && get_gk_switch(cartsys, 1)==GK_NORMAL && cartslots->gk_guest_slot==-1)) |
| 3044 | | { |
| 3045 | | (gramkrackerbox->ram_ptr)[gramkrackerbox->grom_address] = data; |
| 3046 | | } |
| 3047 | | // The GK GROM emulation does not wrap at 8K boundaries. |
| 3048 | | gramkrackerbox->grom_address = (gramkrackerbox->grom_address+1) & 0xffff; |
| 1807 | crc = strtoul(crcstr, NULL, 16); |
| 1808 | header = find_file(zip, file, crc); |
| 1809 | } |
| 1810 | if (header == NULL) throw rpk_exception(RPK_INVALID_FILE_REF, "File not found or CRC check failed"); |
| 3049 | 1811 | |
| 3050 | | /* Reset the write address flipflop. */ |
| 3051 | | gramkrackerbox->waddr_LSB = FALSE; |
| 1812 | length = header->uncompressed_length; |
| 1813 | |
| 1814 | // Allocate storage |
| 1815 | contents = malloc(length); |
| 1816 | if (contents==NULL) throw rpk_exception(RPK_OUT_OF_MEMORY); |
| 1817 | |
| 1818 | // and unzip file from the zip file |
| 1819 | ziperr = zip_file_decompress(zip, contents, length); |
| 1820 | if (ziperr != ZIPERR_NONE) throw rpk_exception(RPK_ZIP_ERROR); |
| 1821 | |
| 1822 | // check for sha1 |
| 1823 | sha1 = xml_get_attribute_string(rom_resource_node, "sha1", NULL); |
| 1824 | if (sha1 != NULL) |
| 1825 | { |
| 1826 | hash_collection actual_hashes; |
| 1827 | actual_hashes.compute((const UINT8 *)contents, length, hash_collection::HASH_TYPES_CRC_SHA1); |
| 1828 | |
| 1829 | hash_collection expected_hashes; |
| 1830 | expected_hashes.add_from_string(hash_collection::HASH_SHA1, sha1, strlen(sha1)); |
| 1831 | |
| 1832 | if (actual_hashes != expected_hashes) throw rpk_exception(RPK_INVALID_FILE_REF, "SHA1 check failed"); |
| 3052 | 1833 | } |
| 1834 | |
| 1835 | // Create a socket instance |
| 1836 | return new rpk_socket(socketname, length, contents); |
| 3053 | 1837 | } |
| 3054 | 1838 | |
| 3055 | 1839 | /* |
| 3056 | | Reads from the RAM space of the GRAM Kracker. |
| 1840 | Load a ram resource and put it in a pcb socket instance. |
| 3057 | 1841 | */ |
| 3058 | | static READ8Z_DEVICE_HANDLER( ti99_cart_gk_rz ) |
| 1842 | rpk_socket* rpk_reader::load_ram_resource(emu_options &options, xml_data_node* ram_resource_node, const char* socketname, const char* system_name) |
| 3059 | 1843 | { |
| 3060 | | // gk_slot is the slot where the GK module is plugged in |
| 3061 | | // gk_guest_slot is the slot where the cartridge is plugged in |
| 3062 | | cartridge_t *gromkrackerbox, *gkguestcart; |
| 3063 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1844 | const char* length_string; |
| 1845 | const char* ram_type; |
| 1846 | const char* ram_filename; |
| 1847 | const char* ram_pname; |
| 1848 | int length; |
| 1849 | void* contents; |
| 3064 | 1850 | |
| 3065 | | gromkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 1851 | // find the length attribute |
| 1852 | length_string = xml_get_attribute_string(ram_resource_node, "length", NULL); |
| 1853 | if (length_string == NULL) throw rpk_exception(RPK_MISSING_RAM_LENGTH); |
| 3066 | 1854 | |
| 3067 | | if (cartslots->gk_guest_slot != -1) |
| 1855 | // parse it |
| 1856 | char suffix = '\0'; |
| 1857 | sscanf(length_string, "%u%c", &length, &suffix); |
| 1858 | switch(tolower(suffix)) |
| 3068 | 1859 | { |
| 3069 | | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 3070 | | // printf("accessing cartridge in slot %d\n", slot); |
| 3071 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 3072 | | // printf("address=%lx, offset=%lx\n", pcbdef, offset); |
| 3073 | | (*pcbdef->read)(gkguestcart->pcb, offset, value); |
| 3074 | | return; |
| 1860 | case 'k': // kilobytes |
| 1861 | length *= 1024; |
| 1862 | break; |
| 1863 | |
| 1864 | case 'm': |
| 1865 | /* megabytes */ |
| 1866 | length *= 1024*1024; |
| 1867 | break; |
| 1868 | |
| 1869 | case '\0': |
| 1870 | break; |
| 1871 | |
| 1872 | default: // failed |
| 1873 | throw rpk_exception(RPK_INVALID_RAM_SPEC); |
| 3075 | 1874 | } |
| 3076 | | else |
| 1875 | |
| 1876 | // Allocate memory for this resource |
| 1877 | contents = malloc(length); |
| 1878 | if (contents==NULL) throw rpk_exception(RPK_OUT_OF_MEMORY); |
| 1879 | |
| 1880 | if (VERBOSE>6) LOG("gromport/RPK: Allocating RAM buffer (%d bytes) for socket '%s'\n", length, socketname); |
| 1881 | |
| 1882 | ram_pname = NULL; |
| 1883 | |
| 1884 | // That's it for pure RAM. Now check whether the RAM is "persistent", i.e. NVRAM. |
| 1885 | // In that case we must load it from the NVRAM directory. |
| 1886 | // The file name is given in the RPK file; the subdirectory is the system name. |
| 1887 | ram_type = xml_get_attribute_string(ram_resource_node, "type", NULL); |
| 1888 | if (ram_type != NULL) |
| 3077 | 1889 | { |
| 3078 | | if (get_gk_switch(device, 1)==GK_OFF) return; |
| 3079 | | if (get_gk_switch(device, 4)==GK_BANK1) |
| 1890 | if (strcmp(ram_type, "persistent")==0) |
| 3080 | 1891 | { |
| 3081 | | *value = (gromkrackerbox->ram_ptr)[offset+0x10000 - 0x6000]; |
| 3082 | | } |
| 3083 | | else |
| 3084 | | { |
| 3085 | | if (get_gk_switch(device, 4)==GK_BANK2) |
| 1892 | // Get the file name (required if persistent) |
| 1893 | ram_filename = xml_get_attribute_string(ram_resource_node, "file", NULL); |
| 1894 | if (ram_filename==NULL) |
| 3086 | 1895 | { |
| 3087 | | *value = (gromkrackerbox->ram_ptr)[offset+0x12000 - 0x6000]; |
| 1896 | free(contents); |
| 1897 | throw rpk_exception(RPK_INVALID_RAM_SPEC, "<ram type='persistent'> must have a 'file' attribute"); |
| 3088 | 1898 | } |
| 3089 | | else |
| 3090 | | { |
| 3091 | | // Write protection on; auto-bank |
| 3092 | | if (gromkrackerbox->ram_page==0) |
| 3093 | | { |
| 3094 | | *value = (gromkrackerbox->ram_ptr)[offset+0x10000 - 0x6000]; |
| 3095 | | } |
| 3096 | | else |
| 3097 | | { |
| 3098 | | *value = (gromkrackerbox->ram_ptr)[offset+0x12000 - 0x6000]; |
| 3099 | | } |
| 3100 | | } |
| 1899 | astring ram_pathname(system_name, PATH_SEPARATOR, ram_filename); |
| 1900 | ram_pname = core_strdup(ram_pathname.cstr()); |
| 1901 | // load, and fill rest with 00 |
| 1902 | if (VERBOSE>6) LOG("gromport/RPK: Loading NVRAM contents from '%s'\n", ram_pname); |
| 1903 | image_battery_load_by_name(options, ram_pname, contents, length, 0x00); |
| 3101 | 1904 | } |
| 3102 | 1905 | } |
| 1906 | |
| 1907 | // Create a socket instance |
| 1908 | return new rpk_socket(socketname, length, contents, ram_pname); |
| 3103 | 1909 | } |
| 3104 | 1910 | |
| 3105 | | /* |
| 3106 | | Writes to the RAM space of the GRAM Kracker. |
| 3107 | | */ |
| 3108 | | static WRITE8_DEVICE_HANDLER( ti99_cart_gk_w ) |
| 1911 | /*------------------------------------------------- |
| 1912 | rpk_open - open a RPK file |
| 1913 | options - parameters from the settings; we need it only for the NVRAM directory |
| 1914 | system_name - name of the driver (also just for NVRAM handling) |
| 1915 | -------------------------------------------------*/ |
| 1916 | |
| 1917 | rpk* rpk_reader::open(emu_options &options, const char *filename, const char *system_name) |
| 3109 | 1918 | { |
| 3110 | | // gk_slot is the slot where the GK module is plugged in |
| 3111 | | // gk_guest_slot is the slot where the cartridge is plugged in |
| 3112 | | cartridge_t *gromkrackerbox, *gkguestcart; |
| 3113 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1919 | zip_error ziperr; |
| 3114 | 1920 | |
| 3115 | | gromkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 1921 | const zip_file_header *header; |
| 1922 | const char *pcb_type; |
| 1923 | const char *id; |
| 1924 | const char *uses_name; |
| 1925 | const char *resource_name; |
| 3116 | 1926 | |
| 3117 | | if (cartslots->gk_guest_slot != -1) |
| 1927 | zip_file* zipfile; |
| 1928 | |
| 1929 | char *layout_text = NULL; |
| 1930 | xml_data_node *layout_xml; |
| 1931 | xml_data_node *romset_node; |
| 1932 | xml_data_node *configuration_node; |
| 1933 | xml_data_node *resources_node; |
| 1934 | xml_data_node *resource_node; |
| 1935 | xml_data_node *socket_node; |
| 1936 | xml_data_node *pcb_node; |
| 1937 | |
| 1938 | rpk_socket *newsock; |
| 1939 | |
| 1940 | int i; |
| 1941 | |
| 1942 | rpk *newrpk = new rpk(options, system_name); |
| 1943 | |
| 1944 | try |
| 3118 | 1945 | { |
| 3119 | | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 3120 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 3121 | | (*pcbdef->write)(gkguestcart->pcb, offset, data); |
| 3122 | | } |
| 3123 | | else |
| 3124 | | { |
| 3125 | | if (get_gk_switch(device, 1)==GK_OFF) |
| 3126 | | return; |
| 1946 | /* open the ZIP file */ |
| 1947 | ziperr = zip_file_open(filename, &zipfile); |
| 1948 | if (ziperr != ZIPERR_NONE) throw rpk_exception(RPK_NOT_ZIP_FORMAT); |
| 3127 | 1949 | |
| 3128 | | if (get_gk_switch(device, 4)==GK_BANK1) |
| 1950 | /* find the layout.xml file */ |
| 1951 | header = find_file(zipfile, "layout.xml", 0); |
| 1952 | if (header == NULL) throw rpk_exception(RPK_MISSING_LAYOUT); |
| 1953 | |
| 1954 | /* reserve space for the layout file contents (+1 for the termination) */ |
| 1955 | layout_text = (char*)malloc(header->uncompressed_length + 1); |
| 1956 | if (layout_text == NULL) throw rpk_exception(RPK_OUT_OF_MEMORY); |
| 1957 | |
| 1958 | /* uncompress the layout text */ |
| 1959 | ziperr = zip_file_decompress(zipfile, layout_text, header->uncompressed_length); |
| 1960 | if (ziperr != ZIPERR_NONE) throw rpk_exception(RPK_ZIP_ERROR); |
| 1961 | |
| 1962 | layout_text[header->uncompressed_length] = '\0'; // Null-terminate |
| 1963 | |
| 1964 | /* parse the layout text */ |
| 1965 | layout_xml = xml_string_read(layout_text, NULL); |
| 1966 | if (layout_xml == NULL) throw rpk_exception(RPK_XML_ERROR); |
| 1967 | |
| 1968 | // Now we work within the XML tree |
| 1969 | |
| 1970 | // romset is the root node |
| 1971 | romset_node = xml_get_sibling(layout_xml->child, "romset"); |
| 1972 | if (romset_node==NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "document element must be <romset>"); |
| 1973 | |
| 1974 | // resources is a child of romset |
| 1975 | resources_node = xml_get_sibling(romset_node->child, "resources"); |
| 1976 | if (resources_node==NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<romset> must have a <resources> child"); |
| 1977 | |
| 1978 | // configuration is a child of romset; we're actually interested in ... |
| 1979 | configuration_node = xml_get_sibling(romset_node->child, "configuration"); |
| 1980 | if (configuration_node==NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<romset> must have a <configuration> child"); |
| 1981 | |
| 1982 | // ... pcb, which is a child of configuration |
| 1983 | pcb_node = xml_get_sibling(configuration_node->child, "pcb"); |
| 1984 | if (pcb_node==NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<configuration> must have a <pcb> child"); |
| 1985 | |
| 1986 | // We'll try to find the PCB type on the provided type list. |
| 1987 | pcb_type = xml_get_attribute_string(pcb_node, "type", NULL); |
| 1988 | if (pcb_type==NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<pcb> must have a 'type' attribute"); |
| 1989 | if (VERBOSE>6) LOG("gromport/RPK: Cartridge says it has PCB type '%s'\n", pcb_type); |
| 1990 | |
| 1991 | i=0; |
| 1992 | do |
| 3129 | 1993 | { |
| 3130 | | (gromkrackerbox->ram_ptr)[offset + 0x10000 - 0x6000] = data; |
| 3131 | | } |
| 3132 | | else |
| 3133 | | { |
| 3134 | | if (get_gk_switch(device, 4)==GK_BANK2) |
| 1994 | if (strcmp(pcb_type, m_types[i].name)==0) |
| 3135 | 1995 | { |
| 3136 | | (gromkrackerbox->ram_ptr)[offset + 0x12000 - 0x6000] = data; |
| 1996 | newrpk->m_type = m_types[i].id; |
| 1997 | break; |
| 3137 | 1998 | } |
| 3138 | | else |
| 1999 | i++; |
| 2000 | } while (m_types[i].id != 0); |
| 2001 | |
| 2002 | if (m_types[i].id==0) throw rpk_exception(RPK_UNKNOWN_PCB_TYPE); |
| 2003 | |
| 2004 | // Find the sockets and load their respective resource |
| 2005 | for (socket_node = pcb_node->child; socket_node != NULL; socket_node = socket_node->next) |
| 2006 | { |
| 2007 | if (strcmp(socket_node->name, "socket")!=0) throw rpk_exception(RPK_INVALID_LAYOUT, "<pcb> element has only <socket> children"); |
| 2008 | id = xml_get_attribute_string(socket_node, "id", NULL); |
| 2009 | if (id == NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<socket> must have an 'id' attribute"); |
| 2010 | uses_name = xml_get_attribute_string(socket_node, "uses", NULL); |
| 2011 | if (uses_name == NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "<socket> must have a 'uses' attribute"); |
| 2012 | |
| 2013 | bool found = false; |
| 2014 | // Locate the resource node |
| 2015 | for (resource_node = resources_node->child; resource_node != NULL; resource_node = resource_node->next) |
| 3139 | 2016 | { |
| 3140 | | // Write protection on |
| 3141 | | // This is handled like in Extended Basic |
| 3142 | | gromkrackerbox->ram_page = (offset & 2)>>1; |
| 2017 | resource_name = xml_get_attribute_string(resource_node, "id", NULL); |
| 2018 | if (resource_name == NULL) throw rpk_exception(RPK_INVALID_LAYOUT, "resource node must have an 'id' attribute"); |
| 2019 | |
| 2020 | if (strcmp(resource_name, uses_name)==0) |
| 2021 | { |
| 2022 | // found it |
| 2023 | if (strcmp(resource_node->name, "rom")==0) |
| 2024 | { |
| 2025 | newsock = load_rom_resource(zipfile, resource_node, id); |
| 2026 | newrpk->add_socket(id, newsock); |
| 2027 | } |
| 2028 | else |
| 2029 | { |
| 2030 | if (strcmp(resource_node->name, "ram")==0) |
| 2031 | { |
| 2032 | newsock = load_ram_resource(options, resource_node, id, system_name); |
| 2033 | newrpk->add_socket(id, newsock); |
| 2034 | } |
| 2035 | else throw rpk_exception(RPK_INVALID_LAYOUT, "resource node must be <rom> or <ram>"); |
| 2036 | } |
| 2037 | found = true; |
| 2038 | } |
| 3143 | 2039 | } |
| 2040 | if (!found) throw rpk_exception(RPK_INVALID_RESOURCE_REF, uses_name); |
| 3144 | 2041 | } |
| 3145 | 2042 | } |
| 3146 | | } |
| 3147 | | |
| 3148 | | /* |
| 3149 | | Read cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 3150 | | */ |
| 3151 | | static READ8Z_DEVICE_HANDLER( ti99_cart_cru_gk_rz ) |
| 3152 | | { |
| 3153 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 3154 | | cartridge_t *gkguestcart; |
| 3155 | | |
| 3156 | | if (cartslots->gk_guest_slot != -1) |
| 2043 | catch (rpk_exception &exp) |
| 3157 | 2044 | { |
| 3158 | | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 3159 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 3160 | | if (pcbdef->cruread != NULL) |
| 3161 | | (*pcbdef->cruread)(gkguestcart->pcb, offset, value); |
| 3162 | | } |
| 3163 | | } |
| 2045 | newrpk->close(); |
| 2046 | if (zipfile != NULL) zip_file_close(zipfile); |
| 2047 | if (layout_text != NULL) free(layout_text); |
| 3164 | 2048 | |
| 3165 | | /* |
| 3166 | | Write cartridge mapper CRU interface (Guest in GRAM Kracker) |
| 3167 | | */ |
| 3168 | | static WRITE8_DEVICE_HANDLER( ti99_cart_cru_gk_w ) |
| 3169 | | { |
| 3170 | | ti99_multicart_state *cartslots = get_safe_token(device); |
| 3171 | | cartridge_t *gkguestcart; |
| 3172 | | |
| 3173 | | if (cartslots->gk_guest_slot != -1) |
| 3174 | | { |
| 3175 | | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 3176 | | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 3177 | | if (pcbdef->cruwrite != NULL) |
| 3178 | | (*pcbdef->cruwrite)(gkguestcart->pcb, offset, data); |
| 2049 | // rethrow the exception |
| 2050 | throw exp; |
| 3179 | 2051 | } |
| 3180 | | } |
| 3181 | 2052 | |
| 3182 | | /*****************************************************************************/ |
| 3183 | | #define TI99_CARTRIDGE_SLOT(p) MCFG_MULTICARTSLOT_ADD(p) \ |
| 3184 | | MCFG_MULTICARTSLOT_EXTENSION_LIST("rpk") \ |
| 3185 | | MCFG_MULTICARTSLOT_PCBTYPE(0, "none", TI99_CARTRIDGE_PCB_NONE) \ |
| 3186 | | MCFG_MULTICARTSLOT_PCBTYPE(1, "standard", TI99_CARTRIDGE_PCB_STD) \ |
| 3187 | | MCFG_MULTICARTSLOT_PCBTYPE(2, "paged", TI99_CARTRIDGE_PCB_PAGED) \ |
| 3188 | | MCFG_MULTICARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM) \ |
| 3189 | | MCFG_MULTICARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER) \ |
| 3190 | | MCFG_MULTICARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX) \ |
| 3191 | | MCFG_MULTICARTSLOT_PCBTYPE(6, "paged379i", TI99_CARTRIDGE_PCB_PAGED379I) \ |
| 3192 | | MCFG_MULTICARTSLOT_PCBTYPE(7, "pagedcru", TI99_CARTRIDGE_PCB_PAGEDCRU) \ |
| 3193 | | MCFG_MULTICARTSLOT_PCBTYPE(8, "gramkracker", TI99_CARTRIDGE_PCB_GRAMKRACKER) \ |
| 3194 | | MCFG_MULTICARTSLOT_START(ti99_cartridge) \ |
| 3195 | | MCFG_MULTICARTSLOT_LOAD(ti99_cartridge) \ |
| 3196 | | MCFG_MULTICARTSLOT_UNLOAD(ti99_cartridge) |
| 2053 | if (zipfile != NULL) zip_file_close(zipfile); |
| 2054 | if (layout_text != NULL) free(layout_text); |
| 3197 | 2055 | |
| 3198 | | static MACHINE_CONFIG_FRAGMENT(ti99_multicart) |
| 3199 | | TI99_CARTRIDGE_SLOT("cartridge1") |
| 3200 | | TI99_CARTRIDGE_SLOT("cartridge2") |
| 3201 | | TI99_CARTRIDGE_SLOT("cartridge3") |
| 3202 | | TI99_CARTRIDGE_SLOT("cartridge4") |
| 3203 | | MACHINE_CONFIG_END |
| 3204 | | |
| 3205 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 3206 | | |
| 3207 | | #define DEVTEMPLATE_ID(p,s) p##ti99_multicart##s |
| 3208 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG |
| 3209 | | #define DEVTEMPLATE_NAME "TI99 Multi-Cartridge Extender" |
| 3210 | | #define DEVTEMPLATE_FAMILY "Multi-cartridge system" |
| 3211 | | #include "devtempl.h" |
| 3212 | | |
| 3213 | | DEFINE_LEGACY_DEVICE(TI99_MULTICART, ti99_multicart); |
| 2056 | return newrpk; |
| 2057 | } |
src/mess/machine/ti99/genboard.c
| r14513 | r14514 | |
| 1 | 1 | /*************************************************************************** |
| 2 | | Geneve 9640 system board |
| 2 | Geneve 9640 mapper and more components |
| 3 | 3 | |
| 4 | This file contains 3 classes: |
| 5 | - mapper: main function of the Gate Array on the Geneve board. Maps logical |
| 6 | memory accesses to a wider address space using map registers. |
| 7 | - keyboard: an implementation of a XT-style keyboard. This should be dropped |
| 8 | and replaced by a proper XT keyboard implementation. |
| 9 | - mouse: an implementation of an Atari-style mouse connected to the v9938. |
| 10 | |
| 4 | 11 | Onboard SRAM configuration: |
| 5 | 12 | There is an adjustable SRAM configuration on board, representing the |
| 6 | 13 | various enhancements by users. |
| r14513 | r14514 | |
| 129 | 136 | remaining time will be used to produce wait states. |
| 130 | 137 | |
| 131 | 138 | Michael Zapf, October 2011 |
| 139 | February 2012: rewritten as class, restructured |
| 140 | |
| 132 | 141 | ***************************************************************************/ |
| 133 | 142 | |
| 134 | | #include "emu.h" |
| 135 | 143 | #include "genboard.h" |
| 136 | | #include "video/v9938.h" |
| 137 | | #include "videowrp.h" |
| 138 | | #include "sound/sn76496.h" |
| 139 | 144 | #include "machine/mm58274c.h" |
| 140 | | #include "peribox.h" |
| 141 | 145 | |
| 142 | | #define KEYQUEUESIZE 256 |
| 143 | | #define MAXKEYMSGLENGTH 10 |
| 144 | | #define KEYAUTOREPEATDELAY 30 |
| 145 | | #define KEYAUTOREPEATRATE 6 |
| 146 | #define CYCLE 333 // 333 ns for CLKOUT |
| 147 | #define VIDEOWAIT 1 // timer ID |
| 146 | 148 | |
| 147 | | #define CYCLE 333 // 333 ns for CLKOUT |
| 148 | | |
| 149 | | #define SRAM_SIZE 384*1024 // maximum SRAM expansion on-board |
| 150 | | #define DRAM_SIZE 512*1024 |
| 151 | | |
| 152 | 149 | #define VERBOSE 1 |
| 153 | 150 | #define LOG logerror |
| 154 | 151 | |
| 155 | | typedef struct _genboard_state |
| 152 | geneve_mapper_device::geneve_mapper_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 153 | : device_t(mconfig, GENEVE_MAPPER, "Geneve Gate Array", tag, owner, clock) |
| 156 | 154 | { |
| 157 | | /* Mouse support */ |
| 158 | | int last_mx; |
| 159 | | int last_my; |
| 160 | | |
| 161 | | /* Joystick support */ |
| 162 | | int joySel; |
| 163 | | |
| 164 | | /* Keyboard support */ |
| 165 | | UINT8 keyQueue[KEYQUEUESIZE]; |
| 166 | | int keyQueueHead; |
| 167 | | int keyQueueLen; |
| 168 | | bool keyInBuf; |
| 169 | | int keyReset; |
| 170 | | UINT32 keyStateSave[4]; |
| 171 | | int keyNumLockState; |
| 172 | | int keyCtrlState; |
| 173 | | int keyAltState; |
| 174 | | int keyRealShiftState; |
| 175 | | int keyFakeShiftState; |
| 176 | | int keyFakeUnshiftState; |
| 177 | | int keyAutoRepeatKey; |
| 178 | | int keyAutoRepeatTimer; |
| 179 | | |
| 180 | | /* Mode flags */ |
| 181 | | bool palvideo; // uncertain, could not be verified with real system |
| 182 | | bool capslock; |
| 183 | | bool keyboard_clock; |
| 184 | | bool keep_keybuf; |
| 185 | | bool extra_waitstates; |
| 186 | | |
| 187 | | bool genmod; |
| 188 | | bool turbo; |
| 189 | | bool timode; |
| 190 | | |
| 191 | | /* GROM simulation */ |
| 192 | | int grom_address; |
| 193 | | bool gromraddr_LSB; |
| 194 | | bool gromwaddr_LSB; |
| 195 | | |
| 196 | | /* Memory */ |
| 197 | | UINT8 *sram; |
| 198 | | UINT8 *dram; |
| 199 | | UINT8 *eprom; |
| 200 | | int sram_mask, sram_val; |
| 201 | | |
| 202 | | /* Mapper */ |
| 203 | | bool geneve_mode; |
| 204 | | bool direct_mode; |
| 205 | | bool cartridge_size_8K; |
| 206 | | bool cartridge_secondpage; |
| 207 | | bool cartridge6_writable; |
| 208 | | bool cartridge7_writable; |
| 209 | | int map[8]; |
| 210 | | |
| 211 | | int line_count; |
| 212 | | |
| 213 | | /* Devices */ |
| 214 | | device_t *cpu; |
| 215 | | device_t *video; |
| 216 | | device_t *tms9901; |
| 217 | | device_t *clock; |
| 218 | | device_t *peribox; |
| 219 | | device_t *sound; |
| 220 | | |
| 221 | | /* VDP Waitstate timer */ |
| 222 | | bool video_waitstates; |
| 223 | | emu_timer *video_waittimer; |
| 224 | | bool video_waiting; |
| 225 | | |
| 226 | | } genboard_state; |
| 227 | | |
| 228 | | static const UINT8 keyboard_mf1_code[0xe] = |
| 229 | | { |
| 230 | | /* extended keys that are equivalent to non-extended keys */ |
| 231 | | 0x1c, /* keypad enter */ |
| 232 | | 0x1d, /* right control */ |
| 233 | | 0x38, /* alt gr */ |
| 234 | | // extra codes are 0x5b for Left Windows, 0x5c for Right Windows, 0x5d |
| 235 | | // for Menu, 0x5e for power, 0x5f for sleep, 0x63 for wake, but I doubt |
| 236 | | // any Geneve program would take advantage of these. */ |
| 237 | | |
| 238 | | // extended key that is equivalent to a non-extended key |
| 239 | | // with shift off |
| 240 | | 0x35, /* pad slash */ |
| 241 | | |
| 242 | | // extended keys that are equivalent to non-extended keys |
| 243 | | // with numlock off |
| 244 | | 0x47, /* home */ |
| 245 | | 0x48, /* up */ |
| 246 | | 0x49, /* page up */ |
| 247 | | 0x4b, /* left */ |
| 248 | | 0x4d, /* right */ |
| 249 | | 0x4f, /* end */ |
| 250 | | 0x50, /* down */ |
| 251 | | 0x51, /* page down */ |
| 252 | | 0x52, /* insert */ |
| 253 | | 0x53 /* delete */ |
| 254 | | }; |
| 255 | | |
| 256 | | static void poll_keyboard(device_t *device); |
| 257 | | static void poll_mouse(device_t *device); |
| 258 | | static void signal_when_key_available(genboard_state *board); |
| 259 | | static UINT8 get_recent_key(device_t *device); |
| 260 | | |
| 261 | | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7" }; |
| 262 | | |
| 263 | | INLINE genboard_state *get_safe_token(device_t *device) |
| 264 | | { |
| 265 | | assert(device != NULL); |
| 266 | | assert(device->type() == GENBOARD); |
| 267 | | |
| 268 | | return (genboard_state *)downcast<legacy_device_base *>(device)->token(); |
| 155 | m_eprom = NULL; |
| 269 | 156 | } |
| 270 | 157 | |
| 271 | 158 | /* |
| 272 | 159 | Callback for VDP waitstate. Not really needed, just for completeness. |
| 273 | 160 | */ |
| 274 | | static TIMER_CALLBACK(video_wait_callback) |
| 161 | void geneve_mapper_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 275 | 162 | { |
| 276 | | device_t *device = (device_t *)ptr; |
| 277 | | genboard_state *board = get_safe_token(device); |
| 278 | | board->video_waiting = false; |
| 163 | // Just remove that flag again. |
| 164 | m_video_waiting = false; |
| 279 | 165 | } |
| 280 | 166 | |
| 281 | | /* |
| 282 | | scanline interrupt |
| 283 | | */ |
| 284 | | TIMER_DEVICE_CALLBACK( geneve_hblank_interrupt ) |
| 167 | INPUT_CHANGED_MEMBER( geneve_mapper_device::gm_changed ) |
| 285 | 168 | { |
| 286 | | device_t *dev = timer.machine().device("geneve_board"); |
| 287 | | int scanline = param; |
| 288 | | //genboard_state *board = get_safe_token(dev); |
| 169 | int number = (int)((UINT64)param&0x03); |
| 170 | int value = newval; |
| 289 | 171 | |
| 290 | | timer.machine().device<v9938_device>("video_v9938")->interrupt(); |
| 291 | | //board->line_count++; |
| 292 | | if (scanline == 0) // was 262 |
| 293 | | { |
| 294 | | //board->line_count = 0; |
| 295 | | poll_keyboard(dev); |
| 296 | | poll_mouse(dev); |
| 297 | | } |
| 298 | | } |
| 299 | | |
| 300 | | void set_gm_switches(device_t *board, int number, int value) |
| 301 | | { |
| 302 | 172 | if (number==1) |
| 303 | 173 | { |
| 304 | 174 | // Turbo switch. May be changed at any time. |
| 305 | | if (VERBOSE>0) LOG("genboard / genmod: Setting turbo flag to %d\n", value); |
| 306 | | ((genboard_state*)board)->turbo = (value!=0); |
| 175 | if (VERBOSE>0) LOG("geneve / genmod: Setting turbo flag to %d\n", value); |
| 176 | m_turbo = (value!=0); |
| 307 | 177 | } |
| 308 | 178 | else |
| 309 | 179 | { |
| 310 | 180 | // TIMode switch. Causes reset when changed. |
| 311 | | if (VERBOSE>0) LOG("genboard / genmod: Setting timode flag to %d\n", value); |
| 312 | | ((genboard_state*)board)->timode = (value!=0); |
| 313 | | board->machine().schedule_hard_reset(); |
| 181 | if (VERBOSE>0) LOG("geneve / genmod: Setting timode flag to %d\n", value); |
| 182 | m_timode = (value!=0); |
| 183 | machine().schedule_hard_reset(); |
| 314 | 184 | } |
| 315 | 185 | } |
| 186 | |
| 316 | 187 | /**************************************************************************** |
| 317 | 188 | GROM simulation. The Geneve board simulated GROM circuits within its gate |
| 318 | 189 | array. |
| r14513 | r14514 | |
| 323 | 194 | within the gate array. Unlike with real GROMs, no address wrapping occurs, |
| 324 | 195 | and the complete 64K space is available. |
| 325 | 196 | */ |
| 326 | | static READ8_DEVICE_HANDLER( read_grom ) |
| 197 | READ8_MEMBER( geneve_mapper_device::read_grom ) |
| 327 | 198 | { |
| 328 | | genboard_state *board = get_safe_token(device); |
| 329 | 199 | UINT8 reply; |
| 330 | 200 | if (offset & 0x0002) |
| 331 | 201 | { |
| 332 | 202 | // GROM address handling |
| 333 | | board->gromwaddr_LSB = false; |
| 203 | m_gromwaddr_LSB = false; |
| 334 | 204 | |
| 335 | | if (board->gromraddr_LSB) |
| 205 | if (m_gromraddr_LSB) |
| 336 | 206 | { |
| 337 | | reply = board->grom_address & 0xff; |
| 338 | | board->gromraddr_LSB = false; |
| 207 | reply = m_grom_address & 0xff; |
| 208 | m_gromraddr_LSB = false; |
| 339 | 209 | } |
| 340 | 210 | else |
| 341 | 211 | { |
| 342 | | reply = (board->grom_address >> 8) & 0xff; |
| 343 | | board->gromraddr_LSB = true; |
| 212 | reply = (m_grom_address >> 8) & 0xff; |
| 213 | m_gromraddr_LSB = true; |
| 344 | 214 | } |
| 345 | 215 | } |
| 346 | 216 | else |
| r14513 | r14514 | |
| 348 | 218 | // GROM data handling |
| 349 | 219 | // GROMs are stored in pages 38..3f |
| 350 | 220 | int page = 0x38; |
| 351 | | reply = board->dram[page*0x2000 + board->grom_address]; |
| 352 | | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 353 | | board->gromraddr_LSB = board->gromwaddr_LSB = false; |
| 221 | reply = m_dram[(page<<13) + m_grom_address]; |
| 222 | m_grom_address = (m_grom_address + 1) & 0xffff; |
| 223 | m_gromraddr_LSB = m_gromwaddr_LSB = false; |
| 354 | 224 | } |
| 355 | 225 | return reply; |
| 356 | 226 | } |
| r14513 | r14514 | |
| 359 | 229 | Simulates GROM. The real Geneve does not use GROMs but simulates them |
| 360 | 230 | within the gate array. |
| 361 | 231 | */ |
| 362 | | static WRITE8_DEVICE_HANDLER( write_grom ) |
| 232 | WRITE8_MEMBER( geneve_mapper_device::write_grom ) |
| 363 | 233 | { |
| 364 | | genboard_state *board = get_safe_token(device); |
| 365 | 234 | if (offset & 0x0002) |
| 366 | 235 | { |
| 367 | 236 | // set address |
| 368 | | board->gromraddr_LSB = false; |
| 369 | | if (board->gromwaddr_LSB) |
| 237 | m_gromraddr_LSB = false; |
| 238 | if (m_gromwaddr_LSB) |
| 370 | 239 | { |
| 371 | | board->grom_address = (board->grom_address & 0xff00) | data; |
| 372 | | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 373 | | board->gromwaddr_LSB = false; |
| 240 | m_grom_address = (m_grom_address & 0xff00) | data; |
| 241 | m_grom_address = (m_grom_address + 1) & 0xffff; |
| 242 | m_gromwaddr_LSB = false; |
| 374 | 243 | } |
| 375 | 244 | else |
| 376 | 245 | { |
| 377 | | board->grom_address = (board->grom_address & 0x00ff) | ((UINT16)data<<8); |
| 378 | | board->gromwaddr_LSB = true; |
| 246 | m_grom_address = (m_grom_address & 0x00ff) | ((UINT16)data<<8); |
| 247 | m_gromwaddr_LSB = true; |
| 379 | 248 | } |
| 380 | 249 | } |
| 381 | 250 | else |
| 382 | 251 | { // write GPL data |
| 383 | 252 | // The Geneve GROM simulator allows for GROM writing (verified with a real system) |
| 384 | 253 | int page = 0x38; |
| 385 | | board->dram[page*0x2000 + board->grom_address] = data; |
| 254 | m_dram[(page<<13) + m_grom_address] = data; |
| 386 | 255 | |
| 387 | | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 388 | | board->gromraddr_LSB = board->gromwaddr_LSB = false; |
| 256 | m_grom_address = (m_grom_address + 1) & 0xffff; |
| 257 | m_gromraddr_LSB = m_gromwaddr_LSB = false; |
| 389 | 258 | } |
| 390 | 259 | } |
| 391 | 260 | |
| r14513 | r14514 | |
| 406 | 275 | |
| 407 | 276 | */ |
| 408 | 277 | |
| 409 | | static void start_video_wait(device_t *device, int ws) |
| 278 | void geneve_mapper_device::start_video_wait(int ws) |
| 410 | 279 | { |
| 411 | | genboard_state *board = get_safe_token(device); |
| 412 | | board->video_waittimer->adjust(attotime::from_nsec(CYCLE * ws)); |
| 413 | | board->video_waiting = true; |
| 280 | m_video_waittimer->adjust(attotime::from_nsec(CYCLE * ws)); |
| 281 | m_video_waiting = true; |
| 414 | 282 | } |
| 415 | 283 | |
| 416 | | static void do_wait(device_t *device, int min) |
| 284 | void geneve_mapper_device::do_wait(int min) |
| 417 | 285 | { |
| 418 | 286 | long ws; |
| 419 | | genboard_state *board = get_safe_token(device); |
| 420 | 287 | |
| 421 | 288 | // Extra waitstates? |
| 422 | | if (board->extra_waitstates && min < 2) min = 2; |
| 289 | if (m_extra_waitstates && min < 2) min = 2; |
| 423 | 290 | |
| 424 | | if (board->video_waiting) { |
| 425 | | attotime left = board->video_waittimer->remaining(); |
| 291 | if (m_video_waiting) { |
| 292 | attotime left = m_video_waittimer->remaining(); |
| 426 | 293 | ws = (left.as_attoseconds()/ATTOSECONDS_PER_NANOSECOND) / CYCLE; |
| 427 | 294 | } |
| 428 | 295 | else ws = 0; |
| 429 | 296 | |
| 430 | 297 | // Now wait for the remaining time or for at least the min time |
| 431 | | device_adjust_icount(board->cpu, -4 * ((ws < min)? min : ws)); |
| 298 | device_adjust_icount(m_cpu, -4 * ((ws < min)? min : ws)); |
| 432 | 299 | } |
| 433 | 300 | |
| 434 | | READ8_DEVICE_HANDLER( geneve_r ) |
| 301 | /************************************************************************ |
| 302 | Called by the address map |
| 303 | ************************************************************************/ |
| 304 | |
| 305 | READ8_MEMBER( geneve_mapper_device::readm ) |
| 435 | 306 | { |
| 436 | | genboard_state *board = get_safe_token(device); |
| 437 | 307 | UINT8 value = 0; |
| 438 | 308 | int page; |
| 439 | 309 | UINT32 physaddr; |
| 440 | 310 | |
| 441 | 311 | // Premature access. The CPU reads the start vector before RESET. |
| 442 | | if (board->peribox==NULL) return 0; |
| 312 | if (m_eprom==NULL) return 0; |
| 443 | 313 | |
| 444 | | if (board->geneve_mode) |
| 314 | if (m_geneve_mode) |
| 445 | 315 | { |
| 446 | 316 | // TODO: shortcut offset & 0xffc0 = 0xf100 |
| 447 | 317 | if ((offset & 0xfff5)==0xf100) |
| r14513 | r14514 | |
| 453 | 323 | // 1111 0001 0000 1000 |
| 454 | 324 | // 1111 0001 0000 1010 |
| 455 | 325 | |
| 456 | | // 1 WS is always added; any pending video waitstates are canceled |
| 457 | | board->video_waiting = false; |
| 458 | | do_wait(device, 1); |
| 326 | // 1 WS is always added; any pending video wait states are canceled |
| 327 | m_video_waiting = false; |
| 328 | do_wait(1); |
| 459 | 329 | |
| 460 | | // Initialize waitstate timer |
| 461 | | // Create 16 waitstates (2 more than expected, experimenting) |
| 462 | | if (board->video_waitstates) |
| 463 | | start_video_wait(device, 16); |
| 330 | // Initialize wait state timer |
| 331 | // Create 16 wait states (2 more than expected, experimenting) |
| 332 | if (m_video_waitstates) |
| 333 | start_video_wait(16); |
| 464 | 334 | |
| 465 | | gen_v9938_rz(board->video, offset, &value); |
| 335 | m_video->readz(space, offset, &value, mem_mask); |
| 466 | 336 | return value; |
| 467 | 337 | } |
| 468 | 338 | if ((offset & 0xfff8)==0xf110) |
| 469 | 339 | { |
| 470 | 340 | // mapper |
| 471 | | value = board->map[offset & 0x0007]; |
| 341 | value = m_map[offset & 0x0007]; |
| 472 | 342 | |
| 473 | 343 | // Add appropriate number of waitstates |
| 474 | 344 | // 1 WS is added at least |
| 475 | | do_wait(device, 1); |
| 345 | do_wait(1); |
| 476 | 346 | return value; |
| 477 | 347 | } |
| 478 | 348 | if ((offset & 0xfff8) == 0xf118) |
| 479 | 349 | { |
| 480 | 350 | // key |
| 481 | | value = get_recent_key(device); |
| 482 | | do_wait(device, 1); |
| 351 | value = m_keyboard->get_recent_key(); |
| 352 | do_wait(1); |
| 483 | 353 | return value; |
| 484 | 354 | } |
| 485 | 355 | if ((offset & 0xfff0)==0xf130) |
| r14513 | r14514 | |
| 487 | 357 | // clock |
| 488 | 358 | // tests on the real machine showed that |
| 489 | 359 | // upper nibble is 0xf (probably because of the location at 0xf130?) |
| 490 | | value = mm58274c_r(board->clock, offset & 0x000f) | 0xf0; |
| 491 | | do_wait(device, 1); |
| 360 | value = mm58274c_r(m_clock, offset & 0x000f) | 0xf0; |
| 361 | do_wait(1); |
| 492 | 362 | return value; |
| 493 | 363 | } |
| 494 | 364 | } |
| r14513 | r14514 | |
| 497 | 367 | if ((offset & 0xfff8)==0x8000) |
| 498 | 368 | { |
| 499 | 369 | // mapper |
| 500 | | value = board->map[offset & 0x0007]; |
| 501 | | do_wait(device, 1); |
| 370 | value = m_map[offset & 0x0007]; |
| 371 | do_wait(1); |
| 502 | 372 | return value; |
| 503 | 373 | } |
| 504 | 374 | if ((offset & 0xfff8)== 0x8008) |
| 505 | 375 | { |
| 506 | 376 | // key |
| 507 | | value = get_recent_key(device); |
| 508 | | do_wait(device, 1); |
| 377 | value = m_keyboard->get_recent_key(); |
| 378 | do_wait(1); |
| 509 | 379 | return value; |
| 510 | 380 | } |
| 511 | 381 | if ((offset & 0xfff0)==0x8010) |
| r14513 | r14514 | |
| 518 | 388 | // Obscure, needs more investigation. We might as well ignore this, |
| 519 | 389 | // as the high nibble is obviously undefined and takes some past |
| 520 | 390 | // value floating around. |
| 521 | | value = mm58274c_r(board->clock, offset & 0x000f); |
| 391 | value = mm58274c_r(m_clock, offset & 0x000f); |
| 522 | 392 | value |= ((offset & 0x000f)==0x000f)? 0x20 : 0x10; |
| 523 | 393 | |
| 524 | | do_wait(device, 1); |
| 394 | do_wait(1); |
| 525 | 395 | return value; |
| 526 | 396 | } |
| 527 | 397 | if ((offset & 0xfc01)==0x8800) |
| r14513 | r14514 | |
| 529 | 399 | // video |
| 530 | 400 | // ++++ ++-- ---- ---+ |
| 531 | 401 | // 1000 1000 0000 00x0 |
| 532 | | // device_adjust_icount(board->cpu, -4); |
| 402 | // device_adjust_icount(m_cpu, -4); |
| 533 | 403 | |
| 534 | 404 | // 1 WS is always added; any pending video waitstates are canceled |
| 535 | | board->video_waiting = false; |
| 536 | | do_wait(device, 1); |
| 405 | m_video_waiting = false; |
| 406 | do_wait(1); |
| 537 | 407 | |
| 538 | 408 | // Initialize waitstate timer |
| 539 | 409 | // Create 14 waitstates (+2, see above) |
| 540 | | if (board->video_waitstates) |
| 541 | | start_video_wait(device, 16); |
| 410 | if (m_video_waitstates) |
| 411 | start_video_wait(16); |
| 542 | 412 | |
| 543 | | gen_v9938_rz(board->video, offset, &value); |
| 413 | m_video->readz(space, offset, &value, mem_mask); |
| 544 | 414 | return value; |
| 545 | 415 | } |
| 546 | 416 | if ((offset & 0xfc01)==0x9000) |
| r14513 | r14514 | |
| 549 | 419 | // ++++ ++-- ---- ---+ |
| 550 | 420 | // 1001 0000 0000 0000 |
| 551 | 421 | // We need to add the address prefix bits |
| 552 | | ti99_peb_data_rz(board->peribox, offset | ((board->genmod)? 0x170000 : 0x070000), &value); |
| 422 | m_peribox->readz(space, offset | ((m_genmod)? 0x170000 : 0x070000), &value, mem_mask); |
| 553 | 423 | |
| 554 | | do_wait(device, 1); |
| 424 | do_wait(1); |
| 555 | 425 | return value; |
| 556 | 426 | } |
| 557 | 427 | if ((offset & 0xfc01)==0x9800) |
| r14513 | r14514 | |
| 559 | 429 | // grom simulation |
| 560 | 430 | // ++++ ++-- ---- ---+ |
| 561 | 431 | // 1001 1000 0000 00x0 |
| 562 | | value = read_grom(device, offset); |
| 432 | value = read_grom(space, offset, mem_mask); |
| 563 | 433 | |
| 564 | | do_wait(device, 1); |
| 434 | do_wait(1); |
| 565 | 435 | return value; |
| 566 | 436 | } |
| 567 | 437 | } |
| 568 | 438 | |
| 569 | 439 | page = (offset & 0xe000) >> 13; |
| 570 | 440 | |
| 571 | | if (board->direct_mode) |
| 441 | if (m_direct_mode) |
| 572 | 442 | { |
| 573 | 443 | physaddr = 0x1e0000; // points to boot eprom |
| 574 | 444 | } |
| 575 | 445 | else |
| 576 | 446 | { |
| 577 | | if (!board->geneve_mode && page==3) |
| 447 | if (!m_geneve_mode && page==3) |
| 578 | 448 | { |
| 579 | 449 | // Cartridge paging in TI mode |
| 580 | 450 | // See also cartridge type "paged" in gromport.h |
| 581 | 451 | // value 0x36 = 0 0110 110x xxxx xxxx xxxx (page 1) |
| 582 | 452 | // value 0x37 = 0 0110 111x xxxx xxxx xxxx (page 2) |
| 583 | 453 | // Only use this if there are 2*8 KiB cartridge ROM |
| 584 | | if (!board->cartridge_size_8K && board->cartridge_secondpage) physaddr = 0x06e000; |
| 454 | if (m_cartridge_size==0x4000 && m_cartridge_secondpage) physaddr = 0x06e000; |
| 585 | 455 | else physaddr = 0x06c000; |
| 586 | 456 | } |
| 587 | 457 | else |
| 588 | 458 | { |
| 589 | | physaddr = (board->map[page] << 13); |
| 459 | physaddr = (m_map[page] << 13); |
| 590 | 460 | } |
| 591 | 461 | } |
| 592 | 462 | |
| 593 | 463 | physaddr |= (offset & 0x1fff); |
| 594 | 464 | |
| 595 | | if (!board->genmod) |
| 465 | if (!m_genmod) |
| 596 | 466 | { |
| 597 | 467 | // Standard Geneve |
| 598 | 468 | if ((physaddr & 0x180000)==0x000000) |
| 599 | 469 | { |
| 600 | 470 | // DRAM. One wait state. |
| 601 | | // device_adjust_icount(board->cpu, -4); |
| 602 | | do_wait(device, 1); |
| 471 | // device_adjust_icount(m_cpu, -4); |
| 472 | do_wait(1); |
| 603 | 473 | |
| 604 | | value = board->dram[physaddr & 0x07ffff]; |
| 474 | value = m_dram[physaddr & 0x07ffff]; |
| 605 | 475 | // printf("dram read physaddr = %06x logaddr = %04x value = %02x\n", physaddr, offset, value); |
| 606 | 476 | return value; |
| 607 | 477 | } |
| r14513 | r14514 | |
| 609 | 479 | if ((physaddr & 0x180000)==0x080000) |
| 610 | 480 | { |
| 611 | 481 | // On-board memory expansion for standard Geneve (never used) |
| 612 | | // device_adjust_icount(board->cpu, -4); |
| 613 | | do_wait(device, 1); |
| 482 | // device_adjust_icount(m_cpu, -4); |
| 483 | do_wait(1); |
| 614 | 484 | return 0; |
| 615 | 485 | } |
| 616 | 486 | |
| r14513 | r14514 | |
| 618 | 488 | { |
| 619 | 489 | // 1 111. ..xx xxxx xxxx xxxx on-board eprom (16K) |
| 620 | 490 | // mirrored for f0, f2, f4, ...; f1, f3, f5, ... |
| 621 | | value = board->eprom[physaddr & 0x003fff]; |
| 622 | | // printf("eprom read physaddr = %06x logaddr = %04x value = %02x\n", physaddr, offset, value); |
| 623 | | do_wait(device, 1); |
| 491 | value = m_eprom[physaddr & 0x003fff]; |
| 492 | if (VERBOSE>8) LOG("eprom read physaddr = %06x logaddr = %04x value = %02x\n", physaddr, offset, value); |
| 493 | do_wait(1); |
| 624 | 494 | return value; |
| 625 | 495 | } |
| 626 | 496 | |
| 627 | 497 | if ((physaddr & 0x180000)==0x180000) |
| 628 | 498 | { |
| 629 | | if ((physaddr & board->sram_mask)==board->sram_val) |
| 499 | if ((physaddr & m_sram_mask)==m_sram_val) |
| 630 | 500 | { |
| 631 | | value = board->sram[physaddr & ~board->sram_mask]; |
| 501 | value = m_sram[physaddr & ~m_sram_mask]; |
| 632 | 502 | } |
| 633 | 503 | // Return in any case |
| 634 | 504 | // printf("sram read physaddr = %06x logaddr = %04x value = %02x\n", physaddr, offset, value); |
| 635 | | do_wait(device, 0); |
| 505 | do_wait(0); |
| 636 | 506 | return value; |
| 637 | 507 | } |
| 638 | 508 | |
| r14513 | r14514 | |
| 640 | 510 | // 0x000000-0x07ffff for the stock Geneve (AMC,AMB,AMA,A0 ...,A15) |
| 641 | 511 | // 0x000000-0x1fffff for the GenMod.(AME,AMD,AMC,AMB,AMA,A0 ...,A15) |
| 642 | 512 | // Add a wait state |
| 643 | | do_wait(device, 1); |
| 513 | do_wait(1); |
| 644 | 514 | |
| 645 | 515 | physaddr = (physaddr & 0x0007ffff); // 19 bit address (with AMA..AMC) |
| 646 | | ti99_peb_data_rz(board->peribox, physaddr, &value); |
| 516 | m_peribox->readz(space, physaddr, &value, mem_mask); |
| 647 | 517 | return value; |
| 648 | 518 | } |
| 649 | 519 | else |
| 650 | 520 | { |
| 651 | 521 | // GenMod mode |
| 652 | | if ((board->timode) && ((physaddr & 0x180000)==0x000000)) |
| 522 | if ((m_timode) && ((physaddr & 0x180000)==0x000000)) |
| 653 | 523 | { |
| 654 | 524 | // DRAM. One wait state. |
| 655 | | value = board->dram[physaddr & 0x07ffff]; |
| 656 | | if (!board->turbo) do_wait(device, 1); |
| 525 | value = m_dram[physaddr & 0x07ffff]; |
| 526 | if (!m_turbo) do_wait(1); |
| 657 | 527 | return value; |
| 658 | 528 | } |
| 659 | 529 | |
| r14513 | r14514 | |
| 661 | 531 | { |
| 662 | 532 | // 1 111. ..xx xxxx xxxx xxxx on-board eprom (16K) |
| 663 | 533 | // mirrored for f0, f2, f4, ...; f1, f3, f5, ... |
| 664 | | value = board->eprom[physaddr & 0x003fff]; |
| 665 | | do_wait(device, 0); |
| 534 | value = m_eprom[physaddr & 0x003fff]; |
| 535 | do_wait(0); |
| 666 | 536 | return value; |
| 667 | 537 | } |
| 668 | 538 | // Route everything else to the P-Box |
| 669 | 539 | physaddr = (physaddr & 0x001fffff); // 21 bit address for Genmod |
| 670 | 540 | |
| 671 | | if (!board->turbo) do_wait(device, 1); |
| 541 | if (!m_turbo) do_wait(1); |
| 672 | 542 | // Check: Are waitstates completely turned off for turbo mode, or |
| 673 | 543 | // merely the waitstates for DRAM memory access and box access? |
| 674 | 544 | |
| 675 | | ti99_peb_data_rz(board->peribox, physaddr, &value); |
| 545 | m_peribox->readz(space, physaddr, &value, mem_mask); |
| 676 | 546 | return value; |
| 677 | 547 | } |
| 678 | 548 | } |
| r14513 | r14514 | |
| 695 | 565 | |
| 696 | 566 | */ |
| 697 | 567 | |
| 698 | | WRITE8_DEVICE_HANDLER( geneve_w ) |
| 568 | WRITE8_MEMBER( geneve_mapper_device::writem ) |
| 699 | 569 | { |
| 700 | | genboard_state *board = get_safe_token(device); |
| 701 | 570 | UINT32 physaddr; |
| 702 | 571 | int page; |
| 703 | 572 | |
| 704 | | if (board->peribox==NULL) return; |
| 573 | if (m_peribox==NULL) return; // see above: prevent premature access |
| 705 | 574 | |
| 706 | | if (board->geneve_mode) |
| 575 | if (m_geneve_mode) |
| 707 | 576 | { |
| 708 | 577 | if ((offset & 0xfff1)==0xf100) |
| 709 | 578 | { |
| 710 | 579 | // video |
| 711 | 580 | // ++++ ++++ ++++ ---+ |
| 712 | 581 | // 1111 0001 0000 .cc0 |
| 713 | | // device_adjust_icount(board->cpu, -4); |
| 582 | // device_adjust_icount(m_cpu, -4); |
| 714 | 583 | |
| 715 | | gen_v9938_w(board->video, offset, data); |
| 584 | m_video->write(space, offset, data, mem_mask); |
| 716 | 585 | |
| 717 | 586 | // 1 WS is always added; any pending video waitstates are canceled |
| 718 | | board->video_waiting = false; |
| 719 | | do_wait(device, 1); |
| 587 | m_video_waiting = false; |
| 588 | do_wait(1); |
| 720 | 589 | |
| 721 | 590 | // Initialize waitstate timer |
| 722 | 591 | // Create 14 waitstates (+3, experimenting) |
| 723 | | if (board->video_waitstates) |
| 724 | | start_video_wait(device, 17); |
| 592 | if (m_video_waitstates) |
| 593 | start_video_wait(17); |
| 725 | 594 | |
| 726 | 595 | return; |
| 727 | 596 | } |
| 728 | 597 | if ((offset & 0xfff8)==0xf110) |
| 729 | 598 | { |
| 730 | 599 | // mapper |
| 731 | | board->map[offset & 0x0007] = data; |
| 732 | | do_wait(device, 1); |
| 600 | m_map[offset & 0x0007] = data; |
| 601 | do_wait(1); |
| 733 | 602 | return; |
| 734 | 603 | } |
| 735 | 604 | if ((offset & 0xfff1)==0xf120) |
| 736 | 605 | { |
| 737 | 606 | // sound |
| 738 | 607 | // ++++ ++++ ++++ ---+ |
| 739 | | sn76496_w(board->sound, 0, data); |
| 608 | m_sound->write(space, 0, data, mem_mask); |
| 740 | 609 | |
| 741 | | // Add 24 waitstates. This is an approximation, as the |
| 610 | // Add 24 waitstates. This is an average value, as the |
| 742 | 611 | // waitstate generation seems to depend on an external timer of |
| 743 | 612 | // the sound chip |
| 744 | | device_adjust_icount(board->cpu, -4 * 24); |
| 613 | device_adjust_icount(m_cpu, -4 * 24); |
| 745 | 614 | return; |
| 746 | 615 | } |
| 747 | 616 | if ((offset & 0xfff0)==0xf130) |
| 748 | 617 | { |
| 749 | 618 | // clock |
| 750 | 619 | // ++++ ++++ ++++ ---- |
| 751 | | mm58274c_w(board->clock, offset & 0x00f, data); |
| 752 | | do_wait(device, 1); |
| 620 | mm58274c_w(m_clock, offset & 0x00f, data); |
| 621 | do_wait(1); |
| 753 | 622 | return; |
| 754 | 623 | } |
| 755 | 624 | } |
| r14513 | r14514 | |
| 759 | 628 | if ((offset & 0xfff8)==0x8000) |
| 760 | 629 | { |
| 761 | 630 | // mapper |
| 762 | | board->map[offset & 0x0007] = data; |
| 763 | | do_wait(device, 1); |
| 631 | m_map[offset & 0x0007] = data; |
| 632 | do_wait(1); |
| 764 | 633 | return; |
| 765 | 634 | } |
| 766 | 635 | // No key write at 8008 |
| 767 | 636 | if ((offset & 0xfff0)==0x8010) |
| 768 | 637 | { |
| 769 | 638 | // clock |
| 770 | | mm58274c_w(board->clock, offset & 0x00f, data); |
| 771 | | do_wait(device, 1); |
| 639 | mm58274c_w(m_clock, offset & 0x00f, data); |
| 640 | do_wait(1); |
| 772 | 641 | return; |
| 773 | 642 | } |
| 774 | 643 | if ((offset & 0xfc01)==0x8400) |
| r14513 | r14514 | |
| 777 | 646 | // ++++ ++-- ---- ---+ |
| 778 | 647 | // 1000 0100 0000 0000 |
| 779 | 648 | |
| 780 | | sn76496_w(board->sound, 0, data); |
| 649 | m_sound->write(space, 0, data, mem_mask); |
| 781 | 650 | // Add 24 waitstates. This is an approximation, as the |
| 782 | 651 | // waitstate generation seems to depend on an external timer of |
| 783 | 652 | // the sound chip |
| 784 | | device_adjust_icount(board->cpu, -4 * 24); |
| 653 | device_adjust_icount(m_cpu, -4 * 24); |
| 785 | 654 | return; |
| 786 | 655 | } |
| 787 | 656 | if ((offset & 0xfc01)==0x8c00) |
| r14513 | r14514 | |
| 789 | 658 | // video |
| 790 | 659 | // ++++ ++-- ---- ---+ |
| 791 | 660 | // 1000 1100 0000 00c0 |
| 792 | | // device_adjust_icount(board->cpu, -4); |
| 661 | // device_adjust_icount(m_cpu, -4); |
| 793 | 662 | // Initialize waitstate timer |
| 794 | | gen_v9938_w(board->video, offset, data); |
| 663 | m_video->write(space, offset, data, mem_mask); |
| 795 | 664 | |
| 796 | 665 | // 1 WS is always added; any pending video waitstates are canceled |
| 797 | | board->video_waiting = false; |
| 798 | | do_wait(device, 1); |
| 666 | m_video_waiting = false; |
| 667 | do_wait(1); |
| 799 | 668 | |
| 800 | 669 | // Initialize waitstate timer |
| 801 | 670 | // Create 14 waitstates (+3) |
| 802 | | if (board->video_waitstates) |
| 803 | | start_video_wait(device, 17); |
| 671 | if (m_video_waitstates) |
| 672 | start_video_wait(17); |
| 804 | 673 | |
| 805 | 674 | return; |
| 806 | 675 | } |
| r14513 | r14514 | |
| 810 | 679 | // ++++ ++-- ---- ---+ |
| 811 | 680 | // 1001 0100 0000 0000 |
| 812 | 681 | // We need to add the address prefix bits |
| 813 | | ti99_peb_data_w(board->peribox, offset | ((board->genmod)? 0x170000 : 0x070000), data); |
| 814 | | do_wait(device, 1); |
| 682 | m_peribox->write(space, offset | ((m_genmod)? 0x170000 : 0x070000), data, mem_mask); |
| 683 | do_wait(1); |
| 815 | 684 | return; |
| 816 | 685 | } |
| 817 | 686 | if ((offset & 0xfc01)==0x9c00) |
| r14513 | r14514 | |
| 819 | 688 | // grom simulation |
| 820 | 689 | // ++++ ++-- ---- ---+ |
| 821 | 690 | // 1001 1100 0000 00c0 |
| 822 | | write_grom(device, offset, data); |
| 823 | | do_wait(device, 1); |
| 691 | write_grom(space, offset, data, mem_mask); |
| 692 | do_wait(1); |
| 824 | 693 | return; |
| 825 | 694 | } |
| 826 | 695 | } |
| 827 | 696 | |
| 828 | 697 | page = (offset & 0xe000) >> 13; |
| 829 | | if (board->direct_mode) |
| 698 | if (m_direct_mode) |
| 830 | 699 | { |
| 831 | 700 | physaddr = 0x1e0000; // points to boot eprom |
| 832 | 701 | } |
| 833 | 702 | else |
| 834 | 703 | { |
| 835 | | if (!board->geneve_mode && page==3) |
| 704 | if (!m_geneve_mode && page==3) |
| 836 | 705 | { |
| 837 | | if (!board->cartridge_size_8K) |
| 706 | if (m_cartridge_size==0x4000) |
| 838 | 707 | { |
| 839 | 708 | // Writing to 0x6000 selects page 1, |
| 840 | 709 | // writing to 0x6002 selects page 2 |
| 841 | | board->cartridge_secondpage = ((offset & 0x0002)!=0); |
| 842 | | do_wait(device, 1); |
| 710 | m_cartridge_secondpage = ((offset & 0x0002)!=0); |
| 711 | do_wait(1); |
| 843 | 712 | return; |
| 844 | 713 | } |
| 845 | 714 | else |
| 846 | 715 | { |
| 847 | 716 | // writing into cartridge rom space (no bankswitching) |
| 848 | | if ((((offset & 0x1000)==0x0000) && !board->cartridge6_writable) |
| 849 | | || (((offset & 0x1000)==0x1000) && !board->cartridge7_writable)) |
| 717 | if ((((offset & 0x1000)==0x0000) && !m_cartridge6_writable) |
| 718 | || (((offset & 0x1000)==0x1000) && !m_cartridge7_writable)) |
| 850 | 719 | { |
| 851 | 720 | if (VERBOSE>0) LOG("genboard: Writing to protected cartridge space %04x ignored\n", offset); |
| 852 | 721 | return; |
| r14513 | r14514 | |
| 857 | 726 | } |
| 858 | 727 | } |
| 859 | 728 | else |
| 860 | | physaddr = (board->map[page] << 13); |
| 729 | physaddr = (m_map[page] << 13); |
| 861 | 730 | } |
| 862 | 731 | |
| 863 | 732 | physaddr |= offset & 0x1fff; |
| 864 | 733 | |
| 865 | 734 | // printf("write physaddr = %06x logaddr = %04x value = %02x\n", physaddr, offset, data); |
| 866 | 735 | |
| 867 | | if (!board->genmod) |
| 736 | if (!m_genmod) |
| 868 | 737 | { |
| 869 | 738 | if ((physaddr & 0x180000)==0x000000) |
| 870 | 739 | { |
| 871 | 740 | // DRAM write. One wait state. (only for normal Geneve) |
| 872 | | board->dram[physaddr & 0x07ffff] = data; |
| 873 | | do_wait(device, 1); |
| 741 | m_dram[physaddr & 0x07ffff] = data; |
| 742 | do_wait(1); |
| 874 | 743 | return; |
| 875 | 744 | } |
| 876 | 745 | |
| 877 | 746 | if ((physaddr & 0x180000)==0x080000) |
| 878 | 747 | { |
| 879 | 748 | // On-board memory expansion for standard Geneve (never used) |
| 880 | | do_wait(device, 1); |
| 749 | do_wait(1); |
| 881 | 750 | return; |
| 882 | 751 | } |
| 883 | 752 | |
| r14513 | r14514 | |
| 886 | 755 | // 1 111. ..xx xxxx xxxx xxxx on-board eprom (16K) |
| 887 | 756 | // mirrored for f0, f2, f4, ...; f1, f3, f5, ... |
| 888 | 757 | // Ignore EPROM write |
| 889 | | do_wait(device, 1); |
| 758 | do_wait(1); |
| 890 | 759 | return; |
| 891 | 760 | } |
| 892 | 761 | |
| 893 | 762 | if ((physaddr & 0x180000)==0x180000) |
| 894 | 763 | { |
| 895 | | if ((physaddr & board->sram_mask)==board->sram_val) |
| 764 | if ((physaddr & m_sram_mask)==m_sram_val) |
| 896 | 765 | { |
| 897 | | board->sram[physaddr & ~board->sram_mask] = data; |
| 766 | m_sram[physaddr & ~m_sram_mask] = data; |
| 898 | 767 | } |
| 899 | | do_wait(device, 0); |
| 768 | do_wait(0); |
| 900 | 769 | // Return in any case |
| 901 | 770 | return; |
| 902 | 771 | } |
| r14513 | r14514 | |
| 905 | 774 | |
| 906 | 775 | // only AMA, AMB, AMC are used; AMD and AME are not used |
| 907 | 776 | physaddr = (physaddr & 0x0007ffff); // 19 bit address |
| 908 | | ti99_peb_data_w(board->peribox, physaddr, data); |
| 909 | | do_wait(device, 1); |
| 777 | m_peribox->write(space, physaddr, data, mem_mask); |
| 778 | do_wait(1); |
| 910 | 779 | } |
| 911 | 780 | else |
| 912 | 781 | { |
| 913 | 782 | // GenMod mode |
| 914 | | if ((board->timode) && ((physaddr & 0x180000)==0x000000)) |
| 783 | if ((m_timode) && ((physaddr & 0x180000)==0x000000)) |
| 915 | 784 | { |
| 916 | 785 | // DRAM. One wait state. |
| 917 | | board->dram[physaddr & 0x07ffff] = data; |
| 918 | | if (!board->turbo) do_wait(device, 1); |
| 786 | m_dram[physaddr & 0x07ffff] = data; |
| 787 | if (!m_turbo) do_wait(1); |
| 919 | 788 | return; |
| 920 | 789 | } |
| 921 | 790 | |
| r14513 | r14514 | |
| 924 | 793 | // 1 111. ..xx xxxx xxxx xxxx on-board eprom (16K) |
| 925 | 794 | // mirrored for f0, f2, f4, ...; f1, f3, f5, ... |
| 926 | 795 | // Ignore EPROM write |
| 927 | | if (!board->turbo) do_wait(device, 1); |
| 796 | if (!m_turbo) do_wait(1); |
| 928 | 797 | return; |
| 929 | 798 | } |
| 930 | 799 | // Route everything else to the P-Box |
| 931 | 800 | physaddr = (physaddr & 0x001fffff); // 21 bit address for Genmod |
| 932 | | ti99_peb_data_w(board->peribox, physaddr, data); |
| 933 | | if (!board->turbo) do_wait(device, 1); |
| 801 | m_peribox->write(space, physaddr, data, mem_mask); |
| 802 | if (!m_turbo) do_wait(1); |
| 934 | 803 | } |
| 935 | 804 | } |
| 936 | 805 | |
| 937 | | /**************************************************************************** |
| 938 | | CRU handling |
| 939 | | *****************************************************************************/ |
| 806 | void geneve_mapper_device::device_start() |
| 807 | { |
| 808 | if (VERBOSE>0) LOG("geneve: Starting Geneve mapper\n"); |
| 809 | // Get pointers |
| 810 | m_peribox = machine().device<bus8z_device>(PERIBOX_TAG); |
| 811 | m_keyboard = machine().device<geneve_keyboard_device>(GKEYBOARD_TAG); |
| 812 | m_video = machine().device<bus8z_device>(VIDEO_SYSTEM_TAG); |
| 813 | m_sound = machine().device<bus8z_device>(TISOUND_TAG); |
| 814 | m_clock = machine().device(GCLOCK_TAG); |
| 815 | m_cpu = machine().device("maincpu"); |
| 940 | 816 | |
| 941 | | #define CRU_CONTROL_BASE 0x1ee0 |
| 942 | | #define CRU_SSTEP_BASE 0x13c0 |
| 817 | // This is a preliminary setting; the initial context switch occurs before |
| 818 | // device_reset. Luckily, the reset vector at >0000/>0002 is the same for |
| 819 | // all variants of the boot eprom. |
| 820 | m_eprom = machine().region("maincpu")->base(); |
| 943 | 821 | |
| 944 | | WRITE8_DEVICE_HANDLER ( geneve_cru_w ) |
| 822 | m_sram = machine().region(SRAM_TAG)->base(); |
| 823 | m_dram = machine().region(DRAM_TAG)->base(); |
| 824 | |
| 825 | m_geneve_mode = false; |
| 826 | m_direct_mode = true; |
| 827 | |
| 828 | // Used for generating the VDP waitstates. These are created in the |
| 829 | // Gate Array on the board and only affect external memory accesses. |
| 830 | // Therefore we cannot use the usual adjust_icount |
| 831 | m_video_waittimer = timer_alloc(VIDEOWAIT); |
| 832 | } |
| 833 | |
| 834 | void geneve_mapper_device::device_reset() |
| 945 | 835 | { |
| 946 | | genboard_state *board = get_safe_token(device); |
| 836 | if (VERBOSE>0) LOG("geneve: Resetting mapper\n"); |
| 947 | 837 | |
| 948 | | int addroff = offset << 1; |
| 949 | | bool rising_edge = false; |
| 950 | | bool falling_edge = false; |
| 838 | m_extra_waitstates = false; |
| 839 | m_video_waitstates = true; |
| 840 | m_video_waiting = false; |
| 951 | 841 | |
| 952 | | // Single step |
| 953 | | // 13c0 - 13fe: 0001 0011 11xx xxx0 |
| 954 | | if ((addroff & 0xffc0) == CRU_SSTEP_BASE) |
| 955 | | { |
| 956 | | int bit = (addroff & 0x003e)>>1; |
| 957 | | if (VERBOSE>0) LOG("genboard: Single step not implemented; bit %d set to %d\n", bit, data); |
| 958 | | return; |
| 959 | | } |
| 842 | m_geneve_mode =false; |
| 843 | m_direct_mode = true; |
| 844 | m_cartridge_size = 0x4000; |
| 845 | m_cartridge_secondpage = false; |
| 846 | m_cartridge6_writable = false; |
| 847 | m_cartridge7_writable = false; |
| 960 | 848 | |
| 961 | | if ((addroff & 0xffe0) == CRU_CONTROL_BASE) |
| 849 | // Clear map |
| 850 | for (int i=0; i < 8; i++) m_map[i] = 0; |
| 851 | |
| 852 | m_genmod = false; |
| 853 | |
| 854 | if (input_port_read(machine(), "MODE")==0) |
| 962 | 855 | { |
| 963 | | int bit = (addroff & 0x001e)>>1; |
| 964 | | switch (bit) |
| 856 | switch (input_port_read(machine(), "BOOTROM")) |
| 965 | 857 | { |
| 966 | | case 5: |
| 967 | | board->palvideo = (data!=0); |
| 858 | case GENEVE_098: |
| 859 | if (VERBOSE>0) LOG("geneve: Using 0.98 boot eprom\n"); |
| 860 | m_eprom = machine().region("maincpu")->base() + 0x4000; |
| 968 | 861 | break; |
| 969 | | case 7: |
| 970 | | board->capslock = (data!=0); |
| 862 | case GENEVE_100: |
| 863 | if (VERBOSE>0) LOG("geneve: Using 1.00 boot eprom\n"); |
| 864 | m_eprom = machine().region("maincpu")->base(); |
| 971 | 865 | break; |
| 972 | | case 8: |
| 973 | | rising_edge = (!board->keyboard_clock && (data!=0)); |
| 974 | | board->keyboard_clock = (data!=0); |
| 975 | | if (rising_edge) |
| 976 | | signal_when_key_available(board); |
| 977 | | break; |
| 978 | | case 9: |
| 979 | | rising_edge = (!board->keep_keybuf && (data!=0)); |
| 980 | | falling_edge = (board->keep_keybuf && (data==0)); |
| 981 | | board->keep_keybuf = (data!=0); |
| 982 | | |
| 983 | | if (rising_edge) |
| 984 | | signal_when_key_available(board); |
| 985 | | else |
| 986 | | { |
| 987 | | if (falling_edge) |
| 988 | | { |
| 989 | | if (board->keyQueueLen != 0) |
| 990 | | { |
| 991 | | board->keyQueueHead = (board->keyQueueHead + 1) % KEYQUEUESIZE; |
| 992 | | board->keyQueueLen--; |
| 993 | | } |
| 994 | | /* clear keyboard interrupt */ |
| 995 | | tms9901_set_single_int(board->tms9901, 8, CLEAR_LINE); |
| 996 | | board->keyInBuf = false; |
| 997 | | } |
| 998 | | } |
| 999 | | break; |
| 1000 | | case 10: |
| 1001 | | board->geneve_mode = (data!=0); |
| 1002 | | break; |
| 1003 | | case 11: |
| 1004 | | board->direct_mode = (data!=0); |
| 1005 | | break; |
| 1006 | | case 12: |
| 1007 | | board->cartridge_size_8K = (data!=0); |
| 1008 | | break; |
| 1009 | | case 13: |
| 1010 | | board->cartridge6_writable = (data!=0); |
| 1011 | | break; |
| 1012 | | case 14: |
| 1013 | | board->cartridge7_writable = (data!=0); |
| 1014 | | break; |
| 1015 | | case 15: |
| 1016 | | board->extra_waitstates = (data==0); // let's use the inverse semantics |
| 1017 | | break; |
| 1018 | | default: |
| 1019 | | if (VERBOSE>0) LOG("genboard: set CRU address %04x=%02x ignored\n", addroff, data); |
| 1020 | | break; |
| 1021 | 866 | } |
| 1022 | 867 | } |
| 1023 | 868 | else |
| 1024 | 869 | { |
| 1025 | | ti99_peb_cru_w(board->peribox, addroff, data); |
| 870 | if (VERBOSE>0) LOG("geneve: Using GenMod modification\n"); |
| 871 | m_eprom = machine().region("maincpu")->base() + 0x8000; |
| 872 | if (m_eprom[0] != 0xf0) |
| 873 | { |
| 874 | fatalerror("genboard: GenMod boot rom missing.\n"); |
| 875 | } |
| 876 | m_genmod = true; |
| 877 | m_turbo = ((input_port_read(machine(), "GENMODDIPS") & GM_TURBO)!=0); |
| 878 | m_timode = ((input_port_read(machine(), "GENMODDIPS") & GM_TIM)!=0); |
| 1026 | 879 | } |
| 1027 | | } |
| 1028 | 880 | |
| 1029 | | |
| 1030 | | READ8_DEVICE_HANDLER ( geneve_cru_r ) |
| 1031 | | { |
| 1032 | | UINT8 value = 0; |
| 1033 | | genboard_state *board = get_safe_token(device); |
| 1034 | | int addroff = offset << 4; |
| 1035 | | |
| 1036 | | // Single step |
| 1037 | | // 13c0 - 13fe: 0001 0011 11xx xxx0 |
| 1038 | | if ((addroff & 0xffc0) == CRU_SSTEP_BASE) |
| 881 | switch (input_port_read(machine(), "SRAM")) |
| 1039 | 882 | { |
| 1040 | | int bit = (addroff & 0x003e)>>1; |
| 1041 | | if (VERBOSE>0) LOG("genboard: Single step not implemented; attempting to read bit %d\n", bit); |
| 1042 | | return value; |
| 883 | /* 1 100. .... .... .... .... on-board sram (128K) -+ |
| 884 | 1 101. .... .... .... .... on-board sram (128K) -+-- maximum SRAM expansion |
| 885 | 1 1100 .... .... .... .... on-board sram (64K) --+ |
| 886 | 1 1101 0... .... .... .... on-board sram (32K) - additional 32 KiB required for MDOS 2.50s and higher |
| 887 | 1 1101 1... .... .... .... on-board sram (32K) - standard setup |
| 888 | */ |
| 889 | case 0: // 32 KiB |
| 890 | m_sram_mask = 0x1f8000; |
| 891 | m_sram_val = 0x1d8000; |
| 892 | break; |
| 893 | case 1: // 64 KiB |
| 894 | m_sram_mask = 0x1f0000; |
| 895 | m_sram_val = 0x1d0000; |
| 896 | break; |
| 897 | case 2: // 384 KiB (actually 512 KiB, but the EPROM masks the upper 128 KiB) |
| 898 | m_sram_mask = 0x180000; |
| 899 | m_sram_val = 0x180000; |
| 900 | break; |
| 1043 | 901 | } |
| 1044 | | |
| 1045 | | // TMS9995-internal CRU locations (1ee0-1efe) are handled within the 99xxcore |
| 1046 | | // implementation (read_single_cru), so we don't arrive here |
| 1047 | | |
| 1048 | | // Propagate the CRU access to external devices |
| 1049 | | ti99_peb_cru_rz(board->peribox, addroff, &value); |
| 1050 | | return value; |
| 1051 | 902 | } |
| 1052 | 903 | |
| 904 | const device_type GENEVE_MAPPER = &device_creator<geneve_mapper_device>; |
| 905 | |
| 1053 | 906 | /**************************************************************************** |
| 1054 | 907 | Keyboard support |
| 1055 | | *****************************************************************************/ |
| 908 | ****************************************************************************/ |
| 1056 | 909 | |
| 1057 | | UINT8 get_recent_key(device_t *device) |
| 910 | static const char *const KEYNAMES[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7" }; |
| 911 | |
| 912 | static const UINT8 MF1_CODE[0xe] = |
| 1058 | 913 | { |
| 1059 | | genboard_state *board = get_safe_token(device); |
| 1060 | | if (board->keyInBuf) |
| 1061 | | return board->keyQueue[board->keyQueueHead]; |
| 1062 | | else |
| 1063 | | return 0; |
| 1064 | | } |
| 914 | /* extended keys that are equivalent to non-extended keys */ |
| 915 | 0x1c, /* keypad enter */ |
| 916 | 0x1d, /* right control */ |
| 917 | 0x38, /* alt gr */ |
| 918 | // extra codes are 0x5b for Left Windows, 0x5c for Right Windows, 0x5d |
| 919 | // for Menu, 0x5e for power, 0x5f for sleep, 0x63 for wake, but I doubt |
| 920 | // any Geneve program would take advantage of these. */ |
| 1065 | 921 | |
| 1066 | | static void signal_when_key_available(genboard_state *board) |
| 922 | // extended key that is equivalent to a non-extended key |
| 923 | // with shift off |
| 924 | 0x35, /* pad slash */ |
| 925 | |
| 926 | // extended keys that are equivalent to non-extended keys |
| 927 | // with numlock off |
| 928 | 0x47, /* home */ |
| 929 | 0x48, /* up */ |
| 930 | 0x49, /* page up */ |
| 931 | 0x4b, /* left */ |
| 932 | 0x4d, /* right */ |
| 933 | 0x4f, /* end */ |
| 934 | 0x50, /* down */ |
| 935 | 0x51, /* page down */ |
| 936 | 0x52, /* insert */ |
| 937 | 0x53 /* delete */ |
| 938 | }; |
| 939 | |
| 940 | geneve_keyboard_device::geneve_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 941 | : device_t(mconfig, GENEVE_KEYBOARD, "Geneve XT-style keyboard", tag, owner, clock) |
| 1067 | 942 | { |
| 1068 | | // if keyboard reset is not asserted, and key clock is enabled, and key |
| 1069 | | // buffer clear is disabled, and key queue is not empty. */ |
| 1070 | | if ((!board->keyReset) && (board->keyboard_clock) && (board->keep_keybuf) && (board->keyQueueLen != 0)) |
| 1071 | | { |
| 1072 | | tms9901_set_single_int(board->tms9901, 8, ASSERT_LINE); |
| 1073 | | board->keyInBuf = true; |
| 1074 | | } |
| 1075 | 943 | } |
| 1076 | 944 | |
| 1077 | | INLINE void post_in_keyQueue(genboard_state *board, int keycode) |
| 945 | void geneve_keyboard_device::post_in_key_queue(int keycode) |
| 1078 | 946 | { |
| 1079 | | board->keyQueue[(board->keyQueueHead + board->keyQueueLen) % KEYQUEUESIZE] = keycode; |
| 1080 | | board->keyQueueLen++; |
| 947 | m_key_queue[(m_key_queue_head + m_key_queue_length) % KEYQUEUESIZE] = keycode; |
| 948 | m_key_queue_length++; |
| 949 | |
| 950 | if (VERBOSE>5) LOG("geneve: posting keycode %02x\n", keycode); |
| 1081 | 951 | } |
| 1082 | 952 | |
| 1083 | | static void poll_keyboard(device_t *device) |
| 953 | void geneve_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 1084 | 954 | { |
| 1085 | | genboard_state *board = get_safe_token(device); |
| 955 | poll(); |
| 956 | } |
| 1086 | 957 | |
| 958 | void geneve_keyboard_device::poll() |
| 959 | { |
| 1087 | 960 | UINT32 keystate; |
| 1088 | 961 | UINT32 key_transitions; |
| 1089 | 962 | int i, j; |
| 1090 | 963 | int keycode; |
| 1091 | 964 | int pressed; |
| 965 | if (VERBOSE>8) LOG("geneve: poll keyboard\n"); |
| 966 | if (m_key_reset) return; |
| 1092 | 967 | |
| 1093 | | if (board->keyReset) |
| 1094 | | return; |
| 1095 | | |
| 1096 | 968 | /* Poll keyboard */ |
| 1097 | | for (i = 0; (i < 4) && (board->keyQueueLen <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)); i++) |
| 969 | for (i = 0; (i < 4) && (m_key_queue_length <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)); i++) |
| 1098 | 970 | { |
| 1099 | | keystate = input_port_read(device->machine(), keynames[2*i]) | (input_port_read(device->machine(), keynames[2*i + 1]) << 16); |
| 1100 | | key_transitions = keystate ^ board->keyStateSave[i]; |
| 971 | keystate = input_port_read(*this, KEYNAMES[2*i]) | (input_port_read(*this, KEYNAMES[2*i + 1]) << 16); |
| 972 | key_transitions = keystate ^ m_key_state_save[i]; |
| 1101 | 973 | if (key_transitions) |
| 1102 | 974 | { |
| 1103 | | for (j = 0; (j < 32) && (board->keyQueueLen <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)); j++) |
| 975 | for (j = 0; (j < 32) && (m_key_queue_length <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)); j++) |
| 1104 | 976 | { |
| 1105 | 977 | if ((key_transitions >> j) & 1) |
| 1106 | 978 | { |
| 1107 | 979 | keycode = (i << 5) | j; |
| 1108 | 980 | pressed = ((keystate >> j) & 1); |
| 1109 | 981 | if (pressed) |
| 1110 | | board->keyStateSave[i] |= (1 << j); |
| 982 | m_key_state_save[i] |= (1 << j); |
| 1111 | 983 | else |
| 1112 | | board->keyStateSave[i] &= ~ (1 << j); |
| 984 | m_key_state_save[i] &= ~ (1 << j); |
| 1113 | 985 | |
| 1114 | 986 | /* Update auto-repeat */ |
| 1115 | 987 | if (pressed) |
| 1116 | 988 | { |
| 1117 | | board->keyAutoRepeatKey = keycode; |
| 1118 | | board->keyAutoRepeatTimer = KEYAUTOREPEATDELAY+1; |
| 989 | m_key_autorepeat_key = keycode; |
| 990 | m_key_autorepeat_timer = KEYAUTOREPEATDELAY+1; |
| 1119 | 991 | } |
| 1120 | | else /*if (keycode == board->keyAutoRepeatKey)*/ |
| 1121 | | board->keyAutoRepeatKey = 0; |
| 992 | else /*if (keycode == m_key_autorepeat_key)*/ |
| 993 | m_key_autorepeat_key = 0; |
| 1122 | 994 | |
| 1123 | 995 | // Release Fake Shift/Unshift if another key is pressed |
| 1124 | 996 | // We do so if a key is released, though it is actually |
| 1125 | 997 | // required only if it is a modifier key |
| 1126 | 998 | /*if (pressed)*/ |
| 1127 | 999 | //{ |
| 1128 | | if (board->keyFakeShiftState) |
| 1000 | if (m_key_fake_shift_state) |
| 1129 | 1001 | { |
| 1130 | 1002 | /* Fake shift release */ |
| 1131 | | post_in_keyQueue(board, 0xe0); |
| 1132 | | post_in_keyQueue(board, 0xaa); |
| 1133 | | board->keyFakeShiftState = 0; |
| 1003 | post_in_key_queue(0xe0); |
| 1004 | post_in_key_queue(0xaa); |
| 1005 | m_key_fake_shift_state = false; |
| 1134 | 1006 | } |
| 1135 | | if (board->keyFakeUnshiftState) |
| 1007 | if (m_key_fake_unshift_state) |
| 1136 | 1008 | { |
| 1137 | 1009 | /* Fake shift press */ |
| 1138 | | post_in_keyQueue(board, 0xe0); |
| 1139 | | post_in_keyQueue(board, 0x2a); |
| 1140 | | board->keyFakeUnshiftState = 0; |
| 1010 | post_in_key_queue(0xe0); |
| 1011 | post_in_key_queue(0x2a); |
| 1012 | m_key_fake_unshift_state = false; |
| 1141 | 1013 | } |
| 1142 | 1014 | //} |
| 1143 | 1015 | |
| 1144 | 1016 | /* update shift and numlock state */ |
| 1145 | 1017 | if ((keycode == 0x2a) || (keycode == 0x36)) |
| 1146 | | board->keyRealShiftState = board->keyRealShiftState + (pressed ? +1 : -1); |
| 1018 | m_key_real_shift_state = m_key_real_shift_state + (pressed ? +1 : -1); |
| 1147 | 1019 | if ((keycode == 0x1d) || (keycode == 0x61)) |
| 1148 | | board->keyCtrlState = board->keyCtrlState + (pressed ? +1 : -1); |
| 1020 | m_key_ctrl_state = m_key_ctrl_state + (pressed ? +1 : -1); |
| 1149 | 1021 | if ((keycode == 0x38) || (keycode == 0x62)) |
| 1150 | | board->keyAltState = board->keyAltState + (pressed ? +1 : -1); |
| 1022 | m_key_alt_state = m_key_alt_state + (pressed ? +1 : -1); |
| 1151 | 1023 | if ((keycode == 0x45) && pressed) |
| 1152 | | board->keyNumLockState = ! board->keyNumLockState; |
| 1024 | m_key_numlock_state = !m_key_numlock_state; |
| 1153 | 1025 | |
| 1154 | 1026 | if ((keycode >= 0x60) && (keycode < 0x6e)) |
| 1155 | 1027 | { /* simpler extended keys */ |
| r14513 | r14514 | |
| 1160 | 1032 | /* Handle shift state */ |
| 1161 | 1033 | if (keycode == 0x63) |
| 1162 | 1034 | { /* non-shifted key */ |
| 1163 | | if (board->keyRealShiftState) |
| 1035 | if (m_key_real_shift_state!=0) |
| 1164 | 1036 | /* Fake shift unpress */ |
| 1165 | | board->keyFakeUnshiftState = 1; |
| 1037 | m_key_fake_unshift_state = true; |
| 1166 | 1038 | } |
| 1167 | 1039 | else /*if (keycode >= 0x64)*/ |
| 1168 | 1040 | { /* non-numlock mode key */ |
| 1169 | | if (board->keyNumLockState & ! board->keyRealShiftState) |
| 1041 | if (m_key_numlock_state & (m_key_real_shift_state==0)) |
| 1170 | 1042 | /* Fake shift press if numlock is active */ |
| 1171 | | board->keyFakeShiftState = 1; |
| 1172 | | else if ((! board->keyNumLockState) & board->keyRealShiftState) |
| 1043 | m_key_fake_shift_state = true; |
| 1044 | else if ((!m_key_numlock_state) & (m_key_real_shift_state!=0)) |
| 1173 | 1045 | /* Fake shift unpress if shift is down */ |
| 1174 | | board->keyFakeUnshiftState = 1; |
| 1046 | m_key_fake_unshift_state = true; |
| 1175 | 1047 | } |
| 1176 | 1048 | |
| 1177 | | if (board->keyFakeShiftState) |
| 1049 | if (m_key_fake_shift_state) |
| 1178 | 1050 | { |
| 1179 | | post_in_keyQueue(board, 0xe0); |
| 1180 | | post_in_keyQueue(board, 0x2a); |
| 1051 | post_in_key_queue(0xe0); |
| 1052 | post_in_key_queue(0x2a); |
| 1181 | 1053 | } |
| 1182 | 1054 | |
| 1183 | | if (board->keyFakeUnshiftState) |
| 1055 | if (m_key_fake_unshift_state) |
| 1184 | 1056 | { |
| 1185 | | post_in_keyQueue(board, 0xe0); |
| 1186 | | post_in_keyQueue(board, 0xaa); |
| 1057 | post_in_key_queue(0xe0); |
| 1058 | post_in_key_queue(0xaa); |
| 1187 | 1059 | } |
| 1188 | 1060 | } |
| 1189 | 1061 | |
| 1190 | | keycode = keyboard_mf1_code[keycode-0x60]; |
| 1191 | | if (! pressed) |
| 1192 | | keycode |= 0x80; |
| 1193 | | post_in_keyQueue(board, 0xe0); |
| 1194 | | post_in_keyQueue(board, keycode); |
| 1062 | keycode = MF1_CODE[keycode-0x60]; |
| 1063 | if (!pressed) keycode |= 0x80; |
| 1064 | post_in_key_queue(0xe0); |
| 1065 | post_in_key_queue(keycode); |
| 1195 | 1066 | } |
| 1196 | 1067 | else if (keycode == 0x6e) |
| 1197 | 1068 | { /* emulate Print Screen / System Request (F13) key */ |
| 1198 | 1069 | /* this is a bit complex, as Alt+PrtScr -> SysRq */ |
| 1199 | 1070 | /* Additionally, Ctrl+PrtScr involves no fake shift press */ |
| 1200 | | if (board->keyAltState) |
| 1071 | if (m_key_alt_state!=0) |
| 1201 | 1072 | { |
| 1202 | 1073 | /* SysRq */ |
| 1203 | 1074 | keycode = 0x54; |
| 1204 | | if (! pressed) |
| 1205 | | keycode |= 0x80; |
| 1206 | | post_in_keyQueue(board, keycode); |
| 1075 | if (!pressed) keycode |= 0x80; |
| 1076 | post_in_key_queue(keycode); |
| 1207 | 1077 | } |
| 1208 | 1078 | else |
| 1209 | 1079 | { |
| 1210 | 1080 | /* Handle shift state */ |
| 1211 | | if (pressed && (! board->keyRealShiftState) && (! board->keyCtrlState)) |
| 1081 | if (pressed && (m_key_real_shift_state==0) && (m_key_ctrl_state==0)) |
| 1212 | 1082 | { /* Fake shift press */ |
| 1213 | | post_in_keyQueue(board, 0xe0); |
| 1214 | | post_in_keyQueue(board, 0x2a); |
| 1215 | | board->keyFakeShiftState = 1; |
| 1083 | post_in_key_queue(0xe0); |
| 1084 | post_in_key_queue(0x2a); |
| 1085 | m_key_fake_shift_state = true; |
| 1216 | 1086 | } |
| 1217 | 1087 | |
| 1218 | 1088 | keycode = 0x37; |
| 1219 | | if (! pressed) |
| 1220 | | keycode |= 0x80; |
| 1221 | | post_in_keyQueue(board, 0xe0); |
| 1222 | | post_in_keyQueue(board, keycode); |
| 1089 | if (!pressed) keycode |= 0x80; |
| 1090 | post_in_key_queue(0xe0); |
| 1091 | post_in_key_queue(keycode); |
| 1223 | 1092 | } |
| 1224 | 1093 | } |
| 1225 | 1094 | else if (keycode == 0x6f) |
| r14513 | r14514 | |
| 1229 | 1098 | // repeat or release. |
| 1230 | 1099 | if (pressed) |
| 1231 | 1100 | { |
| 1232 | | if (board->keyCtrlState) |
| 1101 | if (m_key_ctrl_state!=0) |
| 1233 | 1102 | { |
| 1234 | | post_in_keyQueue(board, 0xe0); |
| 1235 | | post_in_keyQueue(board, 0x46); |
| 1236 | | post_in_keyQueue(board, 0xe0); |
| 1237 | | post_in_keyQueue(board, 0xc6); |
| 1103 | post_in_key_queue(0xe0); |
| 1104 | post_in_key_queue(0x46); |
| 1105 | post_in_key_queue(0xe0); |
| 1106 | post_in_key_queue(0xc6); |
| 1238 | 1107 | } |
| 1239 | 1108 | else |
| 1240 | 1109 | { |
| 1241 | | post_in_keyQueue(board, 0xe1); |
| 1242 | | post_in_keyQueue(board, 0x1d); |
| 1243 | | post_in_keyQueue(board, 0x45); |
| 1244 | | post_in_keyQueue(board, 0xe1); |
| 1245 | | post_in_keyQueue(board, 0x9d); |
| 1246 | | post_in_keyQueue(board, 0xc5); |
| 1110 | post_in_key_queue(0xe1); |
| 1111 | post_in_key_queue(0x1d); |
| 1112 | post_in_key_queue(0x45); |
| 1113 | post_in_key_queue(0xe1); |
| 1114 | post_in_key_queue(0x9d); |
| 1115 | post_in_key_queue(0xc5); |
| 1247 | 1116 | } |
| 1248 | 1117 | } |
| 1249 | 1118 | } |
| 1250 | 1119 | else |
| 1251 | 1120 | { |
| 1252 | | if (! pressed) |
| 1253 | | keycode |= 0x80; |
| 1254 | | post_in_keyQueue(board, keycode); |
| 1121 | if (!pressed) keycode |= 0x80; |
| 1122 | post_in_key_queue(keycode); |
| 1255 | 1123 | } |
| 1256 | | signal_when_key_available(board); |
| 1124 | signal_when_key_available(); |
| 1257 | 1125 | } |
| 1258 | 1126 | } |
| 1259 | 1127 | } |
| 1260 | 1128 | } |
| 1261 | 1129 | |
| 1262 | 1130 | /* Handle auto-repeat */ |
| 1263 | | if ((board->keyQueueLen <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)) && board->keyAutoRepeatKey && (--board->keyAutoRepeatTimer == 0)) |
| 1131 | if ((m_key_queue_length <= (KEYQUEUESIZE-MAXKEYMSGLENGTH)) && (m_key_autorepeat_key!=0) && (--m_key_autorepeat_timer == 0)) |
| 1264 | 1132 | { |
| 1265 | | if ((board->keyAutoRepeatKey >= 0x60) && (board->keyAutoRepeatKey < 0x6e)) |
| 1133 | if ((m_key_autorepeat_key >= 0x60) && (m_key_autorepeat_key < 0x6e)) |
| 1266 | 1134 | { |
| 1267 | | post_in_keyQueue(board, 0xe0); |
| 1268 | | post_in_keyQueue(board, keyboard_mf1_code[board->keyAutoRepeatKey-0x60]); |
| 1135 | post_in_key_queue(0xe0); |
| 1136 | post_in_key_queue(MF1_CODE[m_key_autorepeat_key-0x60]); |
| 1269 | 1137 | } |
| 1270 | | else if (board->keyAutoRepeatKey == 0x6e) |
| 1138 | else if (m_key_autorepeat_key == 0x6e) |
| 1271 | 1139 | { |
| 1272 | | if (board->keyAltState) |
| 1273 | | post_in_keyQueue(board, 0x54); |
| 1140 | if (m_key_alt_state!=0) |
| 1141 | post_in_key_queue(0x54); |
| 1274 | 1142 | else |
| 1275 | 1143 | { |
| 1276 | | post_in_keyQueue(board, 0xe0); |
| 1277 | | post_in_keyQueue(board, 0x37); |
| 1144 | post_in_key_queue(0xe0); |
| 1145 | post_in_key_queue(0x37); |
| 1278 | 1146 | } |
| 1279 | 1147 | } |
| 1280 | | else if (board->keyAutoRepeatKey == 0x6f) |
| 1148 | else if (m_key_autorepeat_key == 0x6f) |
| 1281 | 1149 | ; |
| 1282 | 1150 | else |
| 1283 | 1151 | { |
| 1284 | | post_in_keyQueue(board, board->keyAutoRepeatKey); |
| 1152 | post_in_key_queue(m_key_autorepeat_key); |
| 1285 | 1153 | } |
| 1286 | | signal_when_key_available(board); |
| 1287 | | board->keyAutoRepeatTimer = KEYAUTOREPEATRATE; |
| 1154 | signal_when_key_available(); |
| 1155 | m_key_autorepeat_timer = KEYAUTOREPEATRATE; |
| 1288 | 1156 | } |
| 1289 | 1157 | } |
| 1290 | 1158 | |
| 1291 | | /**************************************************************************** |
| 1292 | | Mouse support |
| 1293 | | ****************************************************************************/ |
| 1294 | | |
| 1295 | | static void poll_mouse(device_t *device) |
| 1159 | UINT8 geneve_keyboard_device::get_recent_key() |
| 1296 | 1160 | { |
| 1297 | | genboard_state *board = get_safe_token(device); |
| 1298 | | |
| 1299 | | int new_mx, new_my; |
| 1300 | | int delta_x, delta_y, buttons; |
| 1301 | | |
| 1302 | | buttons = input_port_read(device->machine(), "MOUSE0"); |
| 1303 | | new_mx = input_port_read(device->machine(), "MOUSEX"); |
| 1304 | | new_my = input_port_read(device->machine(), "MOUSEY"); |
| 1305 | | |
| 1306 | | /* compute x delta */ |
| 1307 | | delta_x = new_mx - board->last_mx; |
| 1308 | | |
| 1309 | | /* check for wrap */ |
| 1310 | | if (delta_x > 0x80) |
| 1311 | | delta_x = 0x100-delta_x; |
| 1312 | | if (delta_x < -0x80) |
| 1313 | | delta_x = -0x100-delta_x; |
| 1314 | | |
| 1315 | | board->last_mx = new_mx; |
| 1316 | | |
| 1317 | | /* compute y delta */ |
| 1318 | | delta_y = new_my - board->last_my; |
| 1319 | | |
| 1320 | | /* check for wrap */ |
| 1321 | | if (delta_y > 0x80) |
| 1322 | | delta_y = 0x100-delta_y; |
| 1323 | | if (delta_y < -0x80) |
| 1324 | | delta_y = -0x100-delta_y; |
| 1325 | | |
| 1326 | | board->last_my = new_my; |
| 1327 | | |
| 1328 | | video_update_mouse(board->video, delta_x, delta_y, buttons & 3); |
| 1161 | if (m_key_in_buffer) return m_key_queue[m_key_queue_head]; |
| 1162 | else return 0; |
| 1329 | 1163 | } |
| 1330 | 1164 | |
| 1331 | | /**************************************************************************** |
| 1332 | | TMS9901 and attached devices handling |
| 1333 | | ****************************************************************************/ |
| 1334 | | |
| 1335 | | /* |
| 1336 | | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes |
| 1337 | | */ |
| 1338 | | static TMS9901_INT_CALLBACK( tms9901_interrupt_callback ) |
| 1165 | void geneve_keyboard_device::signal_when_key_available() |
| 1339 | 1166 | { |
| 1340 | | /* INTREQ is connected to INT1 (IC0-3 are not connected) */ |
| 1341 | | cputag_set_input_line(device->machine(), "maincpu", 0, intreq? ASSERT_LINE : CLEAR_LINE); |
| 1167 | // if keyboard reset is not asserted, and key clock is enabled, and key |
| 1168 | // buffer clear is disabled, and key queue is not empty. */ |
| 1169 | if ((!m_key_reset) && (m_keyboard_clock) && (m_keep_keybuf) && (m_key_queue_length != 0)) |
| 1170 | { |
| 1171 | if (VERBOSE>6) LOG("geneve: signalling key available\n"); |
| 1172 | m_interrupt(ASSERT_LINE); |
| 1173 | m_key_in_buffer = true; |
| 1174 | } |
| 1342 | 1175 | } |
| 1343 | 1176 | |
| 1344 | | /* |
| 1345 | | Read pins INT3*-INT7* of Geneve 9901. |
| 1346 | | |
| 1347 | | signification: |
| 1348 | | (bit 1: INT1 status) |
| 1349 | | (bit 2: INT2 status) |
| 1350 | | bit 3-7: joystick status |
| 1351 | | */ |
| 1352 | | static READ8_DEVICE_HANDLER( R9901_0 ) |
| 1177 | WRITE_LINE_MEMBER( geneve_keyboard_device::clock_control ) |
| 1353 | 1178 | { |
| 1354 | | device_t *dev = device->machine().device("geneve_board"); |
| 1355 | | genboard_state *board = get_safe_token(dev); |
| 1356 | | int answer; |
| 1357 | | answer = input_port_read(device->machine(), "JOY") >> (board->joySel * 8); |
| 1358 | | return answer; |
| 1179 | bool rising_edge = (!m_keyboard_clock && (state==ASSERT_LINE)); |
| 1180 | m_keyboard_clock = (state==ASSERT_LINE); |
| 1181 | if (VERBOSE>5) LOG("geneve: keyboard clock_control state=%d\n", m_keyboard_clock); |
| 1182 | if (rising_edge) |
| 1183 | signal_when_key_available(); |
| 1359 | 1184 | } |
| 1360 | 1185 | |
| 1361 | | /* |
| 1362 | | Read pins INT8*-INT15* of Geneve 9901. |
| 1363 | | |
| 1364 | | signification: |
| 1365 | | (bit 0: keyboard interrupt) |
| 1366 | | bit 1: unused |
| 1367 | | bit 2: mouse right button |
| 1368 | | (bit 3: clock interrupt) |
| 1369 | | (bit 4: INTB from PE-bus) |
| 1370 | | bit 5 & 7: used as output |
| 1371 | | bit 6: unused |
| 1372 | | */ |
| 1373 | | static READ8_DEVICE_HANDLER( R9901_1 ) |
| 1186 | WRITE_LINE_MEMBER( geneve_keyboard_device::send_scancodes ) |
| 1374 | 1187 | { |
| 1375 | | int answer; |
| 1376 | | answer = (input_port_read(device->machine(), "MOUSE0") & 4) ^ 4; |
| 1377 | | return answer; |
| 1378 | | } |
| 1188 | bool rising_edge = (!m_keep_keybuf && (state==ASSERT_LINE)); |
| 1189 | bool falling_edge = (m_keep_keybuf && (state==CLEAR_LINE)); |
| 1190 | m_keep_keybuf = (state==ASSERT_LINE); |
| 1379 | 1191 | |
| 1380 | | /* |
| 1381 | | Read pins P0-P7 of Geneve 9901. |
| 1382 | | */ |
| 1383 | | static READ8_DEVICE_HANDLER( R9901_2 ) |
| 1384 | | { |
| 1385 | | return 0; |
| 1192 | if (rising_edge) signal_when_key_available(); |
| 1193 | else |
| 1194 | { |
| 1195 | if (falling_edge) |
| 1196 | { |
| 1197 | if (m_key_queue_length != 0) |
| 1198 | { |
| 1199 | m_key_queue_head = (m_key_queue_head + 1) % KEYQUEUESIZE; |
| 1200 | m_key_queue_length--; |
| 1201 | } |
| 1202 | /* clear keyboard interrupt */ |
| 1203 | m_interrupt(CLEAR_LINE); |
| 1204 | m_key_in_buffer = false; |
| 1205 | } |
| 1206 | } |
| 1386 | 1207 | } |
| 1387 | 1208 | |
| 1388 | | /* |
| 1389 | | Read pins P8-P15 of Geneve 9901. |
| 1390 | | bit 4: mouse right button |
| 1391 | | */ |
| 1392 | | static READ8_DEVICE_HANDLER( R9901_3 ) |
| 1209 | WRITE_LINE_MEMBER( geneve_keyboard_device::reset_line ) |
| 1393 | 1210 | { |
| 1394 | | int answer = 0; |
| 1211 | m_key_reset = !(state==ASSERT_LINE); |
| 1395 | 1212 | |
| 1396 | | if (! (input_port_read(device->machine(), "MOUSE0") & 4)) |
| 1397 | | answer |= 0x10; |
| 1398 | | |
| 1399 | | return answer; |
| 1213 | if (m_key_reset) |
| 1214 | { |
| 1215 | /* reset -> clear keyboard key queue, but not geneve key buffer */ |
| 1216 | m_key_queue_length = (m_key_in_buffer)? 1 : 0; |
| 1217 | m_key_queue_head = 0; |
| 1218 | memset(m_key_state_save, 0, sizeof(m_key_state_save)); |
| 1219 | m_key_numlock_state = false; |
| 1220 | m_key_ctrl_state = 0; |
| 1221 | m_key_alt_state = 0; |
| 1222 | m_key_real_shift_state = 0; |
| 1223 | m_key_fake_shift_state = false; |
| 1224 | m_key_fake_unshift_state = false; |
| 1225 | m_key_autorepeat_key = 0; |
| 1226 | } |
| 1400 | 1227 | } |
| 1401 | 1228 | |
| 1402 | | /* |
| 1403 | | Write PE bus reset line |
| 1404 | | */ |
| 1405 | | static WRITE8_DEVICE_HANDLER( W9901_PE_bus_reset ) |
| 1229 | void geneve_keyboard_device::device_config_complete() |
| 1406 | 1230 | { |
| 1407 | | if (VERBOSE>0) LOG("genboard: PE bus reset request, ignoring.\n"); |
| 1231 | // Resolve the callback lines to the console |
| 1232 | const geneve_keyboard_config *intf = reinterpret_cast<const geneve_keyboard_config *>(static_config()); |
| 1233 | m_interrupt.resolve(intf->interrupt, *this); |
| 1408 | 1234 | } |
| 1409 | 1235 | |
| 1410 | | /* |
| 1411 | | Write VDP reset line |
| 1412 | | */ |
| 1413 | | static WRITE8_DEVICE_HANDLER( W9901_VDP_reset ) |
| 1236 | void geneve_keyboard_device::device_start() |
| 1414 | 1237 | { |
| 1415 | | if (VERBOSE>0) LOG("genboard: Video reset request, ignoring.\n"); |
| 1238 | if (VERBOSE>2) LOG("geneve: Keyboard started\n"); |
| 1239 | m_timer = timer_alloc(0); |
| 1416 | 1240 | } |
| 1417 | 1241 | |
| 1418 | | /* |
| 1419 | | Write joystick select line |
| 1420 | | */ |
| 1421 | | static WRITE8_DEVICE_HANDLER( W9901_joySel ) |
| 1242 | void geneve_keyboard_device::device_reset() |
| 1422 | 1243 | { |
| 1423 | | device_t *dev = device->machine().device("geneve_board"); |
| 1424 | | genboard_state *board = get_safe_token(dev); |
| 1425 | | board->joySel = data; |
| 1244 | reset_line(CLEAR_LINE); |
| 1245 | m_key_queue_length = 0; |
| 1246 | m_key_reset = true; |
| 1247 | m_keyboard_clock = false; |
| 1248 | m_key_in_buffer = false; |
| 1249 | m_keep_keybuf = false; |
| 1250 | m_timer->adjust(attotime::from_usec(1), 0, attotime::from_hz(120)); |
| 1426 | 1251 | } |
| 1427 | 1252 | |
| 1428 | | static WRITE8_DEVICE_HANDLER( W9901_keyboardReset ) |
| 1429 | | { |
| 1430 | | device_t *dev = device->machine().device("geneve_board"); |
| 1431 | | genboard_state *board = get_safe_token(dev); |
| 1253 | INPUT_PORTS_START( genkeys ) |
| 1254 | PORT_START("KEY0") /* IN3 */ |
| 1255 | PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */ |
| 1256 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) /* Esc 01 81 */ |
| 1257 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) /* 1 02 82 */ |
| 1258 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2 @") PORT_CODE(KEYCODE_2) /* 2 03 83 */ |
| 1259 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) /* 3 04 84 */ |
| 1260 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) /* 4 05 85 */ |
| 1261 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) /* 5 06 86 */ |
| 1262 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6 ^") PORT_CODE(KEYCODE_6) /* 6 07 87 */ |
| 1263 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7 &") PORT_CODE(KEYCODE_7) /* 7 08 88 */ |
| 1264 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8 *") PORT_CODE(KEYCODE_8) /* 8 09 89 */ |
| 1265 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9 (") PORT_CODE(KEYCODE_9) /* 9 0A 8A */ |
| 1266 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0 )") PORT_CODE(KEYCODE_0) /* 0 0B 8B */ |
| 1267 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- _") PORT_CODE(KEYCODE_MINUS) /* - 0C 8C */ |
| 1268 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("= +") PORT_CODE(KEYCODE_EQUALS) /* = 0D 8D */ |
| 1269 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) /* Backspace 0E 8E */ |
| 1270 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) /* Tab 0F 8F */ |
| 1432 | 1271 | |
| 1433 | | board->keyReset = !data; |
| 1272 | PORT_START("KEY1") /* IN4 */ |
| 1273 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) /* Q 10 90 */ |
| 1274 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) /* W 11 91 */ |
| 1275 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) /* E 12 92 */ |
| 1276 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) /* R 13 93 */ |
| 1277 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) /* T 14 94 */ |
| 1278 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) /* Y 15 95 */ |
| 1279 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) /* U 16 96 */ |
| 1280 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) /* I 17 97 */ |
| 1281 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) /* O 18 98 */ |
| 1282 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) /* P 19 99 */ |
| 1283 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) /* [ 1A 9A */ |
| 1284 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) /* ] 1B 9B */ |
| 1285 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER) /* Enter 1C 9C */ |
| 1286 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Ctrl") PORT_CODE(KEYCODE_LCONTROL) /* Left Ctrl 1D 9D */ |
| 1287 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) /* A 1E 9E */ |
| 1288 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) /* S 1F 9F */ |
| 1434 | 1289 | |
| 1435 | | if (board->keyReset) |
| 1436 | | { |
| 1437 | | /* reset -> clear keyboard key queue, but not geneve key buffer */ |
| 1438 | | board->keyQueueLen = (board->keyInBuf)? 1 : 0; |
| 1439 | | memset(board->keyStateSave, 0, sizeof(board->keyStateSave)); |
| 1440 | | board->keyNumLockState = 0; |
| 1441 | | board->keyCtrlState = 0; |
| 1442 | | board->keyAltState = 0; |
| 1443 | | board->keyRealShiftState = 0; |
| 1444 | | board->keyFakeShiftState = 0; |
| 1445 | | board->keyFakeUnshiftState = 0; |
| 1446 | | board->keyAutoRepeatKey = 0; |
| 1447 | | } |
| 1448 | | /*else |
| 1449 | | poll_keyboard(space->machine());*/ |
| 1450 | | } |
| 1290 | PORT_START("KEY2") /* IN5 */ |
| 1291 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) /* D 20 A0 */ |
| 1292 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) /* F 21 A1 */ |
| 1293 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) /* G 22 A2 */ |
| 1294 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) /* H 23 A3 */ |
| 1295 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) /* J 24 A4 */ |
| 1296 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) /* K 25 A5 */ |
| 1297 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) /* L 26 A6 */ |
| 1298 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("; :") PORT_CODE(KEYCODE_COLON) /* ; 27 A7 */ |
| 1299 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("' \"") PORT_CODE(KEYCODE_QUOTE) /* ' 28 A8 */ |
| 1300 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("` ~") PORT_CODE(KEYCODE_TILDE) /* ` 29 A9 */ |
| 1301 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Shift") PORT_CODE(KEYCODE_LSHIFT) /* Left Shift 2A AA */ |
| 1302 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) /* \ 2B AB */ |
| 1303 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) /* Z 2C AC */ |
| 1304 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) /* X 2D AD */ |
| 1305 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) /* C 2E AE */ |
| 1306 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) /* V 2F AF */ |
| 1451 | 1307 | |
| 1452 | | /* |
| 1453 | | Write external mem cycles (0=long, 1=short) |
| 1454 | | */ |
| 1455 | | static WRITE8_DEVICE_HANDLER( W9901_ext_mem_wait_states ) |
| 1456 | | { |
| 1457 | | if (VERBOSE>0) LOG("genboard: external bus wait states set to %d, not implemented yet.\n", data); |
| 1458 | | } |
| 1308 | PORT_START("KEY3") /* IN6 */ |
| 1309 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) /* B 30 B0 */ |
| 1310 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) /* N 31 B1 */ |
| 1311 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) /* M 32 B2 */ |
| 1312 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) /* , 33 B3 */ |
| 1313 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) /* . 34 B4 */ |
| 1314 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) /* / 35 B5 */ |
| 1315 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R-Shift") PORT_CODE(KEYCODE_RSHIFT) /* Right Shift 36 B6 */ |
| 1316 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP * (PrtScr)") PORT_CODE(KEYCODE_ASTERISK ) /* Keypad * (PrtSc) 37 B7 */ |
| 1317 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Alt") PORT_CODE(KEYCODE_LALT) /* Left Alt 38 B8 */ |
| 1318 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) /* Space 39 B9 */ |
| 1319 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps") PORT_CODE(KEYCODE_CAPSLOCK) /* Caps Lock 3A BA */ |
| 1320 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) /* F1 3B BB */ |
| 1321 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) /* F2 3C BC */ |
| 1322 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) /* F3 3D BD */ |
| 1323 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) /* F4 3E BE */ |
| 1324 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) /* F5 3F BF */ |
| 1459 | 1325 | |
| 1460 | | /* |
| 1461 | | Write vdp wait cycles (1=add 14 cycles, 0=add none) |
| 1462 | | see above for waitstate handling |
| 1463 | | */ |
| 1464 | | static WRITE8_DEVICE_HANDLER( W9901_VDP_wait_states ) |
| 1465 | | { |
| 1466 | | device_t *dev = device->machine().device("geneve_board"); |
| 1467 | | genboard_state *board = get_safe_token(dev); |
| 1468 | | if (VERBOSE>1) LOG("genboard: vdp wait states set to %d\n", data); |
| 1469 | | board->video_waitstates = (data!=0); |
| 1470 | | } |
| 1326 | PORT_START("KEY4") /* IN7 */ |
| 1327 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) /* F6 40 C0 */ |
| 1328 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) /* F7 41 C1 */ |
| 1329 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) /* F8 42 C2 */ |
| 1330 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) /* F9 43 C3 */ |
| 1331 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) /* F10 44 C4 */ |
| 1332 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NumLock") PORT_CODE(KEYCODE_NUMLOCK) /* Num Lock 45 C5 */ |
| 1333 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ScrLock (F14)") PORT_CODE(KEYCODE_SCRLOCK) /* Scroll Lock 46 C6 */ |
| 1334 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 7 (Home)") PORT_CODE(KEYCODE_7_PAD ) /* Keypad 7 (Home) 47 C7 */ |
| 1335 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 8 (Up)") PORT_CODE(KEYCODE_8_PAD ) /* Keypad 8 (Up arrow) 48 C8 */ |
| 1336 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 9 (PgUp)") PORT_CODE(KEYCODE_9_PAD ) /* Keypad 9 (PgUp) 49 C9 */ |
| 1337 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) /* Keypad - 4A CA */ |
| 1338 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 4 (Left)") PORT_CODE(KEYCODE_4_PAD ) /* Keypad 4 (Left arrow) 4B CB */ |
| 1339 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) /* Keypad 5 4C CC */ |
| 1340 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 6 (Right)") PORT_CODE(KEYCODE_6_PAD ) /* Keypad 6 (Right arrow) 4D CD */ |
| 1341 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) /* Keypad + 4E CE */ |
| 1342 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 1 (End)") PORT_CODE(KEYCODE_1_PAD ) /* Keypad 1 (End) 4F CF */ |
| 1471 | 1343 | |
| 1472 | | /* tms9901 setup */ |
| 1473 | | const tms9901_interface tms9901_wiring_geneve = |
| 1474 | | { |
| 1475 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT8 | TMS9901_INTB | TMS9901_INTC, /* only input pins whose state is always known */ |
| 1344 | PORT_START("KEY5") /* IN8 */ |
| 1345 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 2 (Down)") PORT_CODE(KEYCODE_2_PAD ) /* Keypad 2 (Down arrow) 50 D0 */ |
| 1346 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 3 (PgDn)") PORT_CODE(KEYCODE_3_PAD ) /* Keypad 3 (PgDn) 51 D1 */ |
| 1347 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 0 (Ins)") PORT_CODE(KEYCODE_0_PAD ) /* Keypad 0 (Ins) 52 D2 */ |
| 1348 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP . (Del)") PORT_CODE(KEYCODE_DEL_PAD ) /* Keypad . (Del) 53 D3 */ |
| 1349 | PORT_BIT ( 0x0030, 0x0000, IPT_UNUSED ) |
| 1350 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(84/102)\\") PORT_CODE(KEYCODE_BACKSLASH2) /* Backslash 2 56 D6 */ |
| 1351 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)F11") PORT_CODE(KEYCODE_F11) /* F11 57 D7 */ |
| 1352 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)F12") PORT_CODE(KEYCODE_F12) /* F12 58 D8 */ |
| 1353 | PORT_BIT ( 0xfe00, 0x0000, IPT_UNUSED ) |
| 1476 | 1354 | |
| 1477 | | { /* read handlers */ |
| 1478 | | R9901_0, // INTA, VDPint, Joystick |
| 1479 | | R9901_1, // Keyb, Mouse, Clock, INTB |
| 1480 | | R9901_2, // - |
| 1481 | | R9901_3 // Mouse right button |
| 1482 | | }, |
| 1355 | PORT_START("KEY6") /* IN9 */ |
| 1356 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)KP Enter") PORT_CODE(KEYCODE_ENTER_PAD) /* PAD Enter 60 e0 */ |
| 1357 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)R-Control") PORT_CODE(KEYCODE_RCONTROL) /* Right Control 61 e1 */ |
| 1358 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)ALTGR") PORT_CODE(KEYCODE_RALT) /* ALTGR 64 e4 */ |
| 1483 | 1359 | |
| 1484 | | { /* write handlers */ |
| 1485 | | W9901_PE_bus_reset, |
| 1486 | | W9901_VDP_reset, |
| 1487 | | W9901_joySel, |
| 1488 | | NULL, |
| 1489 | | NULL, |
| 1490 | | NULL, |
| 1491 | | W9901_keyboardReset, |
| 1492 | | W9901_ext_mem_wait_states, |
| 1493 | | NULL, |
| 1494 | | W9901_VDP_wait_states, |
| 1495 | | NULL, |
| 1496 | | NULL, |
| 1497 | | NULL, |
| 1498 | | NULL, |
| 1499 | | NULL, |
| 1500 | | NULL |
| 1501 | | }, |
| 1360 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)KP /") PORT_CODE(KEYCODE_SLASH_PAD) /* PAD Slash 62 e2 */ |
| 1502 | 1361 | |
| 1503 | | /* interrupt handler */ |
| 1504 | | tms9901_interrupt_callback, |
| 1362 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Home") PORT_CODE(KEYCODE_HOME) /* Home 66 e6 */ |
| 1363 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Up") PORT_CODE(KEYCODE_UP) /* Up 67 e7 */ |
| 1364 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Page Up") PORT_CODE(KEYCODE_PGUP) /* Page Up 68 e8 */ |
| 1365 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Left") PORT_CODE(KEYCODE_LEFT) /* Left 69 e9 */ |
| 1366 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Right") PORT_CODE(KEYCODE_RIGHT) /* Right 6a ea */ |
| 1367 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)End") PORT_CODE(KEYCODE_END) /* End 6b eb */ |
| 1368 | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Down") PORT_CODE(KEYCODE_DOWN) /* Down 6c ec */ |
| 1369 | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Page Down") PORT_CODE(KEYCODE_PGDN) /* Page Down 6d ed */ |
| 1370 | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Insert") PORT_CODE(KEYCODE_INSERT) /* Insert 6e ee */ |
| 1371 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Delete") PORT_CODE(KEYCODE_DEL) /* Delete 6f ef */ |
| 1505 | 1372 | |
| 1506 | | /* clock rate = 3MHz */ |
| 1507 | | 3000000. |
| 1508 | | }; |
| 1373 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)PrtScr (F13)") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen 63 e3 */ |
| 1374 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Pause (F15)") PORT_CODE(KEYCODE_PAUSE) /* Pause 65 e5 */ |
| 1509 | 1375 | |
| 1510 | | /* |
| 1511 | | inta is connected to both tms9901 IRQ1 line and to tms9995 INT4/EC line. |
| 1512 | | */ |
| 1513 | | WRITE_LINE_DEVICE_HANDLER( board_inta ) |
| 1376 | PORT_START("KEY7") /* IN10 */ |
| 1377 | PORT_BIT ( 0xffff, 0x0000, IPT_UNUSED ) |
| 1378 | #if 0 |
| 1379 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Print Screen") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen alternate 77 f7 */ |
| 1380 | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left Win") /* Left Win 7d fd */ |
| 1381 | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right Win") /* Right Win 7e fe */ |
| 1382 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Menu") /* Menu 7f ff */ |
| 1383 | #endif |
| 1384 | INPUT_PORTS_END |
| 1385 | |
| 1386 | ioport_constructor geneve_keyboard_device::device_input_ports() const |
| 1514 | 1387 | { |
| 1515 | | tms9901_set_single_int(device->machine().device("tms9901"), 1, state); |
| 1516 | | cputag_set_input_line(device->machine(), "maincpu", 1, state); |
| 1388 | return INPUT_PORTS_NAME( genkeys ); |
| 1517 | 1389 | } |
| 1518 | 1390 | |
| 1519 | | /* |
| 1520 | | intb is connected to tms9901 IRQ12 line. |
| 1521 | | */ |
| 1522 | | WRITE_LINE_DEVICE_HANDLER( board_intb ) |
| 1523 | | { |
| 1524 | | tms9901_set_single_int(device->machine().device("tms9901"), 12, state); |
| 1391 | const device_type GENEVE_KEYBOARD = &device_creator<geneve_keyboard_device>; |
| 1525 | 1392 | |
| 1526 | | } |
| 1393 | /**************************************************************************** |
| 1394 | Mouse support |
| 1395 | ****************************************************************************/ |
| 1527 | 1396 | |
| 1528 | | WRITE_LINE_DEVICE_HANDLER( board_ready ) |
| 1397 | geneve_mouse_device::geneve_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1398 | : device_t(mconfig, GENEVE_MOUSE, "Geneve mouse", tag, owner, clock) |
| 1529 | 1399 | { |
| 1530 | | if (VERBOSE>0) LOG("genboard: READY line set ... not yet connected, level=%02x\n", state); |
| 1531 | 1400 | } |
| 1532 | 1401 | |
| 1533 | | /* |
| 1534 | | set the state of int2 (called by the v9938 core) |
| 1535 | | */ |
| 1536 | | void tms9901_gen_set_int2(device_t *, v99x8_device &tms, int state) |
| 1402 | line_state geneve_mouse_device::left_button() |
| 1537 | 1403 | { |
| 1538 | | tms9901_set_single_int(tms.machine().device("tms9901"), 2, state); |
| 1404 | return ((input_port_read(*this, "MOUSE0") & 0x04)!=0)? ASSERT_LINE : CLEAR_LINE; |
| 1539 | 1405 | } |
| 1540 | 1406 | |
| 1541 | | /*************************************************************************** |
| 1542 | | DEVICE LIFECYCLE FUNCTIONS |
| 1543 | | ***************************************************************************/ |
| 1544 | | |
| 1545 | | static const mm58274c_interface geneve_mm58274c_interface = |
| 1407 | void geneve_mouse_device::poll() |
| 1546 | 1408 | { |
| 1547 | | 1, /* mode 24*/ |
| 1548 | | 0 /* first day of week */ |
| 1549 | | }; |
| 1409 | int new_mx, new_my; |
| 1410 | int delta_x, delta_y, buttons; |
| 1550 | 1411 | |
| 1551 | | static MACHINE_CONFIG_FRAGMENT( genboard ) |
| 1552 | | MCFG_MM58274C_ADD("mm58274c", geneve_mm58274c_interface) |
| 1553 | | MACHINE_CONFIG_END |
| 1412 | buttons = input_port_read(*this, "MOUSE0"); |
| 1413 | new_mx = input_port_read(*this, "MOUSEX"); |
| 1414 | new_my = input_port_read(*this, "MOUSEY"); |
| 1554 | 1415 | |
| 1555 | | static DEVICE_START( genboard ) |
| 1556 | | { |
| 1557 | | if (VERBOSE>0) LOG("genboard: Starting Geneve board\n"); |
| 1558 | | genboard_state *board = get_safe_token(device); |
| 1416 | /* compute x delta */ |
| 1417 | delta_x = new_mx - m_last_mx; |
| 1559 | 1418 | |
| 1560 | | board->video = device->siblingdevice("video"); |
| 1561 | | board->tms9901 = device->siblingdevice("tms9901"); |
| 1562 | | board->peribox = device->siblingdevice("peribox"); |
| 1563 | | board->cpu = device->siblingdevice("maincpu"); |
| 1564 | | board->sound = device->siblingdevice("soundgen"); |
| 1419 | /* check for wrap */ |
| 1420 | if (delta_x > 0x80) |
| 1421 | delta_x = 0x100-delta_x; |
| 1422 | if (delta_x < -0x80) |
| 1423 | delta_x = -0x100-delta_x; |
| 1565 | 1424 | |
| 1566 | | board->clock = device->subdevice("mm58274c"); |
| 1425 | m_last_mx = new_mx; |
| 1567 | 1426 | |
| 1568 | | board->sram = (UINT8*)malloc(SRAM_SIZE); |
| 1569 | | board->dram = (UINT8*)malloc(DRAM_SIZE); |
| 1570 | | board->eprom = device->machine().region("maincpu")->base(); |
| 1571 | | assert(board->video && board->tms9901); |
| 1572 | | assert(board->peribox && board->cpu); |
| 1573 | | assert(board->sound && board->clock); |
| 1574 | | assert(board->eprom); |
| 1575 | | board->geneve_mode = false; |
| 1576 | | board->direct_mode = true; |
| 1427 | /* compute y delta */ |
| 1428 | delta_y = new_my - m_last_my; |
| 1577 | 1429 | |
| 1578 | | // Used for generating the VDP waitstates. These are created in the |
| 1579 | | // Gate Array on the board and only affect external memory accesses. |
| 1580 | | // Therefore we cannot use the usual adjust_icount |
| 1581 | | board->video_waittimer = device->machine().scheduler().timer_alloc(FUNC(video_wait_callback), (void *)device); |
| 1430 | /* check for wrap */ |
| 1431 | if (delta_y > 0x80) |
| 1432 | delta_y = 0x100-delta_y; |
| 1433 | if (delta_y < -0x80) |
| 1434 | delta_y = -0x100-delta_y; |
| 1582 | 1435 | |
| 1583 | | memset(board->sram, 0x00, SRAM_SIZE); |
| 1584 | | memset(board->dram, 0x00, DRAM_SIZE); |
| 1585 | | } |
| 1436 | m_last_my = new_my; |
| 1586 | 1437 | |
| 1587 | | static DEVICE_STOP( genboard ) |
| 1588 | | { |
| 1589 | | if (VERBOSE>0) LOG("genboard: Stopping Geneve board\n"); |
| 1590 | | genboard_state *board = get_safe_token(device); |
| 1591 | | free(board->sram); |
| 1592 | | free(board->dram); |
| 1438 | // only middle and right button go to V9938 |
| 1439 | m_v9938->update_mouse_state(delta_x, delta_y, buttons & 0x03); |
| 1593 | 1440 | } |
| 1594 | 1441 | |
| 1595 | | static DEVICE_RESET( genboard ) |
| 1596 | | { |
| 1597 | | genboard_state *board = get_safe_token(device); |
| 1598 | | if (VERBOSE>0) LOG("genboard: Resetting Geneve board\n"); |
| 1599 | | board->joySel = 0; |
| 1600 | | board->keyQueueHead = board->keyQueueLen = 0; |
| 1601 | | memset(board->keyStateSave, 0, sizeof(board->keyStateSave)); |
| 1602 | | board->keyNumLockState = 0; |
| 1603 | | board->keyCtrlState = 0; |
| 1604 | | board->keyAltState = 0; |
| 1605 | | board->keyRealShiftState = 0; |
| 1606 | | board->keyFakeShiftState = 0; |
| 1607 | | board->keyFakeUnshiftState = 0; |
| 1608 | | board->keyAutoRepeatKey = 0; |
| 1609 | | board->keyInBuf = false; |
| 1610 | | board->keyReset = 1; |
| 1611 | | board->last_mx = 0; |
| 1612 | | board->last_my = 0; |
| 1613 | | board->line_count = 0; |
| 1442 | INPUT_PORTS_START( genmouse ) |
| 1443 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 1444 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 1614 | 1445 | |
| 1615 | | board->palvideo = false; |
| 1616 | | board->capslock = false; |
| 1617 | | board->keyboard_clock = false; |
| 1618 | | board->keep_keybuf = false; |
| 1619 | | board->extra_waitstates = false; |
| 1620 | | board->video_waitstates = true; |
| 1621 | | board->video_waiting = false; |
| 1446 | PORT_START("MOUSEY") /* Mouse - Y AXIS */ |
| 1447 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 1622 | 1448 | |
| 1623 | | board->geneve_mode =false; |
| 1624 | | board->direct_mode = true; |
| 1625 | | board->cartridge_size_8K = false; |
| 1626 | | board->cartridge_secondpage = false; |
| 1627 | | board->cartridge6_writable = false; |
| 1628 | | board->cartridge7_writable = false; |
| 1629 | | for (int i=0; i < 8; i++) board->map[i] = 0; |
| 1449 | PORT_START("MOUSE0") /* mouse buttons */ |
| 1450 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Left mouse button") |
| 1451 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Right mouse button") |
| 1452 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Middle mouse button") |
| 1453 | INPUT_PORTS_END |
| 1630 | 1454 | |
| 1631 | | board->genmod = false; |
| 1632 | | if (input_port_read(device->machine(), "MODE")==0) |
| 1633 | | { |
| 1634 | | switch (input_port_read(device->machine(), "BOOTROM")) |
| 1635 | | { |
| 1636 | | case GENEVE_098: |
| 1637 | | if (VERBOSE>0) LOG("genboard: Using 0.98 boot eprom\n"); |
| 1638 | | board->eprom = device->machine().region("maincpu")->base() + 0x4000; |
| 1639 | | break; |
| 1640 | | case GENEVE_100: |
| 1641 | | if (VERBOSE>0) LOG("genboard: Using 1.00 boot eprom\n"); |
| 1642 | | board->eprom = device->machine().region("maincpu")->base(); |
| 1643 | | break; |
| 1644 | | } |
| 1645 | | } |
| 1646 | | else |
| 1647 | | { |
| 1648 | | if (VERBOSE>0) LOG("genboard: Using GenMod modification\n"); |
| 1649 | | board->eprom = device->machine().region("maincpu")->base() + 0x8000; |
| 1650 | | if (board->eprom[0] != 0xf0) |
| 1651 | | { |
| 1652 | | fatalerror("genboard: GenMod boot rom missing.\n"); |
| 1653 | | } |
| 1654 | | board->genmod = true; |
| 1655 | | board->turbo = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TURBO)!=0); |
| 1656 | | board->timode = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TIM)!=0); |
| 1657 | | } |
| 1455 | void geneve_mouse_device::device_start() |
| 1456 | { |
| 1457 | m_v9938 = machine().device<v9938_device>(V9938_TAG); |
| 1458 | } |
| 1658 | 1459 | |
| 1659 | | switch (input_port_read(device->machine(), "SRAM")) |
| 1660 | | { |
| 1661 | | /* 1 100. .... .... .... .... on-board sram (128K) -+ |
| 1662 | | 1 101. .... .... .... .... on-board sram (128K) -+-- maximum SRAM expansion |
| 1663 | | 1 1100 .... .... .... .... on-board sram (64K) --+ |
| 1664 | | 1 1101 0... .... .... .... on-board sram (32K) - additional 32 KiB required for MDOS 2.50s and higher |
| 1665 | | 1 1101 1... .... .... .... on-board sram (32K) - standard setup |
| 1666 | | */ |
| 1667 | | case 0: // 32 KiB |
| 1668 | | board->sram_mask = 0x1f8000; |
| 1669 | | board->sram_val = 0x1d8000; |
| 1670 | | break; |
| 1671 | | case 1: // 64 KiB |
| 1672 | | board->sram_mask = 0x1f0000; |
| 1673 | | board->sram_val = 0x1d0000; |
| 1674 | | break; |
| 1675 | | case 2: // 384 KiB (actually 512 KiB, but the EPROM masks the upper 128 KiB) |
| 1676 | | board->sram_mask = 0x180000; |
| 1677 | | board->sram_val = 0x180000; |
| 1678 | | break; |
| 1679 | | } |
| 1460 | void geneve_mouse_device::device_reset() |
| 1461 | { |
| 1462 | m_last_mx = 0; |
| 1463 | m_last_my = 0; |
| 1680 | 1464 | } |
| 1681 | 1465 | |
| 1682 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 1466 | ioport_constructor geneve_mouse_device::device_input_ports() const |
| 1467 | { |
| 1468 | return INPUT_PORTS_NAME( genmouse ); |
| 1469 | } |
| 1683 | 1470 | |
| 1684 | | #define DEVTEMPLATE_ID(p,s) p##genboard##s |
| 1685 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_MACHINE_CONFIG |
| 1686 | | #define DEVTEMPLATE_NAME "Geneve system board" |
| 1687 | | #define DEVTEMPLATE_FAMILY "Internal component" |
| 1688 | | #include "devtempl.h" |
| 1471 | const device_type GENEVE_MOUSE = &device_creator<geneve_mouse_device>; |
| 1689 | 1472 | |
| 1690 | | DEFINE_LEGACY_DEVICE( GENBOARD, genboard ); |
src/mess/machine/ti99/hfdc.c
| r14513 | r14514 | |
| 1 | | /* |
| 1 | /**************************************************************************** |
| 2 | |
| 2 | 3 | Myarc Hard and Floppy Disk Controller |
| 4 | based on SMC9234 |
| 5 | High Density, Double-sided |
| 6 | |
| 7 | FIXME: HFDC does not work at CRU addresses other than 1100 |
| 8 | (test shows |
| 9 | hfdc: reado 41f5 (00): 00 |
| 10 | hfdc: reado 41f4 (00): 00 -> wrong rom page? (should be (02))) |
| 11 | |
| 3 | 12 | Michael Zapf |
| 4 | | */ |
| 5 | | #include "emu.h" |
| 6 | | #include "peribox.h" |
| 7 | | #include "ti_fdc.h" |
| 8 | | #include "machine/wd17xx.h" |
| 9 | | #include "formats/ti99_dsk.h" |
| 13 | |
| 14 | February 2012: Rewritten as class |
| 15 | |
| 16 | *****************************************************************************/ |
| 17 | |
| 18 | #include "hfdc.h" |
| 10 | 19 | #include "imagedev/flopdrv.h" |
| 11 | | #include "ti99_hd.h" |
| 12 | 20 | #include "machine/mm58274c.h" |
| 13 | | #include "hfdc.h" |
| 21 | #include "formats/ti99_dsk.h" // Format |
| 14 | 22 | |
| 15 | | #define CRU_BASE 0x1100 |
| 23 | #define BUFFER "ram" |
| 24 | #define FDC_TAG "hdc9234" |
| 25 | #define CLOCK_TAG "mm58274c" |
| 16 | 26 | |
| 17 | | #define hfdc_region "hfdc_region" |
| 27 | #define MOTOR_TIMER 1 |
| 18 | 28 | |
| 19 | 29 | #define HFDC_MAX_FLOPPY 4 |
| 20 | 30 | #define HFDC_MAX_HARD 4 |
| r14513 | r14514 | |
| 28 | 38 | #define VERBOSE 1 |
| 29 | 39 | #define LOG logerror |
| 30 | 40 | |
| 31 | | typedef ti99_pebcard_config ti99_hfdc_config; |
| 32 | | |
| 33 | | typedef struct _ti99_hfdc_state |
| 41 | myarc_hfdc_device::myarc_hfdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 42 | : ti_expansion_card_device(mconfig, TI99_HFDC, "Myarc Hard and Floppy Disk Controller", tag, owner, clock) |
| 34 | 43 | { |
| 35 | | /* When TRUE, card is accessible. Indicated by a LED. */ |
| 36 | | int selected; |
| 37 | | |
| 38 | | /* Card select mask. Required to support Genmod. */ |
| 39 | | int select_mask; |
| 40 | | |
| 41 | | /* Card select mask. Required to support Genmod. */ |
| 42 | | int select_value; |
| 43 | | |
| 44 | | /* When TRUE, triggers motor monoflop. */ |
| 45 | | int strobe_motor; |
| 46 | | |
| 47 | | /* Clock divider bit 0. Unused in this emulation. */ |
| 48 | | int CD0; |
| 49 | | |
| 50 | | /* Clock divider bit 1. Unused in this emulation. */ |
| 51 | | int CD1; |
| 52 | | |
| 53 | | /* count 4.23s from rising edge of motor_on */ |
| 54 | | emu_timer *motor_on_timer; |
| 55 | | |
| 56 | | /* Link to the HDC9234 controller on the board. */ |
| 57 | | device_t *controller; |
| 58 | | |
| 59 | | /* Link to the clock chip on the board. */ |
| 60 | | device_t *clock; |
| 61 | | |
| 62 | | /* Determines whether we have access to the CRU bits. */ |
| 63 | | int cru_select; |
| 64 | | |
| 65 | | /* IRQ state */ |
| 66 | | int irq; |
| 67 | | |
| 68 | | /* DMA in Progress state */ |
| 69 | | int dip; |
| 70 | | |
| 71 | | /* Output 1 latch */ |
| 72 | | UINT8 output1_latch; |
| 73 | | |
| 74 | | /* Output 2 latch */ |
| 75 | | UINT8 output2_latch; |
| 76 | | |
| 77 | | /* Connected floppy drives. */ |
| 78 | | device_t *floppy_unit[HFDC_MAX_FLOPPY]; |
| 79 | | |
| 80 | | /* Connected harddisk drives. */ |
| 81 | | device_t *harddisk_unit[HFDC_MAX_HARD]; |
| 82 | | |
| 83 | | /* DMA address latch */ |
| 84 | | UINT32 dma_address; |
| 85 | | |
| 86 | | /* DSR ROM */ |
| 87 | | UINT8 *rom; |
| 88 | | |
| 89 | | /* ROM banks. */ |
| 90 | | int rom_offset; |
| 91 | | |
| 92 | | /* HFDC RAM */ |
| 93 | | UINT8 *ram; |
| 94 | | |
| 95 | | /* RAM banks */ |
| 96 | | int ram_offset[4]; |
| 97 | | |
| 98 | | /* Callback lines to the main system. */ |
| 99 | | ti99_peb_connect lines; |
| 100 | | |
| 101 | | } ti99_hfdc_state; |
| 102 | | |
| 103 | | INLINE ti99_hfdc_state *get_safe_token(device_t *device) |
| 104 | | { |
| 105 | | assert(device != NULL); |
| 106 | | assert(device->type() == HFDC); |
| 107 | | |
| 108 | | return (ti99_hfdc_state *)downcast<legacy_device_base *>(device)->token(); |
| 44 | m_shortname = "ti99_hfdc"; |
| 109 | 45 | } |
| 110 | 46 | |
| 111 | 47 | /* |
| 112 | | Resets the drive geometry. This is required because the heuristic of |
| 113 | | the default implementation sets the drive geometry to the geometry |
| 114 | | of the medium. |
| 115 | | */ |
| 116 | | static void set_geometry(device_t *drive, floppy_type_t type) |
| 117 | | { |
| 118 | | if (drive!=NULL) |
| 119 | | floppy_drive_set_geometry(drive, type); |
| 120 | | else |
| 121 | | if (VERBOSE>0) LOG("ti99: HFDC: Drive not found\n"); |
| 122 | | } |
| 123 | | |
| 124 | | static void set_all_geometries(device_t *device, floppy_type_t type) |
| 125 | | { |
| 126 | | set_geometry(device->siblingdevice(FLOPPY_0), type); |
| 127 | | set_geometry(device->siblingdevice(FLOPPY_1), type); |
| 128 | | set_geometry(device->siblingdevice(FLOPPY_2), type); |
| 129 | | } |
| 130 | | |
| 131 | | /*************************************************************************/ |
| 132 | | |
| 133 | | /* |
| 134 | | Read disk CRU interface |
| 135 | | HFDC manual p. 44 |
| 136 | | |
| 137 | | CRU Select=0 |
| 138 | | xx00 Disk controller interrupt |
| 139 | | xx02 Motor status |
| 140 | | xx04 DMA in progress |
| 141 | | |
| 142 | | Note that the cru line settings on the board do not match the |
| 143 | | description in the manual. 02 and 04 swap their positions (checked with |
| 144 | | board and schematics). Similarly, the dip switches |
| 145 | | for the drive configurations are not correctly enumerated in the manual. |
| 146 | | |
| 147 | | CRU Select=1 |
| 148 | | xx00 Switch 4 status \_ drive 2 config |
| 149 | | xx02 Switch 3 status / |
| 150 | | xx04 Switch 2 status \_ drive 1 config |
| 151 | | xx06 Switch 1 status / |
| 152 | | xx08 Switch 8 status \_ drive 4 config |
| 153 | | xx0A Switch 7 status / |
| 154 | | xx0C Switch 6 status \_ drive 3 config |
| 155 | | xx0E Switch 5 status / |
| 156 | | |
| 157 | | config: 00 = 9/16/18 sectors, 40 tracks, 16 msec |
| 158 | | 10 = 9/16/18 sectors, 40 tracks, 8 msec |
| 159 | | 01 = 9/16/18 sectors, 80 tracks, 2 msec |
| 160 | | 11 = 36 sectors, 80 tracks, 2 msec |
| 161 | | */ |
| 162 | | static READ8Z_DEVICE_HANDLER( cru_r ) |
| 163 | | { |
| 164 | | ti99_hfdc_state *card = get_safe_token(device); |
| 165 | | UINT8 reply; |
| 166 | | |
| 167 | | if ((offset & 0xff00)==CRU_BASE) |
| 168 | | { |
| 169 | | if ((offset & 0x00ff)==0) /* CRU bits 0-7 */ |
| 170 | | { |
| 171 | | /* CRU bits */ |
| 172 | | if (card->cru_select) |
| 173 | | { |
| 174 | | // DIP switches. Logic levels are inverted (on->0, off->1). CRU |
| 175 | | // bit order is the reverse of DIP-switch order, too (dip 1 -> bit 7, |
| 176 | | // dip 8 -> bit 0). |
| 177 | | // MZ: 00 should not be used since there is a bug in the |
| 178 | | // DSR of the HFDC which causes problems with SD disks |
| 179 | | // (controller tries DD and then fails to fall back to SD) */ |
| 180 | | reply = ~(input_port_read(device->machine(), "HFDCDIP")); |
| 181 | | } |
| 182 | | else |
| 183 | | { |
| 184 | | reply = 0; |
| 185 | | |
| 186 | | if (card->irq) reply |= 0x01; |
| 187 | | if (card->dip) reply |= 0x02; |
| 188 | | if (card->strobe_motor) reply |= 0x04; |
| 189 | | } |
| 190 | | *value = reply; |
| 191 | | } |
| 192 | | else /* CRU bits 8+ */ |
| 193 | | *value = 0; |
| 194 | | } |
| 195 | | } |
| 196 | | |
| 197 | | /* |
| 198 | | Write disk CRU interface |
| 199 | | HFDC manual p. 43 |
| 200 | | |
| 201 | | CRU rel. address Definition Active |
| 202 | | 00 Device Service Routine Select HIGH |
| 203 | | 02 Reset to controller chip LOW |
| 204 | | 04 Floppy Motor on / CD0 HIGH |
| 205 | | 06 ROM page select 0 / CD1 |
| 206 | | 08 ROM page select 1 / CRU input select |
| 207 | | 12/4/6/8/A RAM page select at 0x5400 |
| 208 | | 1C/E/0/2/4 RAM page select at 0x5800 |
| 209 | | 26/8/A/C/E RAM page select at 0x5C00 |
| 210 | | |
| 211 | | RAM bank select: bank 0..31; 12 = LSB (accordingly for other two areas) |
| 212 | | ROM bank select: bank 0..3; 06 = MSB, 07 = LSB |
| 213 | | Bit number = (CRU_rel_address - base_address)/2 |
| 214 | | CD0 and CD1 are Clock Divider selections for the Floppy Data Separator (FDC9216) |
| 215 | | */ |
| 216 | | static WRITE8_DEVICE_HANDLER( cru_w ) |
| 217 | | { |
| 218 | | ti99_hfdc_state *card = get_safe_token(device); |
| 219 | | |
| 220 | | if ((offset & 0xff00)==CRU_BASE) |
| 221 | | { |
| 222 | | int bit = (offset >> 1) & 0x1f; |
| 223 | | |
| 224 | | if (bit >= 9 && bit < 24) |
| 225 | | { |
| 226 | | if (data) |
| 227 | | // we leave index 0 unchanged; modify indexes 1-3 |
| 228 | | card->ram_offset[(bit-4)/5] |= 0x0400 << ((bit-9)%5); |
| 229 | | else |
| 230 | | card->ram_offset[(bit-4)/5] &= ~(0x0400 << ((bit-9)%5)); |
| 231 | | |
| 232 | | return; |
| 233 | | } |
| 234 | | |
| 235 | | switch (bit) |
| 236 | | { |
| 237 | | case 0: |
| 238 | | card->selected = data; |
| 239 | | break; |
| 240 | | |
| 241 | | case 1: |
| 242 | | if (!data) smc92x4_reset(card->controller); // active low |
| 243 | | break; |
| 244 | | |
| 245 | | case 2: |
| 246 | | card->CD0 = data; |
| 247 | | if (data && !card->strobe_motor) |
| 248 | | { |
| 249 | | card->motor_on_timer->adjust(attotime::from_msec(4230)); |
| 250 | | } |
| 251 | | card->strobe_motor = data; |
| 252 | | break; |
| 253 | | |
| 254 | | case 3: |
| 255 | | card->CD1 = data; |
| 256 | | if (data) card->rom_offset |= 0x2000; |
| 257 | | else card->rom_offset &= ~0x2000; |
| 258 | | break; |
| 259 | | |
| 260 | | case 4: |
| 261 | | card->cru_select = data; |
| 262 | | if (data) card->rom_offset |= 0x1000; |
| 263 | | else card->rom_offset &= ~0x1000; |
| 264 | | break; |
| 265 | | |
| 266 | | default: |
| 267 | | if (VERBOSE>1) LOG("ti99: HFDC: Attempt to set undefined CRU bit %d\n", bit); |
| 268 | | } |
| 269 | | } |
| 270 | | } |
| 271 | | |
| 272 | | /* |
| 273 | 48 | read a byte in disk DSR space |
| 274 | 49 | HFDC manual, p. 44 |
| 275 | 50 | Memory map as seen by the 99/4A PEB |
| r14513 | r14514 | |
| 284 | 59 | 0x5800 - 0x5bff static RAM page any of 32 pages |
| 285 | 60 | 0x5c00 - 0x5fff static RAM page any of 32 pages |
| 286 | 61 | */ |
| 287 | | |
| 288 | | static READ8Z_DEVICE_HANDLER( data_r ) |
| 62 | READ8Z_MEMBER(myarc_hfdc_device::readz) |
| 289 | 63 | { |
| 290 | | ti99_hfdc_state *card = get_safe_token(device); |
| 291 | | |
| 292 | | if (card->selected && ((offset & card->select_mask)==card->select_value)) |
| 64 | if (m_selected && ((offset & m_select_mask)==m_select_value)) |
| 293 | 65 | { |
| 294 | 66 | /* DSR region */ |
| 295 | 67 | if ((offset & 0x1000)==0x0000) |
| r14513 | r14514 | |
| 299 | 71 | // Tape: 4fc0...4fcf |
| 300 | 72 | if ((offset & 0x1ff0)==TAPE_ADDR) |
| 301 | 73 | { |
| 302 | | if (VERBOSE>0) LOG("ti99: HFDC: Tape support not available (access to address %04x)\n", offset); |
| 74 | if (VERBOSE>0) LOG("ti99: HFDC: Tape support not available (access to address %04x)\n", offset&0xffff); |
| 303 | 75 | return; |
| 304 | 76 | } |
| 305 | 77 | |
| r14513 | r14514 | |
| 307 | 79 | // read: 0100 1111 1101 xx00 |
| 308 | 80 | if ((offset & 0x1ff3)==HDC_R_ADDR) |
| 309 | 81 | { |
| 310 | | *value = smc92x4_r(card->controller, (offset>>2)&1); |
| 82 | *value = m_hdc9234->read(space, (offset>>2)&1, mem_mask); |
| 83 | if (VERBOSE>7) LOG("hfdc: read %04x: %02x\n", offset & 0xffff, *value); |
| 311 | 84 | return; |
| 312 | 85 | } |
| 313 | 86 | |
| 314 | 87 | if ((offset & 0x1fe1)==CLK_ADDR) |
| 315 | 88 | { |
| 316 | | *value = mm58274c_r(card->clock, (offset & 0x001e) >> 1); |
| 89 | *value = mm58274c_r(m_clock, (offset & 0x001e) >> 1); |
| 90 | if (VERBOSE>7) LOG("hfdc: read from clock address %04x: %02x\n", offset & 0xffff, *value); |
| 317 | 91 | return; |
| 318 | 92 | } |
| 319 | 93 | } |
| 320 | 94 | else |
| 321 | 95 | { |
| 322 | 96 | // ROM |
| 323 | | *value = card->rom[card->rom_offset + (offset & 0x0fff)]; |
| 97 | *value = m_dsrrom[(m_rom_page << 12) | (offset & 0x0fff)]; |
| 98 | if (VERBOSE>7) LOG("hfdc: reado %04x (%02x): %02x\n", offset & 0xffff, m_rom_page, *value); |
| 324 | 99 | return; |
| 325 | 100 | } |
| 326 | 101 | } |
| r14513 | r14514 | |
| 333 | 108 | // 0101 10xx xxxx xxxx bank 2 |
| 334 | 109 | // 0101 11xx xxxx xxxx bank 3 |
| 335 | 110 | int bank = (offset & 0x0c00) >> 10; |
| 336 | | *value = card->ram[card->ram_offset[bank] + (offset & 0x03ff)]; |
| 111 | *value = m_buffer_ram[(m_ram_page[bank]<<10) | (offset & 0x03ff)]; |
| 112 | if (VERBOSE>7) LOG("hfdc: read %04x (%02x): %02x\n", offset & 0xffff, m_ram_page[bank], *value); |
| 337 | 113 | } |
| 338 | 114 | } |
| 339 | 115 | } |
| r14513 | r14514 | |
| 341 | 117 | /* |
| 342 | 118 | Write a byte to the controller. |
| 343 | 119 | */ |
| 344 | | static WRITE8_DEVICE_HANDLER( data_w ) |
| 120 | WRITE8_MEMBER( myarc_hfdc_device::write ) |
| 345 | 121 | { |
| 346 | | ti99_hfdc_state *card = get_safe_token(device); |
| 347 | | if (card->selected && ((offset & card->select_mask)==card->select_value)) |
| 122 | if (m_selected && ((offset & m_select_mask)==m_select_value)) |
| 348 | 123 | { |
| 349 | 124 | // Tape: 4fc0...4fcf |
| 350 | 125 | if ((offset & 0x1ff0)==TAPE_ADDR) |
| 351 | 126 | { |
| 352 | | if (VERBOSE>0) LOG("ti99: HFDC: Tape support not available (access to address %04x)\n", offset); |
| 127 | if (VERBOSE>0) LOG("ti99: HFDC: Tape support not available (access to address %04x)\n", offset & 0xffff); |
| 353 | 128 | return; |
| 354 | 129 | } |
| 355 | 130 | |
| r14513 | r14514 | |
| 357 | 132 | // write: 0100 1111 1101 xx10 |
| 358 | 133 | if ((offset & 0x1ff3)==HDC_W_ADDR) |
| 359 | 134 | { |
| 360 | | smc92x4_w(card->controller, (offset>>2)&1, data); |
| 135 | if (VERBOSE>7) LOG("hfdc: write to controller address %04x: %02x\n", offset & 0xffff, data); |
| 136 | m_hdc9234->write(space, (offset>>2)&1, data, mem_mask); |
| 361 | 137 | return; |
| 362 | 138 | } |
| 363 | 139 | |
| 364 | 140 | if ((offset & 0x1fe1)==CLK_ADDR) |
| 365 | 141 | { |
| 366 | | mm58274c_w(card->clock, (offset & 0x001e) >> 1, data); |
| 142 | if (VERBOSE>7) LOG("hfdc: write to clock address %04x: %02x\n", offset & 0xffff, data); |
| 143 | mm58274c_w(m_clock, (offset & 0x001e) >> 1, data); |
| 367 | 144 | return; |
| 368 | 145 | } |
| 369 | 146 | |
| r14513 | r14514 | |
| 375 | 152 | // 0101 10xx xxxx xxxx bank 2 |
| 376 | 153 | // 0101 11xx xxxx xxxx bank 3 |
| 377 | 154 | int bank = (offset & 0x0c00) >> 10; |
| 378 | | card->ram[card->ram_offset[bank] + (offset & 0x03ff)] = data; |
| 155 | if (VERBOSE>7) LOG("hfdc: WRITE %04x (%02x): %02x\n", (offset & 0xffff), m_ram_page[bank], data); |
| 156 | m_buffer_ram[(m_ram_page[bank]<<10) | (offset & 0x03ff)] = data; |
| 379 | 157 | } |
| 380 | 158 | } |
| 381 | 159 | } |
| 382 | 160 | |
| 383 | | /* |
| 384 | | Called whenever the state of the sms9234 interrupt pin changes. |
| 385 | | */ |
| 386 | | static WRITE_LINE_DEVICE_HANDLER( intrq_w ) |
| 161 | void myarc_hfdc_device::crureadz(offs_t offset, UINT8 *value) |
| 387 | 162 | { |
| 388 | | // Note that the callback functions deliver the calling device, which is |
| 389 | | // the controller in this case. |
| 390 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 391 | | card->irq = state; |
| 163 | UINT8 reply; |
| 164 | if ((offset & 0xff00)==m_cru_base) |
| 165 | { |
| 166 | if ((offset & 0x00ff)==0) /* CRU bits 0-7 */ |
| 167 | { |
| 168 | /* CRU bits */ |
| 169 | if (m_cru_select) |
| 170 | { |
| 171 | // DIP switches. Logic levels are inverted (on->0, off->1). CRU |
| 172 | // bit order is the reverse of DIP-switch order, too (dip 1 -> bit 7, |
| 173 | // dip 8 -> bit 0). |
| 174 | // MZ: 00 should not be used since there is a bug in the |
| 175 | // DSR of the HFDC which causes problems with SD disks |
| 176 | // (controller tries DD and then fails to fall back to SD) */ |
| 177 | reply = ~(input_port_read(*this, "HFDCDIP")); |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | reply = 0; |
| 392 | 182 | |
| 393 | | // Set INTA* (active low) |
| 394 | | // Signal from SMC is active high, INTA* is active low; board inverts signal |
| 395 | | card->lines.inta(state); |
| 183 | if (m_irq) reply |= 0x01; |
| 184 | if (m_dip) reply |= 0x02; |
| 185 | if (m_motor_running) reply |= 0x04; |
| 186 | } |
| 187 | *value = reply; |
| 188 | } |
| 189 | else /* CRU bits 8+ */ |
| 190 | *value = 0; |
| 191 | if (VERBOSE>7) LOG("hfdc: reading from CRU %04x: %02x\n", offset, *value); |
| 192 | } |
| 396 | 193 | } |
| 397 | 194 | |
| 398 | 195 | /* |
| 399 | | Called whenever the state of the sms9234 DMA in progress changes. |
| 196 | Write disk CRU interface |
| 197 | HFDC manual p. 43 |
| 198 | |
| 199 | CRU rel. address Definition Active |
| 200 | 00 Device Service Routine Select HIGH |
| 201 | 02 Reset to controller chip LOW |
| 202 | 04 Floppy Motor on / CD0 HIGH |
| 203 | 06 ROM page select 0 / CD1 |
| 204 | 08 ROM page select 1 / CRU input select |
| 205 | 12/4/6/8/A RAM page select at 0x5400 |
| 206 | 1C/E/0/2/4 RAM page select at 0x5800 |
| 207 | 26/8/A/C/E RAM page select at 0x5C00 |
| 208 | |
| 209 | RAM bank select: bank 0..31; 12 = LSB (accordingly for other two areas) |
| 210 | ROM bank select: bank 0..3; 06 = MSB, 07 = LSB |
| 211 | Bit number = (CRU_rel_address - base_address)/2 |
| 212 | CD0 and CD1 are Clock Divider selections for the Floppy Data Separator (FDC9216) |
| 400 | 213 | */ |
| 401 | | static WRITE_LINE_DEVICE_HANDLER( dip_w ) |
| 214 | void myarc_hfdc_device::cruwrite(offs_t offset, UINT8 data) |
| 402 | 215 | { |
| 403 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 404 | | card->dip = state; |
| 405 | | } |
| 406 | | |
| 407 | | // device ok |
| 408 | | static WRITE8_DEVICE_HANDLER( auxbus_out ) |
| 409 | | { |
| 410 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 411 | | switch (offset) |
| 216 | if ((offset & 0xff00)==m_cru_base) |
| 412 | 217 | { |
| 413 | | case INPUT_STATUS: |
| 414 | | if (VERBOSE>1) LOG("ti99: HFDC: Invalid operation: S0=S1=0, but tried to write (expected: read drive status)\n"); |
| 415 | | break; |
| 218 | if (VERBOSE>7) LOG("hfdc: writing to CRU %04x: %02x\n", offset, data); |
| 219 | int bit = (offset >> 1) & 0x1f; |
| 416 | 220 | |
| 417 | | case OUTPUT_DMA_ADDR: |
| 418 | | /* Value is dma address byte. Shift previous contents to the left. */ |
| 419 | | card->dma_address = ((card->dma_address << 8) + (data&0xff))&0xffffff; |
| 420 | | break; |
| 221 | if (bit >= 9 && bit < 24) |
| 222 | { |
| 223 | if (data) |
| 224 | // we leave index 0 unchanged; modify indices 1-3 |
| 225 | m_ram_page[(bit-4)/5] |= 1 << ((bit-9)%5); |
| 226 | else |
| 227 | m_ram_page[(bit-4)/5] &= ~(1 << ((bit-9)%5)); |
| 421 | 228 | |
| 422 | | case OUTPUT_OUTPUT1: |
| 423 | | /* value is output1 */ |
| 424 | | card->output1_latch = data; |
| 425 | | break; |
| 229 | return; |
| 230 | } |
| 426 | 231 | |
| 427 | | case OUTPUT_OUTPUT2: |
| 428 | | /* value is output2 */ |
| 429 | | card->output2_latch = data; |
| 430 | | break; |
| 431 | | } |
| 432 | | } |
| 232 | switch (bit) |
| 233 | { |
| 234 | case 0: |
| 235 | m_selected = (data!=0); |
| 236 | if (VERBOSE>7) LOG("hfdc: selected = %d\n", m_selected); |
| 237 | break; |
| 433 | 238 | |
| 434 | | static int line_to_index(UINT8 line, int max) |
| 435 | | { |
| 436 | | // Calculate the binary logarithm of the given 2-multiple |
| 437 | | int index = 0; |
| 438 | | while (index < max) |
| 439 | | { |
| 440 | | if ((line & 0x01)!=0) |
| 239 | case 1: |
| 240 | if (data==0) m_hdc9234->reset(); // active low |
| 441 | 241 | break; |
| 442 | | else |
| 443 | | { |
| 444 | | line = line >> 1; |
| 445 | | index++; |
| 446 | | } |
| 447 | | } |
| 448 | | if (index==max) return -1; |
| 449 | | return index; |
| 450 | | } |
| 451 | 242 | |
| 452 | | /* |
| 453 | | Select the HFDC floppy disk unit |
| 454 | | This function implements the selection logic on the PCB (outside the |
| 455 | | controller chip) |
| 456 | | (Callback function) |
| 457 | | */ |
| 243 | case 2: |
| 244 | m_CD0 = data; |
| 245 | if (data != 0) m_motor_running = true; |
| 246 | else |
| 247 | { |
| 248 | if (m_motor_running) |
| 249 | { |
| 250 | m_motor_on_timer->adjust(attotime::from_msec(4230)); |
| 251 | } |
| 252 | } |
| 253 | break; |
| 458 | 254 | |
| 459 | | static device_t *current_floppy(device_t *controller) |
| 460 | | { |
| 461 | | int disk_unit = -1; |
| 462 | | ti99_hfdc_state *card = get_safe_token(controller->owner()); |
| 255 | case 3: |
| 256 | m_CD1 = data; |
| 257 | if (data!=0) m_rom_page |= 2; |
| 258 | else m_rom_page &= 0xfd; |
| 259 | break; |
| 463 | 260 | |
| 464 | | disk_unit = line_to_index(card->output1_latch & 0x0f, HFDC_MAX_FLOPPY); |
| 261 | case 4: |
| 262 | m_cru_select = (data!=0); |
| 263 | if (data!=0) m_rom_page |= 1; |
| 264 | else m_rom_page &= 0xfe; |
| 265 | break; |
| 465 | 266 | |
| 466 | | if (disk_unit<0) |
| 467 | | { |
| 468 | | if (VERBOSE>1) LOG("ti99: HFDC: No unit selected\n"); |
| 469 | | return NULL; |
| 267 | default: |
| 268 | if (VERBOSE>1) LOG("ti99: HFDC: Attempt to set undefined CRU bit %d\n", bit); |
| 269 | } |
| 470 | 270 | } |
| 471 | | |
| 472 | | return card->floppy_unit[disk_unit]; |
| 473 | 271 | } |
| 474 | 272 | |
| 475 | | /* |
| 476 | | Select the HFDC hard disk unit |
| 477 | | This function implements the selection logic on the PCB (outside the |
| 478 | | controller chip) |
| 479 | | The HDC9234 allows up to four drives to be selected by the select lines. |
| 480 | | This is not enough for controlling four floppy drives and three hard |
| 481 | | drives, so the user programmable outputs are used to select the floppy |
| 482 | | drives. This selection happens completely outside of the controller, |
| 483 | | so we must implement it here. |
| 484 | | */ |
| 485 | 273 | |
| 486 | | static device_t *current_harddisk(device_t *controller) |
| 274 | int myarc_hfdc_device::slog2(int value) |
| 487 | 275 | { |
| 488 | | ti99_hfdc_state *card = get_safe_token(controller->owner()); |
| 489 | | |
| 490 | | int disk_unit = -1; |
| 491 | | disk_unit = line_to_index((card->output1_latch>>4)&0x0f, HFDC_MAX_HARD); |
| 492 | | |
| 493 | | /* The HFDC does not use disk_unit=0. The first HD has index 1. */ |
| 494 | | |
| 495 | | if (disk_unit>=0) |
| 496 | | return card->harddisk_unit[disk_unit]; |
| 497 | | else |
| 498 | | return NULL; |
| 276 | int i=-1; |
| 277 | while (value!=0) |
| 278 | { |
| 279 | value >>= 1; |
| 280 | i++; |
| 281 | } |
| 282 | return i; |
| 499 | 283 | } |
| 500 | 284 | |
| 501 | | static READ_LINE_DEVICE_HANDLER( auxbus_in ) |
| 285 | READ8_MEMBER( myarc_hfdc_device::auxbus_in ) |
| 502 | 286 | { |
| 503 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 504 | | device_t *drive; |
| 505 | 287 | UINT8 reply = 0; |
| 288 | int index = 0; |
| 506 | 289 | |
| 507 | | if (card->output1_latch==0) |
| 290 | if ((m_output1_latch & 0xf0)==0) |
| 508 | 291 | { |
| 292 | if (VERBOSE>4) LOG("hfdc: no drive selected, returning 0\n"); |
| 293 | // No HD and no floppy |
| 509 | 294 | return 0; /* is that the correct default value? */ |
| 510 | 295 | } |
| 511 | 296 | |
| 512 | | /* If a floppy is selected, we have one line set among the four programmable outputs. */ |
| 513 | | if ((card->output1_latch & 0x0f)!=0) |
| 297 | // If a floppy is selected, we have one line set among the four programmable outputs. |
| 298 | // Floppy selected <=> latch & 0x10 != 0; floppy number in last four bits |
| 299 | if ((m_output1_latch & 0x10)!=0) |
| 514 | 300 | { |
| 515 | | drive = current_floppy(device); |
| 301 | index = slog2(m_output1_latch & 0x0f); |
| 302 | if (index==-1) return 0; |
| 516 | 303 | |
| 517 | 304 | /* Get floppy status. */ |
| 518 | | if (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_INDEX) == FLOPPY_DRIVE_INDEX) |
| 305 | if (floppy_drive_get_flag_state(m_floppy_unit[index], FLOPPY_DRIVE_INDEX) == FLOPPY_DRIVE_INDEX) |
| 519 | 306 | reply |= DS_INDEX; |
| 520 | | if (floppy_tk00_r(drive) == CLEAR_LINE) |
| 307 | if (floppy_tk00_r(m_floppy_unit[index]) == CLEAR_LINE) |
| 521 | 308 | reply |= DS_TRK00; |
| 522 | | if (floppy_wpt_r(drive) == CLEAR_LINE) |
| 309 | if (floppy_wpt_r(m_floppy_unit[index]) == CLEAR_LINE) |
| 523 | 310 | reply |= DS_WRPROT; |
| 524 | 311 | |
| 525 | 312 | /* if (image_exists(disk_img)) */ |
| 526 | 313 | |
| 527 | 314 | reply |= DS_READY; /* Floppies don't have a READY line; line is pulled up */ |
| 528 | 315 | reply |= DS_SKCOM; /* Same here. */ |
| 316 | if (VERBOSE>4) LOG("hfdc: floppy selected, returning status %02x\n", reply); |
| 529 | 317 | } |
| 530 | | else /* one of the first four lines must be selected */ |
| 318 | else // one of the first three lines must be selected |
| 531 | 319 | { |
| 532 | 320 | UINT8 state; |
| 533 | | drive = current_harddisk(device); |
| 534 | | state = ti99_mfm_harddisk_status(drive); |
| 321 | index = slog2((m_output1_latch>>4) & 0x0f)-1; |
| 322 | mfm_harddisk_device *hd = static_cast<mfm_harddisk_device *>(m_harddisk_unit[index]); |
| 323 | state = hd->get_status(); |
| 324 | |
| 535 | 325 | if (state & MFMHD_TRACK00) reply |= DS_TRK00; |
| 536 | 326 | if (state & MFMHD_SEEKCOMP) reply |= DS_SKCOM; |
| 537 | 327 | if (state & MFMHD_WRFAULT) reply |= DS_WRFAULT; |
| 538 | 328 | if (state & MFMHD_INDEX) reply |= DS_INDEX; |
| 539 | 329 | if (state & MFMHD_READY) reply |= DS_READY; |
| 330 | if (VERBOSE>4) LOG("hfdc: hd selected, returning status %02x\n", reply); |
| 540 | 331 | } |
| 541 | 332 | |
| 542 | 333 | return reply; |
| 543 | 334 | } |
| 544 | 335 | |
| 336 | WRITE8_MEMBER( myarc_hfdc_device::auxbus_out ) |
| 337 | { |
| 338 | int index; |
| 339 | device_t* selected_drive = NULL; |
| 340 | |
| 341 | switch (offset) |
| 342 | { |
| 343 | case INPUT_STATUS: |
| 344 | if (VERBOSE>1) LOG("ti99: HFDC: Invalid operation: S0=S1=0, but tried to write (expected: read drive status)\n"); |
| 345 | break; |
| 346 | |
| 347 | case OUTPUT_DMA_ADDR: |
| 348 | /* Value is dma address byte. Shift previous contents to the left. */ |
| 349 | m_dma_address = ((m_dma_address << 8) + (data&0xff))&0xffffff; |
| 350 | break; |
| 351 | |
| 352 | case OUTPUT_OUTPUT1: |
| 353 | // value is output1 |
| 354 | // The HFDC interprets the value as follows: |
| 355 | // WDS = Winchester Drive System, old name for hard disk |
| 356 | // +------+------+------+------+------+------+------+------+ |
| 357 | // | WDS3 | WDS2 | WDS1 | DSKx | x=4 | x=3 | x=2 | x=1 | |
| 358 | // +------+------+------+------+------+------+------+------+ |
| 359 | // Accordingly, drive 0 is always the floppy; selected by the low nibble |
| 360 | if (data & 0x10) |
| 361 | { |
| 362 | // Floppy selected |
| 363 | index = slog2(data & 0x0f); |
| 364 | if (index>=0) selected_drive = m_floppy_unit[index]; |
| 365 | } |
| 366 | else |
| 367 | { |
| 368 | // HD selected |
| 369 | index = slog2((data>>4) & 0x0f); |
| 370 | if (index>=0) selected_drive = m_harddisk_unit[index-1]; |
| 371 | } |
| 372 | |
| 373 | m_hdc9234->connect_drive(selected_drive); |
| 374 | m_output1_latch = data; |
| 375 | break; |
| 376 | |
| 377 | case OUTPUT_OUTPUT2: |
| 378 | /* value is output2 */ |
| 379 | m_output2_latch = data; |
| 380 | break; |
| 381 | } |
| 382 | } |
| 383 | |
| 545 | 384 | /* |
| 546 | 385 | Read a byte from buffer in DMA mode |
| 547 | 386 | */ |
| 548 | | static UINT8 hfdc_dma_read_callback(device_t *device) |
| 387 | READ8_MEMBER( myarc_hfdc_device::read_buffer ) |
| 549 | 388 | { |
| 550 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 551 | | UINT8 value = card->ram[card->dma_address & 0x7fff]; |
| 552 | | card->dma_address++; |
| 389 | UINT8 value = m_buffer_ram[m_dma_address & 0x7fff]; |
| 390 | m_dma_address++; |
| 553 | 391 | return value; |
| 554 | 392 | } |
| 555 | 393 | |
| 556 | 394 | /* |
| 557 | 395 | Write a byte to buffer in DMA mode |
| 558 | 396 | */ |
| 559 | | static void hfdc_dma_write_callback(device_t *device, UINT8 data) |
| 397 | WRITE8_MEMBER( myarc_hfdc_device::write_buffer ) |
| 560 | 398 | { |
| 561 | | ti99_hfdc_state *card = get_safe_token(device->owner()); |
| 562 | | card->ram[card->dma_address & 0x7fff] = data; |
| 563 | | card->dma_address++; |
| 399 | m_buffer_ram[m_dma_address & 0x7fff] = data; |
| 400 | m_dma_address++; |
| 564 | 401 | } |
| 565 | 402 | |
| 566 | 403 | /* |
| 567 | | callback called at the end of the motor movement |
| 404 | Called whenever the state of the sms9234 interrupt pin changes. |
| 568 | 405 | */ |
| 569 | | static TIMER_CALLBACK(motor_on_timer_callback) |
| 406 | WRITE_LINE_MEMBER( myarc_hfdc_device::intrq_w ) |
| 570 | 407 | { |
| 571 | | // currently no activity here |
| 408 | m_irq = state; |
| 409 | |
| 410 | // Set INTA* |
| 411 | // Signal from SMC is active high, INTA* is active low; board inverts signal |
| 412 | // Anyway, we keep with ASSERT_LINE and CLEAR_LINE |
| 413 | m_slot->set_inta(state); |
| 572 | 414 | } |
| 573 | 415 | |
| 416 | |
| 574 | 417 | /* |
| 575 | | Preliminary MFM harddisk interface. |
| 418 | Called whenever the state of the sms9234 DMA in progress changes. |
| 576 | 419 | */ |
| 577 | | static void hfdc_harddisk_get_next_id(device_t *controller, int head, chrn_id_hd *id) |
| 420 | WRITE_LINE_MEMBER( myarc_hfdc_device::dip_w ) |
| 578 | 421 | { |
| 579 | | device_t *harddisk = current_harddisk(controller); |
| 580 | | if (harddisk != NULL) |
| 581 | | ti99_mfm_harddisk_get_next_id(harddisk, head, id); |
| 422 | m_dip = state; |
| 582 | 423 | } |
| 583 | 424 | |
| 584 | | static void hfdc_harddisk_seek(device_t *controller, int direction) |
| 425 | /* |
| 426 | Callback called at the end of DVENA pulse |
| 427 | */ |
| 428 | void myarc_hfdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 585 | 429 | { |
| 586 | | device_t *harddisk = current_harddisk(controller); |
| 587 | | if (harddisk != NULL) |
| 588 | | ti99_mfm_harddisk_seek(harddisk, direction); |
| 430 | m_motor_running = false; |
| 431 | if (VERBOSE>6) LOG("hfdc: motor off\n"); |
| 589 | 432 | } |
| 590 | 433 | |
| 591 | | static void hfdc_harddisk_read_sector(device_t *controller, int cylinder, int head, int sector, UINT8 **buf, int *sector_length) |
| 434 | const smc92x4_interface ti99_smc92x4_interface = |
| 592 | 435 | { |
| 593 | | device_t *harddisk = current_harddisk(controller); |
| 594 | | if (harddisk != NULL) |
| 595 | | ti99_mfm_harddisk_read_sector(harddisk, cylinder, head, sector, buf, sector_length); |
| 596 | | } |
| 436 | FALSE, /* do not use the full track layout */ |
| 437 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, intrq_w), |
| 438 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, dip_w), |
| 439 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, auxbus_out), |
| 440 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, auxbus_in), |
| 441 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, read_buffer), |
| 442 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, myarc_hfdc_device, write_buffer) |
| 443 | }; |
| 597 | 444 | |
| 598 | | static void hfdc_harddisk_write_sector(device_t *controller, int cylinder, int head, int sector, UINT8 *buf, int sector_length) |
| 445 | static const mm58274c_interface floppy_mm58274c_interface = |
| 599 | 446 | { |
| 600 | | device_t *harddisk = current_harddisk(controller); |
| 601 | | if (harddisk != NULL) |
| 602 | | ti99_mfm_harddisk_write_sector(harddisk, cylinder, head, sector, buf, sector_length); |
| 603 | | } |
| 447 | 1, /* mode 24*/ |
| 448 | 0 /* first day of week */ |
| 449 | }; |
| 604 | 450 | |
| 605 | | static void hfdc_harddisk_read_track(device_t *controller, int head, UINT8 **buffer, int *data_count) |
| 606 | | { |
| 607 | | device_t *harddisk = current_harddisk(controller); |
| 608 | | if (harddisk != NULL) |
| 609 | | ti99_mfm_harddisk_read_track(harddisk, head, buffer, data_count); |
| 610 | | } |
| 451 | MACHINE_CONFIG_FRAGMENT( ti99_hfdc ) |
| 452 | MCFG_SMC92X4_ADD(FDC_TAG, ti99_smc92x4_interface ) |
| 453 | MCFG_MM58274C_ADD(CLOCK_TAG, floppy_mm58274c_interface) |
| 454 | MACHINE_CONFIG_END |
| 611 | 455 | |
| 612 | | static void hfdc_harddisk_write_track(device_t *controller, int head, UINT8 *buffer, int data_count) |
| 613 | | { |
| 614 | | device_t *harddisk = current_harddisk(controller); |
| 615 | | if (harddisk != NULL) |
| 616 | | ti99_mfm_harddisk_write_track(harddisk, head, buffer, data_count); |
| 617 | | } |
| 456 | ROM_START( ti99_hfdc ) |
| 457 | ROM_REGION(0x4000, DSRROM, 0) |
| 458 | ROM_LOAD("hfdc.bin", 0x0000, 0x4000, CRC(66fbe0ed) SHA1(11df2ecef51de6f543e4eaf8b2529d3e65d0bd59)) /* HFDC disk DSR ROM */ |
| 459 | ROM_REGION(0x8000, BUFFER, 0) /* HFDC RAM buffer 32 KiB */ |
| 460 | ROM_FILL(0x0000, 0x8000, 0x00) |
| 461 | ROM_END |
| 618 | 462 | |
| 619 | | const smc92x4_interface ti99_smc92x4_interface = |
| 620 | | { |
| 621 | | FALSE, /* do not use the full track layout */ |
| 622 | | DEVCB_LINE(intrq_w), |
| 623 | | DEVCB_LINE(dip_w), |
| 624 | | DEVCB_HANDLER(auxbus_out), |
| 625 | | DEVCB_LINE(auxbus_in), |
| 463 | INPUT_PORTS_START( ti99_hfdc ) |
| 464 | PORT_START( "CRUHFDC" ) |
| 465 | PORT_DIPNAME( 0x1f00, 0x1100, "HFDC CRU base" ) |
| 466 | PORT_DIPSETTING( 0x1000, "1000" ) |
| 467 | PORT_DIPSETTING( 0x1100, "1100" ) |
| 468 | PORT_DIPSETTING( 0x1200, "1200" ) |
| 469 | PORT_DIPSETTING( 0x1300, "1300" ) |
| 470 | PORT_DIPSETTING( 0x1400, "1400" ) |
| 471 | PORT_DIPSETTING( 0x1500, "1500" ) |
| 472 | PORT_DIPSETTING( 0x1600, "1600" ) |
| 473 | PORT_DIPSETTING( 0x1700, "1700" ) |
| 474 | PORT_DIPSETTING( 0x1800, "1800" ) |
| 475 | PORT_DIPSETTING( 0x1900, "1900" ) |
| 476 | PORT_DIPSETTING( 0x1a00, "1A00" ) |
| 477 | PORT_DIPSETTING( 0x1b00, "1B00" ) |
| 478 | PORT_DIPSETTING( 0x1c00, "1C00" ) |
| 479 | PORT_DIPSETTING( 0x1d00, "1D00" ) |
| 480 | PORT_DIPSETTING( 0x1e00, "1E00" ) |
| 481 | PORT_DIPSETTING( 0x1f00, "1F00" ) |
| 626 | 482 | |
| 627 | | current_floppy, |
| 628 | | hfdc_dma_read_callback, |
| 629 | | hfdc_dma_write_callback, |
| 483 | PORT_START( "HFDCDIP" ) |
| 484 | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) |
| 485 | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 486 | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 487 | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 488 | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 630 | 489 | |
| 631 | | /* Preliminary MFM harddisk interface. */ |
| 632 | | hfdc_harddisk_get_next_id, |
| 633 | | hfdc_harddisk_seek, |
| 634 | | hfdc_harddisk_read_sector, |
| 635 | | hfdc_harddisk_write_sector, |
| 636 | | hfdc_harddisk_read_track, |
| 637 | | hfdc_harddisk_write_track |
| 638 | | }; |
| 490 | PORT_START( "DRVSPD" ) |
| 491 | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) |
| 492 | PORT_CONFSETTING( 0x00, "No delay") |
| 493 | PORT_CONFSETTING( 0x01, "Realistic") |
| 494 | INPUT_PORTS_END |
| 639 | 495 | |
| 640 | | static const ti99_peb_card hfdc_card = |
| 496 | void myarc_hfdc_device::device_start() |
| 641 | 497 | { |
| 642 | | data_r, |
| 643 | | data_w, |
| 644 | | cru_r, |
| 645 | | cru_w, |
| 498 | if (VERBOSE>5) LOG("hfdc: start\n"); |
| 499 | m_hdc9234 = static_cast<smc92x4_device *>(subdevice(FDC_TAG)); |
| 500 | m_clock = subdevice(CLOCK_TAG); |
| 501 | m_dsrrom = subregion(DSRROM)->base(); |
| 502 | m_buffer_ram = subregion(BUFFER)->base(); |
| 646 | 503 | |
| 647 | | NULL, NULL, NULL, NULL |
| 648 | | }; |
| 504 | m_motor_on_timer = timer_alloc(MOTOR_TIMER); |
| 649 | 505 | |
| 650 | | static DEVICE_START( ti99_hfdc ) |
| 651 | | { |
| 652 | | ti99_hfdc_state *card = get_safe_token(device); |
| 653 | | |
| 654 | | /* Resolve the callbacks to the PEB */ |
| 655 | | peb_callback_if *topeb = (peb_callback_if *)device->static_config(); |
| 656 | | card->lines.inta.resolve(topeb->inta, *device); |
| 657 | 506 | // The HFDC does not use READY; it has on-board RAM for DMA |
| 658 | | |
| 659 | | card->motor_on_timer = device->machine().scheduler().timer_alloc(FUNC(motor_on_timer_callback), (void *)device); |
| 660 | | card->ram = NULL; |
| 661 | | card->ram_offset[0] = 0x2000; // static bank |
| 662 | | card->controller = device->subdevice("smc92x4"); |
| 663 | | card->clock = device->subdevice("mm58274c"); |
| 664 | | astring region(device->tag(), ":", hfdc_region); |
| 665 | | card->rom = device->machine().region(region.cstr())->base(); |
| 666 | 507 | } |
| 667 | 508 | |
| 668 | | static DEVICE_STOP( ti99_hfdc ) |
| 509 | void myarc_hfdc_device::device_reset() |
| 669 | 510 | { |
| 670 | | ti99_hfdc_state *card = get_safe_token(device); |
| 671 | | if (card->ram) free(card->ram); |
| 672 | | } |
| 673 | | |
| 674 | | static DEVICE_RESET( ti99_hfdc ) |
| 675 | | { |
| 676 | | ti99_hfdc_state *card = get_safe_token(device); |
| 677 | | static const char *const flopname[] = {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}; |
| 678 | | static const char *const hardname[] = {MFMHD_0, MFMHD_1, MFMHD_2}; |
| 679 | | |
| 680 | | /* If the card is selected in the menu, register the card */ |
| 681 | | if (input_port_read(device->machine(), "DISKCTRL") == DISK_HFDC) |
| 511 | if (VERBOSE>5) LOG("hfdc: reset\n"); |
| 512 | if (m_genmod) |
| 682 | 513 | { |
| 683 | | device_t *peb = device->owner(); |
| 684 | | int success = mount_card(peb, device, &hfdc_card, get_pebcard_config(device)->slot); |
| 685 | | if (!success) return; |
| 514 | m_select_mask = 0x1fe000; |
| 515 | m_select_value = 0x174000; |
| 516 | } |
| 517 | else |
| 518 | { |
| 519 | m_select_mask = 0x7e000; |
| 520 | m_select_value = 0x74000; |
| 521 | } |
| 686 | 522 | |
| 687 | | card->select_mask = 0x7e000; |
| 688 | | card->select_value = 0x74000; |
| 523 | m_cru_base = input_port_read(*this, "CRUHFDC"); |
| 689 | 524 | |
| 690 | | if (input_port_read(device->machine(), "MODE")==GENMOD) |
| 691 | | { |
| 692 | | // GenMod card modification |
| 693 | | if (VERBOSE>0) LOG("ti99: HFDC: Configuring for GenMod\n"); |
| 694 | | card->select_mask = 0x1fe000; |
| 695 | | card->select_value = 0x174000; |
| 696 | | } |
| 525 | // Resetting values |
| 526 | m_rom_page = 0; |
| 697 | 527 | |
| 698 | | // Allocate 32 KiB for on-board buffer memory |
| 699 | | if (card->ram==NULL) |
| 700 | | { |
| 701 | | card->ram = (UINT8*)malloc(32768); |
| 702 | | // memset(card->ram, 0, 32768); |
| 703 | | } |
| 528 | m_ram_page[0] = 0x08; // static page 0x08 |
| 529 | for (int i=1; i < 4; i++) m_ram_page[i] = 0; |
| 530 | m_dma_address = 0; |
| 531 | m_output1_latch = m_output2_latch = 0; |
| 532 | m_dip = m_irq = false; |
| 533 | m_cru_select = false; |
| 534 | m_CD0 = m_CD1 = 0; |
| 535 | m_motor_running = false; |
| 536 | m_selected = false; |
| 704 | 537 | |
| 705 | | if (input_port_read(device->machine(), "HFDCDIP")&0x55) |
| 706 | | ti99_set_80_track_drives(TRUE); |
| 707 | | else |
| 708 | | ti99_set_80_track_drives(FALSE); |
| 538 | // Find the floppies and hard disks |
| 539 | m_floppy_unit[0] = m_slot->get_drive(FLOPPY_0); |
| 540 | m_floppy_unit[1] = m_slot->get_drive(FLOPPY_1); |
| 541 | m_floppy_unit[2] = m_slot->get_drive(FLOPPY_2); |
| 542 | m_floppy_unit[3] = m_slot->get_drive(FLOPPY_3); |
| 709 | 543 | |
| 710 | | smc92x4_set_timing(card->controller, input_port_read(device->machine(), "DRVSPD")); |
| 544 | m_harddisk_unit[0] = m_slot->get_drive(MFMHD_0); |
| 545 | m_harddisk_unit[1] = m_slot->get_drive(MFMHD_1); |
| 546 | m_harddisk_unit[2] = m_slot->get_drive(MFMHD_2); |
| 711 | 547 | |
| 712 | | // Connect floppy drives to controller. Note that *this* is the |
| 713 | | // controller, not the controller chip. The pcb contains a select |
| 714 | | // logic. |
| 715 | | int i; |
| 716 | | for (i = 0; i < 4; i++) |
| 717 | | { |
| 718 | | card->floppy_unit[i] = device->siblingdevice(flopname[i]); |
| 548 | if (input_port_read(*this, "HFDCDIP")&0x55) |
| 549 | ti99_set_80_track_drives(TRUE); |
| 550 | else |
| 551 | ti99_set_80_track_drives(FALSE); |
| 719 | 552 | |
| 720 | | if (card->floppy_unit[i]!=NULL) |
| 721 | | { |
| 722 | | floppy_drive_set_controller(card->floppy_unit[i], device); |
| 723 | | // floppy_drive_set_index_pulse_callback(floppy_unit[i], smc92x4_index_pulse_callback); |
| 724 | | floppy_drive_set_rpm(card->floppy_unit[i], 300.); |
| 725 | | } |
| 726 | | else |
| 727 | | { |
| 728 | | if (VERBOSE>0) LOG("ti99: HFDC: Image %s is null\n", flopname[i]); |
| 729 | | } |
| 730 | | } |
| 553 | m_hdc9234->set_timing(input_port_read(*this, "DRVSPD")!=0); |
| 731 | 554 | |
| 732 | | /* In the HFDC ROM, WDSx selects drive x; drive 0 is not used */ |
| 733 | | for (i = 1; i < 4; i++) |
| 555 | floppy_type_t floptype = FLOPPY_STANDARD_5_25_DSHD; |
| 556 | // Again, need to re-adjust the floppy geometries |
| 557 | for (int i=0; i < HFDC_MAX_FLOPPY; i++) |
| 558 | { |
| 559 | if (m_floppy_unit[i] != NULL) |
| 734 | 560 | { |
| 735 | | card->harddisk_unit[i] = device->siblingdevice(hardname[i-1]); |
| 561 | // floppy_drive_set_controller(card->floppy_unit[i], device); |
| 562 | // floppy_drive_set_index_pulse_callback(floppy_unit[i], smc92x4_index_pulse_callback); |
| 563 | floppy_drive_set_geometry(m_floppy_unit[i], floptype); |
| 736 | 564 | } |
| 737 | | card->harddisk_unit[0] = NULL; |
| 738 | | |
| 739 | | floppy_type_t flop = FLOPPY_STANDARD_5_25_DSHD; |
| 740 | | set_all_geometries(device, flop); |
| 741 | | |
| 742 | | card->strobe_motor = 0; |
| 743 | | card->ram_offset[1] = card->ram_offset[2] = card->ram_offset[3] = 0; |
| 744 | | card->rom_offset = 0; |
| 745 | 565 | } |
| 566 | |
| 567 | if (VERBOSE>2) LOG("hfdc: CRU base = %04x\n", m_cru_base); |
| 746 | 568 | // TODO: Check how to make use of floppy_mon_w(w->drive, CLEAR_LINE); |
| 747 | 569 | } |
| 748 | 570 | |
| 749 | | static const mm58274c_interface floppy_mm58274c_interface = |
| 571 | machine_config_constructor myarc_hfdc_device::device_mconfig_additions() const |
| 750 | 572 | { |
| 751 | | 1, /* mode 24*/ |
| 752 | | 0 /* first day of week */ |
| 753 | | }; |
| 573 | return MACHINE_CONFIG_NAME( ti99_hfdc ); |
| 574 | } |
| 754 | 575 | |
| 755 | | MACHINE_CONFIG_FRAGMENT( ti99_hfdc ) |
| 756 | | MCFG_SMC92X4_ADD("smc92x4", ti99_smc92x4_interface ) |
| 757 | | MCFG_MM58274C_ADD("mm58274c", floppy_mm58274c_interface) |
| 758 | | MACHINE_CONFIG_END |
| 576 | const rom_entry *myarc_hfdc_device::device_rom_region() const |
| 577 | { |
| 578 | return ROM_NAME( ti99_hfdc ); |
| 579 | } |
| 759 | 580 | |
| 760 | | ROM_START( ti99_hfdc ) |
| 761 | | ROM_REGION(0x4000, hfdc_region, 0) |
| 762 | | ROM_LOAD_OPTIONAL("hfdc.bin", 0x0000, 0x4000, CRC(66fbe0ed) SHA1(11df2ecef51de6f543e4eaf8b2529d3e65d0bd59)) /* HFDC disk DSR ROM */ |
| 763 | | ROM_END |
| 581 | ioport_constructor myarc_hfdc_device::device_input_ports() const |
| 582 | { |
| 583 | return INPUT_PORTS_NAME(ti99_hfdc); |
| 584 | } |
| 764 | 585 | |
| 765 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 766 | | |
| 767 | | #define DEVTEMPLATE_ID(p,s) p##ti99_hfdc##s |
| 768 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_ROM_REGION | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG |
| 769 | | #define DEVTEMPLATE_NAME "Myarc Hard and Floppy Disk Controller Card" |
| 770 | | #define DEVTEMPLATE_SHORTNAME "myarchfdc" |
| 771 | | #define DEVTEMPLATE_FAMILY "Peripheral expansion" |
| 772 | | #include "devtempl.h" |
| 773 | | |
| 774 | | DEFINE_LEGACY_DEVICE( HFDC, ti99_hfdc ); |
| 775 | | |
| 586 | const device_type TI99_HFDC = &device_creator<myarc_hfdc_device>; |
src/mess/machine/ti99/ti_rs232.c
| r14513 | r14514 | |
| 1 | | /* |
| 1 | /**************************************************************************** |
| 2 | |
| 2 | 3 | TI-99 RS232 and Parallel interface card |
| 3 | 4 | |
| 4 | 5 | TI99 RS232 card ('rs232') |
| r14513 | r14514 | |
| 93 | 94 | |
| 94 | 95 | The protocol changes back to normal mode after transmitting the control |
| 95 | 96 | sequence. |
| 96 | | */ |
| 97 | 97 | |
| 98 | | #include "emu.h" |
| 99 | | #include "peribox.h" |
| 100 | | #include "machine/tms9902.h" |
| 98 | Michael Zapf |
| 99 | February 2012: Rewritten as class |
| 100 | |
| 101 | *****************************************************************************/ |
| 102 | |
| 101 | 103 | #include "ti_rs232.h" |
| 102 | 104 | |
| 103 | | #define CRU_BASE 0x1300 |
| 104 | 105 | #define SENILA_0_BIT 0x80 |
| 105 | 106 | #define SENILA_1_BIT 0x40 |
| 106 | 107 | |
| 107 | | #define ser_region "ser_region" |
| 108 | | |
| 109 | 108 | #define RECV_MODE_NORMAL 1 |
| 110 | 109 | #define RECV_MODE_ESC 2 |
| 111 | 110 | #define RECV_MODE_ESC_LINES 3 |
| r14513 | r14514 | |
| 113 | 112 | #define VERBOSE 1 |
| 114 | 113 | #define LOG logerror |
| 115 | 114 | |
| 116 | | // Second card: Change CRU base to 0x1500 |
| 117 | | // #define CRU_BASE 0x1500 |
| 115 | #define ESC 0x1b |
| 118 | 116 | |
| 119 | | typedef ti99_pebcard_config ti_rs232_config; |
| 120 | | |
| 121 | | typedef struct _ti_rs232_state |
| 117 | ti_rs232_pio_device::ti_rs232_pio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 118 | : ti_expansion_card_device(mconfig, TI99_RS232, "TI-99 RS232/PIO interface", tag, owner, clock) |
| 122 | 119 | { |
| 123 | | device_t *uart[2]; |
| 124 | | device_t *serdev[2], *piodev; |
| 120 | m_shortname = "ti99_rs232"; |
| 121 | } |
| 125 | 122 | |
| 126 | | int selected; |
| 127 | | int select_mask; |
| 128 | | int select_value; |
| 129 | 123 | |
| 130 | | UINT8 signals[2]; // Latches the state of the output lines for UART0/UART1 |
| 131 | | int recv_mode[2]; // May be NORMAL or ESC |
| 124 | /**************************************************************************/ |
| 125 | /* Ports */ |
| 132 | 126 | |
| 133 | | // Baud rate management |
| 134 | | // not part of the real device, but required for the connection to the |
| 135 | | // real UART |
| 136 | | double time_hold[2]; |
| 127 | ti_rs232_attached_device::ti_rs232_attached_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 128 | : device_t(mconfig, TI99_RS232_DEV, "Serial attached device", tag, owner, clock), |
| 129 | device_image_interface(mconfig, *this) |
| 130 | { |
| 131 | } |
| 137 | 132 | |
| 138 | | // PIO flags |
| 139 | | int pio_direction; // a.k.a. PIOOC pio in output mode if 0 |
| 140 | | int pio_handshakeout; |
| 141 | | int pio_handshakein; |
| 142 | | int pio_spareout; |
| 143 | | int pio_sparein; |
| 144 | | int flag0; // spare |
| 145 | | int led; // a.k.a. flag3 |
| 146 | | int pio_out_buffer; |
| 147 | | int pio_in_buffer; |
| 148 | | int pio_readable; |
| 149 | | int pio_writable; |
| 150 | | int pio_write; // 1 if image is to be written to |
| 133 | ti_pio_attached_device::ti_pio_attached_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 134 | : device_t(mconfig, TI99_PIO_DEV, "Parallel attached device", tag, owner, clock), |
| 135 | device_image_interface(mconfig, *this) |
| 136 | { |
| 137 | } |
| 151 | 138 | |
| 152 | | UINT8 *rom; |
| 153 | | |
| 154 | | /* Keeps the state of the SENILA line. */ |
| 155 | | UINT8 senila; |
| 156 | | |
| 157 | | /* Keeps the value put on the bus when SENILA becomes active. */ |
| 158 | | UINT8 ila; |
| 159 | | |
| 160 | | /* Callback lines to the main system. */ |
| 161 | | ti99_peb_connect lines; |
| 162 | | |
| 163 | | } ti_rs232_state; |
| 164 | | |
| 165 | | #define ESC 0x1b |
| 166 | | |
| 167 | | INLINE ti_rs232_state *get_safe_token(device_t *device) |
| 139 | void ti_rs232_attached_device::device_start() |
| 168 | 140 | { |
| 169 | | assert(device != NULL); |
| 170 | | assert(device->type() == TIRS232); |
| 141 | } |
| 171 | 142 | |
| 172 | | return (ti_rs232_state *)downcast<legacy_device_base *>(device)->token(); |
| 143 | void ti_pio_attached_device::device_start() |
| 144 | { |
| 173 | 145 | } |
| 174 | 146 | |
| 175 | | static void incoming_dtr(device_t *device, line_state value); |
| 176 | | static void output_line_state(device_t *tms9902, int mask, UINT8 value); |
| 177 | | |
| 178 | | |
| 179 | | /**************************************************************************/ |
| 180 | | /* Ports */ |
| 181 | | |
| 182 | | static DEVICE_START( ti99_rs232_serdev ) |
| 147 | void ti_rs232_attached_device::device_config_complete() |
| 183 | 148 | { |
| 149 | update_names(); |
| 184 | 150 | } |
| 185 | 151 | |
| 186 | | static DEVICE_START( ti99_piodev ) |
| 152 | void ti_pio_attached_device::device_config_complete() |
| 187 | 153 | { |
| 154 | update_names(); |
| 188 | 155 | } |
| 189 | 156 | |
| 190 | 157 | /* |
| r14513 | r14514 | |
| 192 | 159 | <name><number>, i.e. the number is the longest string from the right |
| 193 | 160 | which can be interpreted as a number. |
| 194 | 161 | */ |
| 195 | | static int get_index_from_tagname(device_t *image) |
| 162 | int ti_rs232_attached_device::get_index_from_tagname() |
| 196 | 163 | { |
| 197 | | const char *tag = image->tag(); |
| 198 | | int maxlen = strlen(tag); |
| 164 | const char *mytag = tag(); |
| 165 | int maxlen = strlen(mytag); |
| 199 | 166 | int i; |
| 200 | 167 | for (i=maxlen-1; i >=0; i--) |
| 201 | | if (tag[i] < 48 || tag[i] > 57) break; |
| 168 | if (mytag[i] < 48 || mytag[i] > 57) break; |
| 202 | 169 | |
| 203 | | return atoi(tag+i+1); |
| 170 | return atoi(mytag+i+1); |
| 204 | 171 | } |
| 205 | 172 | |
| 206 | 173 | /* |
| 207 | 174 | Initialize rs232 unit and open image |
| 208 | 175 | */ |
| 209 | | static DEVICE_IMAGE_LOAD( ti99_rs232_serdev ) |
| 176 | bool ti_rs232_attached_device::call_load() |
| 210 | 177 | { |
| 211 | | device_t *tms9902 = NULL; |
| 178 | tms9902_device* tms9902 = NULL; |
| 179 | // ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner()); |
| 212 | 180 | |
| 213 | | // TODO: strcmp does not work this way (wrong constant or wrong function) |
| 214 | | int devnumber = get_index_from_tagname(&image.device()); |
| 181 | int devnumber = get_index_from_tagname(); |
| 215 | 182 | if (devnumber==0) |
| 216 | 183 | { |
| 217 | | tms9902 = image.device().siblingdevice("tms9902_0"); |
| 184 | tms9902 = siblingdevice<tms9902_device>("tms9902_0"); |
| 218 | 185 | // Turn on polling |
| 219 | | tms9902_clock(tms9902, true); |
| 186 | tms9902->set_clock(true); |
| 220 | 187 | } |
| 221 | 188 | else if (devnumber==1) |
| 222 | 189 | { |
| 223 | | tms9902 = image.device().siblingdevice("tms9902_1"); |
| 190 | tms9902 = siblingdevice<tms9902_device>("tms9902_1"); |
| 224 | 191 | // Turn on polling |
| 225 | | tms9902_clock(tms9902, true); |
| 192 | tms9902->set_clock(true); |
| 226 | 193 | } |
| 227 | 194 | else |
| 228 | 195 | { |
| 229 | 196 | LOG("ti99/rs232: Could not find device tag number\n"); |
| 230 | | return IMAGE_INIT_FAIL; |
| 197 | return true; |
| 231 | 198 | } |
| 232 | 199 | |
| 233 | | incoming_dtr(tms9902, image? ASSERT_LINE : CLEAR_LINE); |
| 200 | // The following line may cause trouble in the init phase |
| 201 | // card->incoming_dtr(devnumber, (m_file!=NULL)? ASSERT_LINE : CLEAR_LINE); |
| 234 | 202 | |
| 235 | | return IMAGE_INIT_PASS; |
| 203 | return false; // OK |
| 236 | 204 | } |
| 237 | 205 | |
| 238 | | static DEVICE_IMAGE_UNLOAD( ti99_rs232_serdev ) |
| 206 | void ti_rs232_attached_device::call_unload() |
| 239 | 207 | { |
| 240 | | device_t *tms9902 = NULL; |
| 241 | | int devnumber = get_index_from_tagname(&image.device()); |
| 208 | tms9902_device* tms9902 = NULL; |
| 209 | |
| 210 | int devnumber = get_index_from_tagname(); |
| 242 | 211 | if (devnumber==0) |
| 243 | 212 | { |
| 244 | | tms9902 = image.device().siblingdevice("tms9902_0"); |
| 213 | tms9902 = siblingdevice<tms9902_device>("tms9902_0"); |
| 245 | 214 | // Turn off polling |
| 246 | | tms9902_clock(tms9902, false); |
| 215 | tms9902->set_clock(false); |
| 247 | 216 | } |
| 248 | 217 | else if (devnumber==1) |
| 249 | 218 | { |
| 250 | | tms9902 = image.device().siblingdevice("tms9902_1"); |
| 219 | tms9902 = siblingdevice<tms9902_device>("tms9902_1"); |
| 251 | 220 | // Turn off polling |
| 252 | | tms9902_clock(tms9902, false); |
| 221 | tms9902->set_clock(false); |
| 253 | 222 | } |
| 254 | 223 | } |
| 255 | 224 | |
| 256 | 225 | /* |
| 257 | 226 | Initialize pio unit and open image |
| 258 | 227 | */ |
| 259 | | static DEVICE_IMAGE_LOAD( ti99_piodev ) |
| 228 | bool ti_pio_attached_device::call_load() |
| 260 | 229 | { |
| 261 | | device_t *carddev = image.device().owner(); |
| 262 | | ti_rs232_state *card = get_safe_token(carddev); |
| 230 | ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner()); |
| 263 | 231 | |
| 232 | /* tell whether the image is readable */ |
| 233 | card->m_pio_readable = !has_been_created(); |
| 264 | 234 | /* tell whether the image is writable */ |
| 265 | | card->pio_readable = !image.has_been_created(); |
| 266 | | /* tell whether the image is writable */ |
| 267 | | card->pio_writable = !image.is_readonly(); |
| 235 | card->m_pio_writable = !is_readonly(); |
| 268 | 236 | |
| 269 | | if (card->pio_write && card->pio_writable) |
| 270 | | card->pio_handshakein = 0; /* receiver ready */ |
| 237 | if (card->m_pio_write && card->m_pio_writable) |
| 238 | card->m_pio_handshakein = false; /* receiver ready */ |
| 271 | 239 | else |
| 272 | | card->pio_handshakein = 1; |
| 240 | card->m_pio_handshakein = true; |
| 273 | 241 | |
| 274 | | return IMAGE_INIT_PASS; |
| 242 | return false; // OK |
| 275 | 243 | } |
| 276 | 244 | |
| 277 | 245 | /* |
| 278 | 246 | close a pio image |
| 279 | 247 | */ |
| 280 | | static DEVICE_IMAGE_UNLOAD( ti99_piodev ) |
| 248 | void ti_pio_attached_device::call_unload() |
| 281 | 249 | { |
| 282 | | device_t *carddev = image.device().owner(); |
| 283 | | ti_rs232_state *card = get_safe_token(carddev); |
| 250 | ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner()); |
| 284 | 251 | |
| 285 | | card->pio_writable = 0; |
| 286 | | card->pio_handshakein = 1; /* receiver not ready */ |
| 287 | | card->pio_sparein = 0; |
| 252 | card->m_pio_writable = false; |
| 253 | card->m_pio_handshakein = true; /* receiver not ready */ |
| 254 | card->m_pio_sparein = false; |
| 288 | 255 | } |
| 289 | 256 | |
| 290 | 257 | /****************************************************************************/ |
| 291 | 258 | |
| 292 | 259 | /* |
| 293 | 260 | CRU read |
| 294 | | TODO: Check read operations |
| 295 | 261 | */ |
| 296 | | static READ8Z_DEVICE_HANDLER( cru_rz ) |
| 262 | void ti_rs232_pio_device::crureadz(offs_t offset, UINT8 *value) |
| 297 | 263 | { |
| 298 | | ti_rs232_state *card = get_safe_token(device); |
| 299 | | |
| 300 | | if ((offset & 0xff00)==CRU_BASE) |
| 264 | if ((offset & 0xff00)==m_cru_base) |
| 301 | 265 | { |
| 302 | 266 | if ((offset & 0x00c0)==0x0000) |
| 303 | 267 | { |
| 304 | 268 | UINT8 reply = 0x00; |
| 305 | | if (card->pio_direction) |
| 306 | | reply |= 0x02; |
| 307 | | if (card->pio_handshakein) |
| 308 | | reply |= 0x04; |
| 309 | | if (card->pio_sparein) |
| 310 | | reply |= 0x08; |
| 311 | | if (card->flag0) |
| 312 | | reply |= 0x10; |
| 269 | if (m_pio_direction_in) reply |= 0x02; |
| 270 | if (m_pio_handshakein) reply |= 0x04; |
| 271 | if (m_pio_sparein) reply |= 0x08; |
| 272 | if (m_flag0) reply |= 0x10; |
| 313 | 273 | // The CTS line is realized as CRU bits |
| 314 | 274 | // Mind that this line is handled as an output going to the remote CTS |
| 315 | | if (card->signals[0] & CTS) |
| 316 | | reply |= 0x20; |
| 317 | | if (card->signals[1] & CTS) |
| 318 | | reply |= 0x40; |
| 319 | | if (card->led) |
| 320 | | reply |= 0x80; |
| 275 | if ((m_signals[0] & CTS)!=0) reply |= 0x20; |
| 276 | if ((m_signals[1] & CTS)!=0) reply |= 0x40; |
| 277 | if (m_led) reply |= 0x80; |
| 321 | 278 | *value = reply; |
| 322 | 279 | return; |
| 323 | 280 | } |
| 324 | 281 | if ((offset & 0x00c0)==0x0040) |
| 325 | 282 | { |
| 326 | | *value = tms9902_cru_r(card->uart[0], offset>>4); |
| 283 | *value = m_uart[0]->cruread(*m_space, offset>>4, 0xff); |
| 327 | 284 | return; |
| 328 | 285 | } |
| 329 | 286 | if ((offset & 0x00c0)==0x0080) |
| 330 | 287 | { |
| 331 | | *value = tms9902_cru_r(card->uart[1], offset>>1); |
| 288 | *value = m_uart[1]->cruread(*m_space, offset>>1, 0xff); |
| 332 | 289 | return; |
| 333 | 290 | } |
| 334 | 291 | } |
| r14513 | r14514 | |
| 337 | 294 | /* |
| 338 | 295 | CRU write |
| 339 | 296 | */ |
| 340 | | static WRITE8_DEVICE_HANDLER( cru_w ) |
| 297 | void ti_rs232_pio_device::cruwrite(offs_t offset, UINT8 data) |
| 341 | 298 | { |
| 342 | | ti_rs232_state *card = get_safe_token(device); |
| 343 | | |
| 344 | | if ((offset & 0xff00)==CRU_BASE) |
| 299 | if ((offset & 0xff00)==m_cru_base) |
| 345 | 300 | { |
| 346 | 301 | if ((offset & 0x00c0)==0x0040) |
| 347 | 302 | { |
| 348 | | tms9902_cru_w(card->uart[0], offset>>1, data); |
| 303 | m_uart[0]->cruwrite(*m_space, offset>>1, data, 0xff); |
| 349 | 304 | return; |
| 350 | 305 | } |
| 351 | 306 | if ((offset & 0x00c0)==0x0080) |
| 352 | 307 | { |
| 353 | | tms9902_cru_w(card->uart[1], offset>>1, data); |
| 308 | m_uart[1]->cruwrite(*m_space, offset>>1, data, 0xff); |
| 354 | 309 | return; |
| 355 | 310 | } |
| 356 | 311 | |
| 357 | | device_image_interface *image = dynamic_cast<device_image_interface *>(card->piodev); |
| 312 | device_image_interface *image = dynamic_cast<device_image_interface *>(m_piodev); |
| 313 | |
| 358 | 314 | int bit = (offset & 0x00ff)>>1; |
| 359 | 315 | switch (bit) |
| 360 | 316 | { |
| 361 | 317 | case 0: |
| 362 | | card->selected = data; |
| 318 | m_selected = (data!=0); |
| 363 | 319 | break; |
| 364 | 320 | |
| 365 | 321 | case 1: |
| 366 | | card->pio_direction = data; |
| 322 | m_pio_direction_in = (data!=0); |
| 367 | 323 | break; |
| 368 | 324 | |
| 369 | 325 | case 2: |
| 370 | | if (data != card->pio_handshakeout) |
| 326 | if ((data!=0) != m_pio_handshakeout) |
| 371 | 327 | { |
| 372 | | card->pio_handshakeout = data; |
| 373 | | if (card->pio_write && card->pio_writable && (!card->pio_direction)) |
| 328 | m_pio_handshakeout = (data!=0); |
| 329 | if (m_pio_write && m_pio_writable && (!m_pio_direction_in)) |
| 374 | 330 | { /* PIO in output mode */ |
| 375 | | if (!card->pio_handshakeout) |
| 331 | if (!m_pio_handshakeout) |
| 376 | 332 | { /* write data strobe */ |
| 377 | 333 | /* write data and acknowledge */ |
| 378 | | UINT8 buf = card->pio_out_buffer; |
| 334 | UINT8 buf = m_pio_out_buffer; |
| 379 | 335 | int ret = image->fwrite(&buf, 1); |
| 380 | 336 | if (ret) |
| 381 | | card->pio_handshakein = 1; |
| 337 | m_pio_handshakein = 1; |
| 382 | 338 | } |
| 383 | 339 | else |
| 384 | 340 | { |
| 385 | 341 | /* end strobe */ |
| 386 | 342 | /* we can write some data: set receiver ready */ |
| 387 | | card->pio_handshakein = 0; |
| 343 | m_pio_handshakein = 0; |
| 388 | 344 | } |
| 389 | 345 | } |
| 390 | | if ((!card->pio_write) && card->pio_readable /*&& pio_direction*/) |
| 346 | if ((!m_pio_write) && m_pio_readable /*&& pio_direction_in*/) |
| 391 | 347 | { /* PIO in input mode */ |
| 392 | | if (!card->pio_handshakeout) |
| 348 | if (!m_pio_handshakeout) |
| 393 | 349 | { /* receiver ready */ |
| 394 | 350 | /* send data and strobe */ |
| 395 | 351 | UINT8 buf; |
| 396 | 352 | if (image->fread(&buf, 1)) |
| 397 | | card->pio_in_buffer = buf; |
| 398 | | card->pio_handshakein = 0; |
| 353 | m_pio_in_buffer = buf; |
| 354 | m_pio_handshakein = 0; |
| 399 | 355 | } |
| 400 | 356 | else |
| 401 | 357 | { |
| 402 | 358 | /* data acknowledge */ |
| 403 | 359 | /* we can send some data: set transmitter ready */ |
| 404 | | card->pio_handshakein = 1; |
| 360 | m_pio_handshakein = 1; |
| 405 | 361 | } |
| 406 | 362 | } |
| 407 | 363 | } |
| 408 | 364 | break; |
| 409 | 365 | |
| 410 | 366 | case 3: |
| 411 | | card->pio_spareout = data; |
| 367 | m_pio_spareout = (data!=0); |
| 412 | 368 | break; |
| 413 | 369 | |
| 414 | 370 | case 4: |
| 415 | | card->flag0 = data; |
| 371 | m_flag0 = (data!=0); |
| 416 | 372 | break; |
| 417 | 373 | |
| 418 | 374 | case 5: |
| 419 | 375 | // Set the CTS line for RS232/1 |
| 420 | | LOG("TI-RS232/1: Setting CTS* via CRU to %d\n", data); |
| 421 | | output_line_state(card->uart[0], CTS, (data==0)? CTS : 0); |
| 376 | if (VERBOSE>5) LOG("TI-RS232/1/3: Setting CTS* via CRU to %d\n", data); |
| 377 | output_line_state(0, CTS, (data==0)? CTS : 0); |
| 422 | 378 | break; |
| 423 | 379 | |
| 424 | 380 | case 6: |
| 425 | 381 | // Set the CTS line for RS232/2 |
| 426 | | LOG("TI-RS232/2: Setting CTS* via CRU to %d\n", data); |
| 427 | | output_line_state(card->uart[1], CTS, (data==0)? CTS : 0); |
| 382 | if (VERBOSE>5) LOG("TI-RS232/2/4: Setting CTS* via CRU to %d\n", data); |
| 383 | output_line_state(1, CTS, (data==0)? CTS : 0); |
| 428 | 384 | break; |
| 429 | 385 | |
| 430 | 386 | case 7: |
| 431 | | card->led = data; |
| 387 | m_led = (data!=0); |
| 432 | 388 | break; |
| 433 | 389 | } |
| 434 | 390 | return; |
| r14513 | r14514 | |
| 438 | 394 | /* |
| 439 | 395 | Memory read |
| 440 | 396 | */ |
| 441 | | static READ8Z_DEVICE_HANDLER( data_rz ) |
| 397 | READ8Z_MEMBER( ti_rs232_pio_device::readz ) |
| 442 | 398 | { |
| 443 | | ti_rs232_state *card = get_safe_token(device); |
| 444 | | |
| 445 | | if (card->senila) |
| 399 | if (m_senila==ASSERT_LINE) |
| 446 | 400 | { |
| 447 | 401 | if (VERBOSE>3) LOG("ti99/rs232: Sensing ILA\n"); |
| 448 | | *value = card->ila; |
| 402 | *value = m_ila; |
| 449 | 403 | // The card ROM must be unselected, or we get two values |
| 450 | 404 | // on the data bus |
| 451 | 405 | |
| 452 | 406 | // Not sure whether this is correct; there is no software that makes |
| 453 | 407 | // use of it |
| 454 | | card->ila = 0; |
| 408 | m_ila = 0; |
| 455 | 409 | } |
| 456 | | if (((offset & card->select_mask)==card->select_value) && card->selected) |
| 410 | if (((offset & m_select_mask)==m_select_value) && m_selected) |
| 457 | 411 | { |
| 458 | 412 | if ((offset & 0x1000)==0x0000) |
| 459 | 413 | { |
| 460 | | *value = card->rom[offset&0x0fff]; |
| 414 | *value = m_dsrrom[offset&0x0fff]; |
| 461 | 415 | } |
| 462 | 416 | else |
| 463 | 417 | { |
| 464 | | *value = card->pio_direction ? card->pio_in_buffer : card->pio_out_buffer; |
| 418 | *value = m_pio_direction_in ? m_pio_in_buffer : m_pio_out_buffer; |
| 465 | 419 | } |
| 466 | 420 | } |
| 467 | 421 | } |
| r14513 | r14514 | |
| 469 | 423 | /* |
| 470 | 424 | Memory write |
| 471 | 425 | */ |
| 472 | | static WRITE8_DEVICE_HANDLER( data_w ) |
| 426 | WRITE8_MEMBER( ti_rs232_pio_device::write ) |
| 473 | 427 | { |
| 474 | | ti_rs232_state *card = get_safe_token(device); |
| 475 | | |
| 476 | | if (((offset & card->select_mask)==card->select_value) && card->selected) |
| 428 | if (((offset & m_select_mask)==m_select_value) && m_selected) |
| 477 | 429 | { |
| 478 | 430 | if ((offset & 0x1001)==0x1000) |
| 479 | 431 | { |
| 480 | | card->pio_out_buffer = data; |
| 432 | m_pio_out_buffer = data; |
| 481 | 433 | } |
| 482 | 434 | } |
| 483 | 435 | } |
| 484 | 436 | |
| 485 | 437 | /**************************************************************************/ |
| 486 | 438 | |
| 487 | | /* |
| 488 | | Propagates the /INT signal of the UARTs to the /INT line of the pbox. |
| 489 | | */ |
| 490 | | static TMS9902_INT_CALLBACK( int_callback ) |
| 491 | | { |
| 492 | | device_t *carddev = device->owner(); |
| 493 | | ti_rs232_state *card = get_safe_token(carddev); |
| 494 | | int senila_bit = (device==card->uart[0])? SENILA_0_BIT : SENILA_1_BIT; |
| 495 | 439 | |
| 496 | | if (state==FALSE) |
| 497 | | card->ila |= senila_bit; |
| 498 | | else |
| 499 | | card->ila &= ~senila_bit; |
| 500 | | |
| 501 | | card->lines.inta(state); |
| 502 | | } |
| 503 | | |
| 504 | 440 | // ========================================================== |
| 505 | 441 | |
| 506 | 442 | /* |
| 507 | 443 | The DTR line of the interface card is wired to the CTS and DSR |
| 508 | 444 | of the UART. |
| 509 | 445 | */ |
| 510 | | static void incoming_dtr(device_t *tms9902, line_state value) |
| 446 | void ti_rs232_pio_device::incoming_dtr(int uartind, line_state value) |
| 511 | 447 | { |
| 512 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 513 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 514 | | |
| 515 | 448 | if (VERBOSE>2) LOG("TI-RS232/%d: incoming DTR = %d\n", uartind+1, (value==ASSERT_LINE)? 1:0); |
| 516 | 449 | |
| 517 | | tms9902_rcv_cts(tms9902, value); |
| 518 | | tms9902_rcv_dsr(tms9902, value); |
| 450 | m_uart[uartind]->rcv_cts(value); |
| 451 | m_uart[uartind]->rcv_dsr(value); |
| 519 | 452 | } |
| 520 | 453 | |
| 521 | 454 | /* |
| 522 | 455 | Data transmission |
| 523 | 456 | */ |
| 524 | | static void transmit_data(device_t *tms9902, UINT8 value) |
| 457 | void ti_rs232_pio_device::transmit_data(int uartind, UINT8 value) |
| 525 | 458 | { |
| 526 | 459 | UINT8 buf = value; |
| 527 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 528 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 529 | 460 | |
| 530 | 461 | device_image_interface *serial; |
| 531 | | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 462 | serial = dynamic_cast<device_image_interface *>(m_serdev[uartind]); |
| 532 | 463 | if (!serial->exists()) |
| 533 | 464 | { |
| 534 | 465 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| r14513 | r14514 | |
| 583 | 514 | +12V 6 -| |-( 6) <--- DSR |
| 584 | 515 | nc 4 -----------( 8) <--- DCD |
| 585 | 516 | */ |
| 586 | | static UINT8 map_lines_out(device_t *carddev, int uartind, UINT8 value) |
| 517 | UINT8 ti_rs232_pio_device::map_lines_out(int uartind, UINT8 value) |
| 587 | 518 | { |
| 588 | 519 | UINT8 ret = 0; |
| 589 | | int mapping = input_port_read(carddev->machine(), "SERIALMAP"); |
| 520 | int mapping = input_port_read(*this, "SERIALMAP"); |
| 590 | 521 | |
| 591 | 522 | // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 592 | 523 | |
| r14513 | r14514 | |
| 655 | 586 | return ret; |
| 656 | 587 | } |
| 657 | 588 | |
| 658 | | static UINT8 map_lines_in(device_t *carddev, int uartind, UINT8 value) |
| 589 | UINT8 ti_rs232_pio_device::map_lines_in(int uartind, UINT8 value) |
| 659 | 590 | { |
| 660 | 591 | UINT8 ret = 0; |
| 661 | | int mapping = input_port_read(carddev->machine(), "SERIALMAP"); |
| 592 | int mapping = input_port_read(*this, "SERIALMAP"); |
| 662 | 593 | |
| 663 | 594 | // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 664 | 595 | |
| r14513 | r14514 | |
| 750 | 681 | serial bridge must stop delivering data bytes until the handshake opens the |
| 751 | 682 | channel again. |
| 752 | 683 | */ |
| 753 | | static void receive_data_or_line_state(device_t *tms9902, double baudpoll) |
| 684 | void ti_rs232_pio_device::receive_data_or_line_state(int uartind) |
| 754 | 685 | { |
| 755 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 756 | 686 | device_image_interface *serial; |
| 757 | 687 | UINT8 buffer; |
| 758 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 759 | 688 | int len = 0; |
| 760 | 689 | |
| 761 | | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 690 | serial = dynamic_cast<device_image_interface *>(m_serdev[uartind]); |
| 762 | 691 | |
| 763 | 692 | if (!serial->exists()) |
| 764 | 693 | { |
| r14513 | r14514 | |
| 766 | 695 | return; |
| 767 | 696 | } |
| 768 | 697 | |
| 698 | double baudpoll = m_uart[uartind]->get_baudpoll(); |
| 699 | |
| 769 | 700 | // If more than the minimum waiting time since the last data byte has |
| 770 | 701 | // elapsed, we can get a new value. |
| 771 | | if (card->time_hold[uartind] > 1.0) |
| 702 | if (m_time_hold[uartind] > 1.0) |
| 772 | 703 | { |
| 773 | 704 | len = serial->fread(&buffer, 1); |
| 774 | 705 | if (len==0) return; |
| r14513 | r14514 | |
| 776 | 707 | else |
| 777 | 708 | { |
| 778 | 709 | // number of polls has not yet elapsed; we have to wait. |
| 779 | | card->time_hold[uartind] += baudpoll; |
| 710 | m_time_hold[uartind] += baudpoll; |
| 780 | 711 | return; |
| 781 | 712 | } |
| 782 | 713 | |
| 783 | 714 | // No config parameters here, only data or line setting |
| 784 | | switch (card->recv_mode[uartind]) |
| 715 | switch (m_recv_mode[uartind]) |
| 785 | 716 | { |
| 786 | 717 | case RECV_MODE_NORMAL: |
| 787 | 718 | if (buffer==0x1b) |
| 788 | 719 | { |
| 789 | 720 | if (VERBOSE>2) LOG("TI-RS232/%d: received: %c <%02x>, switch to ESC mode\n", uartind+1, buffer, buffer); |
| 790 | | card->recv_mode[uartind] = RECV_MODE_ESC; |
| 721 | m_recv_mode[uartind] = RECV_MODE_ESC; |
| 791 | 722 | } |
| 792 | 723 | else |
| 793 | 724 | { |
| 794 | 725 | if (VERBOSE>3) LOG("TI-RS232/%d: received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 795 | | tms9902_rcv_data(tms9902, buffer); |
| 796 | | card->time_hold[uartind] = 0.0; |
| 726 | m_uart[uartind]->rcv_data(buffer); |
| 727 | m_time_hold[uartind] = 0.0; |
| 797 | 728 | } |
| 798 | 729 | break; |
| 799 | 730 | case RECV_MODE_ESC: |
| 800 | 731 | if (buffer==0x1b) |
| 801 | 732 | { |
| 802 | | card->recv_mode[uartind] = RECV_MODE_NORMAL; |
| 733 | m_recv_mode[uartind] = RECV_MODE_NORMAL; |
| 803 | 734 | if (VERBOSE>2) LOG("TI-RS232/%d: leaving ESC mode, received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 804 | | tms9902_rcv_data(tms9902, buffer); |
| 805 | | card->time_hold[uartind] = 0.0; |
| 735 | m_uart[uartind]->rcv_data(buffer); |
| 736 | m_time_hold[uartind] = 0.0; |
| 806 | 737 | } |
| 807 | 738 | else |
| 808 | 739 | { |
| r14513 | r14514 | |
| 811 | 742 | if (buffer != 1) |
| 812 | 743 | { |
| 813 | 744 | LOG("TI-RS232/%d: expected length 1 but got %02x, leaving ESC mode.\n", uartind+1, buffer); |
| 814 | | card->recv_mode[uartind] = RECV_MODE_NORMAL; |
| 745 | m_recv_mode[uartind] = RECV_MODE_NORMAL; |
| 815 | 746 | } |
| 816 | 747 | else |
| 817 | | card->recv_mode[uartind] = RECV_MODE_ESC_LINES; |
| 748 | m_recv_mode[uartind] = RECV_MODE_ESC_LINES; |
| 818 | 749 | } |
| 819 | 750 | break; |
| 820 | 751 | |
| r14513 | r14514 | |
| 824 | 755 | if (buffer & EXCEPT) |
| 825 | 756 | { |
| 826 | 757 | // Exception states: BRK, FRMERR, PARERR |
| 827 | | tms9902_rcv_break(tms9902, ((buffer & BRK)!=0)); |
| 758 | m_uart[uartind]->rcv_break(((buffer & BRK)!=0)); |
| 828 | 759 | |
| 829 | | if (buffer & FRMERR) |
| 830 | | tms9902_rcv_framing_error(tms9902); |
| 831 | | if (buffer & PARERR) |
| 832 | | tms9902_rcv_parity_error(tms9902); |
| 760 | if (buffer & FRMERR) m_uart[uartind]->rcv_framing_error(); |
| 761 | if (buffer & PARERR) m_uart[uartind]->rcv_parity_error(); |
| 833 | 762 | } |
| 834 | 763 | else |
| 835 | 764 | { |
| 836 | | buffer = map_lines_in(tms9902->owner(), uartind, buffer); |
| 765 | buffer = map_lines_in(uartind, buffer); |
| 837 | 766 | if (VERBOSE>2) LOG("TI-RS232/%d: received (remapped) <%02x> in ESC mode\n", uartind+1, buffer); |
| 838 | 767 | |
| 839 | 768 | // The DTR line on the RS232 connector of the board is wired to both the |
| 840 | 769 | // CTS and the DSR pin of the TMS9902 |
| 841 | 770 | // Apart from the data line, DTR is the only input line |
| 842 | | incoming_dtr(tms9902, (buffer & DTR)? ASSERT_LINE : CLEAR_LINE); |
| 771 | incoming_dtr(uartind, (buffer & DTR)? ASSERT_LINE : CLEAR_LINE); |
| 843 | 772 | } |
| 844 | 773 | |
| 845 | | card->recv_mode[uartind] = RECV_MODE_NORMAL; |
| 774 | m_recv_mode[uartind] = RECV_MODE_NORMAL; |
| 846 | 775 | break; |
| 847 | 776 | |
| 848 | 777 | default: |
| 849 | | LOG("TI-RS232/%d: unknown mode: %d\n", uartind+1, card->recv_mode[uartind]); |
| 778 | if (VERBOSE>1) LOG("TI-RS232/%d: unknown mode: %d\n", uartind+1, m_recv_mode[uartind]); |
| 850 | 779 | } |
| 851 | 780 | } |
| 852 | 781 | |
| 853 | | static TMS9902_RCV_CALLBACK( rcv_callback ) |
| 854 | | { |
| 855 | | // Called from the UART when it wants to receive a character |
| 856 | | // However, characters are not passed to it at this point |
| 857 | | // Instead, we check for signal line change or data transmission |
| 858 | | // and call the respective function |
| 859 | | receive_data_or_line_state(device, baudpoll); |
| 860 | | } |
| 861 | | |
| 862 | | static TMS9902_XMIT_CALLBACK( xmit_callback ) |
| 863 | | { |
| 864 | | transmit_data(device, (UINT8)data); |
| 865 | | } |
| 866 | | |
| 867 | 782 | /* |
| 868 | 783 | Control operations like configuration or line changes |
| 869 | 784 | */ |
| 870 | | static void configure_interface(device_t *tms9902, int type, int value) |
| 785 | void ti_rs232_pio_device::configure_interface(int uartind, int type, int value) |
| 871 | 786 | { |
| 872 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 873 | 787 | UINT8 bufctrl[4]; |
| 874 | 788 | device_image_interface *serial; |
| 875 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 876 | 789 | UINT8 esc = ESC; |
| 877 | 790 | |
| 878 | | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 791 | serial = dynamic_cast<device_image_interface *>(m_serdev[uartind]); |
| 879 | 792 | |
| 880 | 793 | if (!serial->exists()) |
| 881 | 794 | { |
| r14513 | r14514 | |
| 928 | 841 | serial->fwrite(bufctrl, bufctrl[0]+1); |
| 929 | 842 | } |
| 930 | 843 | |
| 931 | | static void set_bit(device_t *device, int uartind, int line, int value) |
| 844 | void ti_rs232_pio_device::set_bit(int uartind, int line, int value) |
| 932 | 845 | { |
| 933 | | ti_rs232_state *card = get_safe_token(device); |
| 934 | 846 | if (VERBOSE>5) |
| 935 | 847 | { |
| 936 | 848 | switch (line) |
| 937 | 849 | { |
| 938 | | case CTS: LOG("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 939 | | case DCD: LOG("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 940 | | case BRK: LOG("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 850 | case CTS: LOG("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value!=0)? "asserted" : "cleared"); break; |
| 851 | case DCD: LOG("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value!=0)? "asserted" : "cleared"); break; |
| 852 | case BRK: LOG("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value!=0)? "asserted" : "cleared"); break; |
| 941 | 853 | } |
| 942 | 854 | } |
| 943 | 855 | |
| 944 | | if (value) |
| 945 | | card->signals[uartind] |= line; |
| 946 | | else |
| 947 | | card->signals[uartind] &= ~line; |
| 856 | if (value!=0) m_signals[uartind] |= line; |
| 857 | else m_signals[uartind] &= ~line; |
| 948 | 858 | } |
| 949 | 859 | |
| 950 | 860 | /* |
| 951 | 861 | Line changes |
| 952 | 862 | */ |
| 953 | | static void output_exception(device_t *tms9902, int param, UINT8 value) |
| 863 | void ti_rs232_pio_device::output_exception(int uartind, int param, UINT8 value) |
| 954 | 864 | { |
| 955 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 956 | 865 | device_image_interface *serial; |
| 957 | 866 | UINT8 bufctrl[2]; |
| 958 | 867 | UINT8 esc = ESC; |
| 959 | 868 | |
| 960 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 869 | serial = dynamic_cast<device_image_interface *>(m_serdev[uartind]); |
| 961 | 870 | |
| 962 | | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 963 | | |
| 964 | 871 | if (!serial->exists()) |
| 965 | 872 | { |
| 966 | 873 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| r14513 | r14514 | |
| 979 | 886 | /* |
| 980 | 887 | Line changes |
| 981 | 888 | */ |
| 982 | | static void output_line_state(device_t *tms9902, int mask, UINT8 value) |
| 889 | void ti_rs232_pio_device::output_line_state(int uartind, int mask, UINT8 value) |
| 983 | 890 | { |
| 984 | | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 985 | 891 | device_image_interface *serial; |
| 986 | 892 | UINT8 bufctrl[2]; |
| 987 | 893 | UINT8 esc = ESC; |
| 988 | 894 | |
| 989 | | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 895 | serial = dynamic_cast<device_image_interface *>(m_serdev[uartind]); |
| 990 | 896 | |
| 991 | | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 992 | | |
| 993 | 897 | if (!serial->exists()) |
| 994 | 898 | { |
| 995 | 899 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| r14513 | r14514 | |
| 1002 | 906 | bufctrl[0] = 1; |
| 1003 | 907 | |
| 1004 | 908 | // The CTS line (coming from a CRU bit) is connected to the CTS pin |
| 1005 | | if (mask & CTS) set_bit(tms9902->owner(), uartind, CTS, value & CTS); |
| 909 | if (mask & CTS) set_bit(uartind, CTS, value & CTS); |
| 1006 | 910 | |
| 1007 | 911 | // The RTS line (from 9902) is connected to the DCD pin |
| 1008 | | if (mask & RTS) set_bit(tms9902->owner(), uartind, DCD, value & RTS); |
| 912 | if (mask & RTS) set_bit(uartind, DCD, value & RTS); |
| 1009 | 913 | |
| 1010 | 914 | // The DSR pin is hardwired to +5V |
| 1011 | | set_bit(tms9902->owner(), uartind, DSR, 1); |
| 915 | set_bit(uartind, DSR, 1); |
| 1012 | 916 | |
| 1013 | 917 | // As of here, the lines are set according to the schematics of the |
| 1014 | 918 | // serial interface. |
| r14513 | r14514 | |
| 1016 | 920 | // Now translate the signals of the board to those of a DTE-like device |
| 1017 | 921 | // so that we can pass the signal to the real PC serial interface |
| 1018 | 922 | // (can be imagined as if we emulated the cable) |
| 1019 | | bufctrl[1] = map_lines_out(tms9902->owner(), uartind, card->signals[uartind]); |
| 923 | bufctrl[1] = map_lines_out(uartind, m_signals[uartind]); |
| 1020 | 924 | serial->fwrite(bufctrl, 2); |
| 1021 | 925 | } |
| 1022 | 926 | |
| 1023 | | static TMS9902_CTRL_CALLBACK( ctrl_callback ) |
| 927 | /*********************************************************************** |
| 928 | callbacks |
| 929 | ************************************************************************/ |
| 930 | /* |
| 931 | Propagates the /INT signal of the UARTs to the /INT line of the pbox. |
| 932 | */ |
| 933 | WRITE_LINE_MEMBER( ti_rs232_pio_device::int0_callback ) |
| 1024 | 934 | { |
| 1025 | | switch (type) |
| 1026 | | { |
| 1027 | | case CONFIG: |
| 1028 | | configure_interface(device, param, value); break; |
| 1029 | | case EXCEPT: |
| 1030 | | output_exception(device, param, value); break; |
| 1031 | | default: |
| 1032 | | output_line_state(device, param, value); |
| 1033 | | } |
| 1034 | | } |
| 935 | int senila_bit = SENILA_0_BIT; |
| 1035 | 936 | |
| 937 | if (state==ASSERT_LINE) m_ila |= senila_bit; |
| 938 | else m_ila &= ~senila_bit; |
| 1036 | 939 | |
| 1037 | | static WRITE_LINE_DEVICE_HANDLER( senila ) |
| 1038 | | { |
| 1039 | | // put the value on the data bus. We store it in a state variable. |
| 1040 | | ti_rs232_state *card = get_safe_token(device); |
| 1041 | | if (VERBOSE>3) LOG("TI-RS232/1-2: Setting SENILA=%d\n", state); |
| 1042 | | card->senila = state; |
| 940 | m_slot->set_inta(state); |
| 1043 | 941 | } |
| 1044 | 942 | |
| 1045 | | static const tms9902_interface tms9902_params = |
| 943 | WRITE_LINE_MEMBER( ti_rs232_pio_device::int1_callback ) |
| 1046 | 944 | { |
| 1047 | | 3000000., /* clock rate (3MHz) */ |
| 1048 | | int_callback, /* called when interrupt pin state changes */ |
| 1049 | | rcv_callback, /* called when a character is received */ |
| 1050 | | xmit_callback, /* called when a character is transmitted */ |
| 1051 | | ctrl_callback |
| 1052 | | }; |
| 945 | int senila_bit = SENILA_1_BIT; |
| 1053 | 946 | |
| 1054 | | static const ti99_peb_card tirs232_card = |
| 1055 | | { |
| 1056 | | data_rz, data_w, // memory access read/write |
| 1057 | | cru_rz, cru_w, // CRU access |
| 1058 | | senila, NULL, // SENILA/B access |
| 1059 | | NULL, NULL // 16 bit access (none here) |
| 1060 | | }; |
| 947 | if (state==ASSERT_LINE) m_ila |= senila_bit; |
| 948 | else m_ila &= ~senila_bit; |
| 1061 | 949 | |
| 950 | m_slot->set_inta(state); |
| 951 | } |
| 952 | |
| 1062 | 953 | /* |
| 1063 | | Defines the serial serdev. |
| 954 | Called from the UART when it wants to receive a character |
| 955 | However, characters are not passed to it at this point |
| 956 | Instead, we check for signal line change or data transmission |
| 957 | and call the respective function |
| 1064 | 958 | */ |
| 1065 | | DEVICE_GET_INFO( ti99_rs232_serdev ) |
| 959 | WRITE_LINE_MEMBER( ti_rs232_pio_device::rcv0_callback ) |
| 1066 | 960 | { |
| 1067 | | switch ( state ) |
| 1068 | | { |
| 1069 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1070 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_SERIAL; break; |
| 1071 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1072 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 1073 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; |
| 961 | receive_data_or_line_state(0); |
| 962 | } |
| 1074 | 963 | |
| 1075 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ti99_rs232_serdev ); break; |
| 1076 | | // case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ti99_rs232_serdev ); break; |
| 1077 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME( ti99_rs232_serdev ); break; |
| 1078 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME( ti99_rs232_serdev ); break; |
| 1079 | | case DEVINFO_STR_NAME: strcpy( info->s, "TI99 RS232 attached serial device"); break; |
| 1080 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Peripheral expansion"); break; |
| 1081 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, ""); break; |
| 1082 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1083 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1084 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 1085 | | } |
| 964 | WRITE_LINE_MEMBER( ti_rs232_pio_device::rcv1_callback ) |
| 965 | { |
| 966 | receive_data_or_line_state(1); |
| 1086 | 967 | } |
| 1087 | 968 | |
| 1088 | | /* |
| 1089 | | Defines the PIO (parallel IO) serdev |
| 1090 | | */ |
| 1091 | | DEVICE_GET_INFO( ti99_piodev ) |
| 969 | WRITE8_MEMBER( ti_rs232_pio_device::xmit0_callback ) |
| 1092 | 970 | { |
| 1093 | | switch ( state ) |
| 1094 | | { |
| 1095 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1096 | | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_PARALLEL; break; |
| 1097 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 1098 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 1099 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; |
| 971 | transmit_data(0, data); |
| 972 | } |
| 1100 | 973 | |
| 1101 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ti99_piodev ); break; |
| 1102 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME( ti99_piodev ); break; |
| 1103 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(ti99_piodev ); break; |
| 1104 | | case DEVINFO_STR_NAME: strcpy( info->s, "TI99 PIO attached device"); break; |
| 1105 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Peripheral expansion"); break; |
| 1106 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, ""); break; |
| 1107 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1108 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1109 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 974 | WRITE8_MEMBER( ti_rs232_pio_device::xmit1_callback ) |
| 975 | { |
| 976 | transmit_data(1, data); |
| 977 | } |
| 978 | |
| 979 | void ti_rs232_pio_device::ctrl_callback(int uartind, int offset, UINT8 data) |
| 980 | { |
| 981 | if ((offset & CONFIG)!=0) |
| 982 | { |
| 983 | // We cannot pass the configuration data as they need more than 8 bits. |
| 984 | // Could be done by a write16 function as well. |
| 985 | configure_interface(uartind, data, m_uart[uartind]->get_config_value()); |
| 1110 | 986 | } |
| 987 | else |
| 988 | { |
| 989 | if ((offset & EXCEPT)!=0) |
| 990 | { |
| 991 | output_exception(uartind, offset & ~EXCEPT, data); |
| 992 | } |
| 993 | else |
| 994 | { |
| 995 | output_line_state(uartind, offset, data); |
| 996 | } |
| 997 | } |
| 1111 | 998 | } |
| 1112 | 999 | |
| 1113 | | DECLARE_LEGACY_IMAGE_DEVICE(TI99_RS232, ti99_rs232_serdev); |
| 1114 | | DEFINE_LEGACY_IMAGE_DEVICE(TI99_RS232, ti99_rs232_serdev); |
| 1115 | | DECLARE_LEGACY_IMAGE_DEVICE(TI99_PIO, ti99_piodev); |
| 1116 | | DEFINE_LEGACY_IMAGE_DEVICE(TI99_PIO, ti99_piodev); |
| 1117 | | |
| 1118 | | static DEVICE_START( ti_rs232 ) |
| 1000 | WRITE8_MEMBER( ti_rs232_pio_device::ctrl0_callback ) |
| 1119 | 1001 | { |
| 1120 | | ti_rs232_state *card = get_safe_token(device); |
| 1121 | | peb_callback_if *topeb = (peb_callback_if *)device->static_config(); |
| 1002 | ctrl_callback(0, offset, data); |
| 1003 | } |
| 1122 | 1004 | |
| 1123 | | astring region(device->tag(), ":", ser_region); |
| 1124 | | card->rom = device->machine().region(region.cstr())->base(); |
| 1125 | | card->lines.inta.resolve(topeb->inta, *device); |
| 1126 | | // READY and INTB are not used |
| 1127 | | card->uart[0] = device->subdevice("tms9902_0"); |
| 1128 | | card->uart[1] = device->subdevice("tms9902_1"); |
| 1129 | | card->serdev[0] = device->subdevice("serdev0"); |
| 1130 | | card->serdev[1] = device->subdevice("serdev1"); |
| 1131 | | card->piodev = device->subdevice("piodev"); |
| 1005 | WRITE8_MEMBER( ti_rs232_pio_device::ctrl1_callback ) |
| 1006 | { |
| 1007 | ctrl_callback(1, offset, data); |
| 1132 | 1008 | } |
| 1133 | 1009 | |
| 1134 | | static DEVICE_STOP( ti_rs232 ) |
| 1010 | static const tms9902_interface tms9902_params0 = |
| 1135 | 1011 | { |
| 1012 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, int0_callback), /* called when interrupt pin state changes */ |
| 1013 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, rcv0_callback), /* called when a character is received */ |
| 1014 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, xmit0_callback), /* called when a character is transmitted */ |
| 1015 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, ctrl0_callback) |
| 1016 | }; |
| 1017 | |
| 1018 | static const tms9902_interface tms9902_params1 = |
| 1019 | { |
| 1020 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, int1_callback), /* called when interrupt pin state changes */ |
| 1021 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, rcv1_callback), /* called when a character is received */ |
| 1022 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, xmit1_callback), /* called when a character is transmitted */ |
| 1023 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, ctrl1_callback) |
| 1024 | }; |
| 1025 | |
| 1026 | void ti_rs232_pio_device::device_start() |
| 1027 | { |
| 1028 | m_dsrrom = subregion(DSRROM)->base(); |
| 1029 | m_uart[0] = subdevice<tms9902_device>("tms9902_0"); |
| 1030 | m_uart[1] = subdevice<tms9902_device>("tms9902_1"); |
| 1031 | m_serdev[0] = subdevice<ti_rs232_attached_device>("serdev0"); |
| 1032 | m_serdev[1] = subdevice<ti_rs232_attached_device>("serdev1"); |
| 1033 | m_piodev = subdevice<ti_pio_attached_device>("piodev"); |
| 1136 | 1034 | } |
| 1137 | 1035 | |
| 1138 | | static DEVICE_RESET( ti_rs232 ) |
| 1036 | void ti_rs232_pio_device::device_reset() |
| 1139 | 1037 | { |
| 1140 | | ti_rs232_state *card = get_safe_token(device); |
| 1141 | | /* Register the card */ |
| 1142 | | device_t *peb = device->owner(); |
| 1038 | m_pio_direction_in = false; |
| 1039 | m_pio_handshakeout = false; |
| 1040 | m_pio_spareout = false; |
| 1041 | m_flag0 = false; |
| 1143 | 1042 | |
| 1144 | | if (input_port_read(device->machine(), "SERIAL")==SERIAL_TI) |
| 1145 | | { |
| 1146 | | int success = mount_card(peb, device, &tirs232_card, get_pebcard_config(device)->slot); |
| 1147 | | if (!success) return; |
| 1043 | set_bit(0, CTS, 0); |
| 1044 | set_bit(1, CTS, 0); |
| 1148 | 1045 | |
| 1149 | | card->pio_direction = 0; |
| 1150 | | card->pio_handshakeout = 0; |
| 1151 | | card->pio_spareout = 0; |
| 1152 | | card->flag0 = 0; |
| 1046 | m_led = false; |
| 1047 | m_pio_write = true; |
| 1048 | m_recv_mode[0] = RECV_MODE_NORMAL; |
| 1049 | m_recv_mode[1] = RECV_MODE_NORMAL; |
| 1153 | 1050 | |
| 1154 | | set_bit(device, 0, CTS, 0); |
| 1155 | | set_bit(device, 1, CTS, 0); |
| 1051 | if (m_genmod) |
| 1052 | { |
| 1053 | m_select_mask = 0x1fe000; |
| 1054 | m_select_value = 0x174000; |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | m_select_mask = 0x7e000; |
| 1059 | m_select_value = 0x74000; |
| 1060 | } |
| 1156 | 1061 | |
| 1157 | | card->led = 0; |
| 1158 | | card->pio_write = 1; |
| 1159 | | card->recv_mode[0] = RECV_MODE_NORMAL; |
| 1160 | | card->recv_mode[1] = RECV_MODE_NORMAL; |
| 1062 | m_space = machine().device("maincpu")->memory().space(AS_IO); |
| 1063 | m_selected = false; |
| 1161 | 1064 | |
| 1162 | | card->select_mask = 0x7e000; |
| 1163 | | card->select_value = 0x74000; |
| 1065 | m_cru_base = (input_port_read(*this, "CRURS232")==0)? 0x1300 : 0x1500; |
| 1164 | 1066 | |
| 1165 | | card->time_hold[0] = card->time_hold[1] = 0.0; |
| 1067 | m_time_hold[0] = m_time_hold[1] = 0.0; |
| 1166 | 1068 | |
| 1167 | 1069 | // The GenMod modification changes the address bus width of the Geneve. |
| 1168 | 1070 | // All peripheral cards need to be manually modified to properly decode |
| 1169 | 1071 | // the wider address. The next lines perform this soldering job |
| 1170 | 1072 | // automagically. |
| 1171 | | if (input_port_read(device->machine(), "MODE")==GENMOD) |
| 1172 | | { |
| 1173 | | // GenMod card modification |
| 1174 | | card->select_mask = 0x1fe000; |
| 1175 | | card->select_value = 0x174000; |
| 1176 | | } |
| 1177 | | } |
| 1073 | /* if (input_port_read(device->machine(), "MODE")==GENMOD) |
| 1074 | { |
| 1075 | // GenMod card modification |
| 1076 | card->select_mask = 0x1fe000; |
| 1077 | card->select_value = 0x174000; |
| 1078 | }*/ |
| 1178 | 1079 | } |
| 1179 | 1080 | |
| 1180 | 1081 | static MACHINE_CONFIG_FRAGMENT( ti_rs232 ) |
| 1181 | | MCFG_TMS9902_ADD("tms9902_0", tms9902_params) |
| 1182 | | MCFG_TMS9902_ADD("tms9902_1", tms9902_params) |
| 1183 | | MCFG_DEVICE_ADD("serdev0", TI99_RS232, 0) |
| 1184 | | MCFG_DEVICE_ADD("serdev1", TI99_RS232, 0) |
| 1185 | | MCFG_DEVICE_ADD("piodev", TI99_PIO, 0) |
| 1082 | MCFG_TMS9902_ADD("tms9902_0", tms9902_params0, 3000000) |
| 1083 | MCFG_TMS9902_ADD("tms9902_1", tms9902_params1, 3000000) |
| 1084 | MCFG_DEVICE_ADD("serdev0", TI99_RS232_DEV, 0) |
| 1085 | MCFG_DEVICE_ADD("serdev1", TI99_RS232_DEV, 0) |
| 1086 | MCFG_DEVICE_ADD("piodev", TI99_PIO_DEV, 0) |
| 1186 | 1087 | MACHINE_CONFIG_END |
| 1187 | 1088 | |
| 1188 | 1089 | ROM_START( ti_rs232 ) |
| 1189 | | ROM_REGION(0x1000, ser_region, 0) |
| 1190 | | ROM_LOAD_OPTIONAL("rs232.bin", 0x0000, 0x1000, CRC(eab382fb) SHA1(ee609a18a21f1a3ddab334e8798d5f2a0fcefa91)) /* TI rs232 DSR ROM */ |
| 1090 | ROM_REGION(0x1000, DSRROM, 0) |
| 1091 | ROM_LOAD("rs232.bin", 0x0000, 0x1000, CRC(eab382fb) SHA1(ee609a18a21f1a3ddab334e8798d5f2a0fcefa91)) /* TI rs232 DSR ROM */ |
| 1191 | 1092 | ROM_END |
| 1192 | 1093 | |
| 1193 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 1094 | INPUT_PORTS_START( ti_rs232 ) |
| 1095 | PORT_START( "CRURS232" ) |
| 1096 | PORT_DIPNAME( 0x01, 0x00, "TI-RS232 CRU base" ) |
| 1097 | PORT_DIPSETTING( 0x00, "1300" ) |
| 1098 | PORT_DIPSETTING( 0x00, "1500" ) |
| 1194 | 1099 | |
| 1195 | | #define DEVTEMPLATE_ID(p,s) p##ti_rs232##s |
| 1196 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_INLINE_CONFIG | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG |
| 1197 | | #define DEVTEMPLATE_NAME "TI99 RS232/PIO interface card" |
| 1198 | | #define DEVTEMPLATE_SHORTNAME "ti99rs232" |
| 1199 | | #define DEVTEMPLATE_FAMILY "Peripheral expansion" |
| 1200 | | #include "devtempl.h" |
| 1100 | PORT_START( "SERIALMAP" ) |
| 1101 | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) |
| 1102 | PORT_CONFSETTING( 0x00, "6-20" ) |
| 1103 | PORT_CONFSETTING( 0x01, "8-20" ) |
| 1104 | PORT_CONFSETTING( 0x02, "5-20" ) |
| 1105 | INPUT_PORTS_END |
| 1201 | 1106 | |
| 1202 | | DEFINE_LEGACY_DEVICE( TIRS232, ti_rs232 ); |
| 1107 | machine_config_constructor ti_rs232_pio_device::device_mconfig_additions() const |
| 1108 | { |
| 1109 | return MACHINE_CONFIG_NAME( ti_rs232 ); |
| 1110 | } |
| 1203 | 1111 | |
| 1112 | const rom_entry *ti_rs232_pio_device::device_rom_region() const |
| 1113 | { |
| 1114 | return ROM_NAME( ti_rs232 ); |
| 1115 | } |
| 1116 | |
| 1117 | ioport_constructor ti_rs232_pio_device::device_input_ports() const |
| 1118 | { |
| 1119 | return INPUT_PORTS_NAME(ti_rs232); |
| 1120 | } |
| 1121 | |
| 1122 | const device_type TI99_RS232 = &device_creator<ti_rs232_pio_device>; |
| 1123 | const device_type TI99_RS232_DEV = &device_creator<ti_rs232_attached_device>; |
| 1124 | const device_type TI99_PIO_DEV = &device_creator<ti_pio_attached_device>; |
| 1125 | |
src/mess/machine/ti99/peribox.c
| r14513 | r14514 | |
| 1 | | /* |
| 2 | | Peripheral expansion bus support. |
| 1 | /**************************************************************************** |
| 3 | 2 | |
| 3 | Peripheral expansion system |
| 4 | |
| 4 | 5 | The ti-99/4, ti-99/4a, ti computer 99/8, myarc geneve, and snug sgcpu |
| 5 | 6 | 99/4p systems all feature a bus connector that enables the connection of |
| 6 | 7 | extension cards. (Although the hexbus is the preferred bus to add |
| r14513 | r14514 | |
| 11 | 12 | While a few extension cards connect to the side bus connector of the |
| 12 | 13 | ti-99/4(a) console directly, most extension cards were designed to be |
| 13 | 14 | inserted in a PEB instead. The PEB (Peripheral Expansion Box) is a big box |
| 14 | | with an alimentation, a few bus drivers, and several card slots, that |
| 15 | with power supply, a few bus drivers, and several card slots, that |
| 15 | 16 | connects to the ti-99/4(a) side port. The reason for using a PEB is that |
| 16 | 17 | daisy-chaining many modules caused the system to be unreliable due to the |
| 17 | 18 | noise produced by the successive contacts. (As a matter of fact, TI |
| r14513 | r14514 | |
| 21 | 22 | the introduction of the PEB, probably because TI wanted the speech |
| 22 | 23 | synthesizer to be a cheap extension, and the PEB was not cheap.) |
| 23 | 24 | |
| 24 | | June 2010: Reimplemented using device structure (MZ) (obsoletes 99_peb.c) |
| 25 | 25 | |
| 26 | | Slots: |
| 26 | =================## connection cable to console |
| 27 | || |
| 28 | || |
| 29 | +--------------+----+----+----+----+----+----+----+----+------------+ |
| 30 | | | S | S | S | S | S | S | S | S : | |
| 31 | | | L | L | L | L | L | L | L | L : | |
| 32 | | Power | O | O | O | O | O | O | O | O : Floppy | |
| 33 | | unit | T | T | T | T | T | T | T | T | drive | |
| 34 | | and | | | | | | | | | compartment| |
| 35 | | ventilation | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | |
| 36 | | | | | | | | | | | 1 full hgt | |
| 37 | | | | | | | | | | | or | |
| 38 | | | | | | | | | | | 2 "slim" | |
| 39 | | | | | | | | |LED |LED | | |
| 40 | | +----+----+----+----+----+----+-|--+-|--+ | |
| 41 | | : seen from above | | | | |
| 42 | +--------------+-------------------------------O----O---------------+ |
| 27 | 43 | |
| 44 | All slots are connected in parallel with all signal lines. The cards |
| 45 | must be equipped with bus drivers (244/245) and are usually activated |
| 46 | by turning a CRU bit on (except for the memory expansions which are |
| 47 | always active). |
| 48 | |
| 49 | This is emulation in exactly the same way. The data coming from the |
| 50 | console is propagated to all slots, and each card decides whether to |
| 51 | react or not. Similarly, for read operations, all cards are checked, |
| 52 | and only the active cards actually put a value on the data bus |
| 53 | (we do this using the bus8z_device; see ti99defs.h). |
| 54 | |
| 55 | Slot 1 is usually reserved for the "Flex cable interface" when connecting |
| 56 | a TI-99/4(A)/8 console. Also, the Geneve is put into slot 1. We therefore |
| 57 | do not offer peb:slot1. Slot 8 is usually used for floppy controllers |
| 58 | as there is a passthrough for cables. |
| 59 | |
| 60 | |
| 61 | Slots: |
| 62 | |
| 28 | 63 | REAR |
| 29 | 64 | +8V 1||2 +8V |
| 30 | 65 | GND 3||4 READY |
| r14513 | r14514 | |
| 61 | 96 | < from box to console |
| 62 | 97 | > from console into box |
| 63 | 98 | |
| 64 | | READYA < System ready (goes to READY, 10K pull-up to +5V) A low level puts the cpu on hold. |
| 65 | | RESET* > System reset (active low) |
| 66 | | SCLK nc System clock (not connected in interface card) |
| 67 | | LCP* nc CPU indicator 1=TI99 0=2nd generation (not connected in interface card) |
| 68 | | BOOTPG* nc ? |
| 69 | | AUDIO < Input audio (to AUDIOIN in console) |
| 70 | | RDBENA* < Active low: enable flex cable data bus drivers (1K pull-up) |
| 71 | | PCBEN H PCB enable for burn-in (always High) |
| 72 | | HOLD* H Active low CPU hold request (always High) |
| 73 | | IAQHDA nc IAQ [or] HOLDA (logical or) |
| 74 | | SENILA* H(>) Interrupt level A sense enable (always High) |
| 75 | | SENILB* H(>) Interrupt level B sense enable (always High) |
| 76 | | INTA* < Interrupt level A (active low, goes to EXTINT*) |
| 77 | | INTB* nc Interrupt level B (not used) |
| 78 | | LOAD* nc Unmaskable interrupt (not carried by interface cable/card) |
| 79 | | D0-D7 <> Data bus (D0 most significant) |
| 80 | | A0-A15 > Address bus (A0 most sig; A15 also used as CRUOUT) |
| 81 | | AMA/B/C H Extra address bits (always high for TI-99/4x) |
| 82 | | CLKOUT* > Inverted PHI3 clock, from TIM9904 clock generator |
| 83 | | CRUCLK* > Inverted CRU clock, from TMS9900 CRUCLK pin |
| 84 | | DBIN > Active high = read memory. Drives the data bus buffers. |
| 85 | | WE* > Write Enable pulse (derived from TMS9900 WE* pin) |
| 86 | | CRUIN < CRU input bit to TMS9900 |
| 87 | | MEMEN* > Memory access enable (active low) |
| 99 | READYA < System ready (goes to READY, 10K pull-up to +5V) A low level puts the cpu on hold. |
| 100 | RESET* > System reset (active low) |
| 101 | SCLK nc System clock (not connected in interface card) |
| 102 | LCP* nc CPU indicator 1=TI99 0=2nd generation (not connected in interface card) |
| 103 | BOOTPG* nc ? |
| 104 | AUDIO < Input audio (to AUDIOIN in console) |
| 105 | RDBENA* < Active low: enable flex cable data bus drivers (1K pull-up) |
| 106 | PCBEN H PCB enable for burn-in (always High) |
| 107 | HOLD* H Active low CPU hold request (always High) |
| 108 | IAQHDA nc IAQ [or] HOLDA (logical or) |
| 109 | SENILA* H(>) Interrupt level A sense enable (always High) |
| 110 | SENILB* H(>) Interrupt level B sense enable (always High) |
| 111 | INTA* < Interrupt level A (active low, goes to EXTINT*) |
| 112 | INTB* nc Interrupt level B (not used) |
| 113 | LOAD* nc Unmaskable interrupt (not carried by interface cable/card) |
| 114 | D0-D7 <> Data bus (D0 most significant) |
| 115 | A0-A15 > Address bus (A0 most sig; A15 also used as CRUOUT) |
| 116 | AMA/B/C H Extra address bits (always high for TI-99/4x, but used with SGCPU and Geneve) |
| 117 | CLKOUT* > Inverted PHI3 clock, from TIM9904 clock generator |
| 118 | CRUCLK* > Inverted CRU clock, from TMS9900 CRUCLK pin |
| 119 | DBIN > Active high = read memory. Drives the data bus buffers. |
| 120 | WE* > Write Enable pulse (derived from TMS9900 WE* pin) |
| 121 | CRUIN < CRU input bit to TMS9900 |
| 122 | MEMEN* > Memory access enable (active low) |
| 88 | 123 | |
| 124 | The SENILx lines are somewhat obscure, since there have never been hardware |
| 125 | or software that made practical use of them. The intended use can be guessed |
| 126 | from some few traditional cards (like the TI RS232) which indeed have |
| 127 | connections. |
| 89 | 128 | |
| 90 | | The obscure SENILx lines: |
| 129 | With SENILA* asserted (low), a value shall be put on the data bus, |
| 130 | representing the interrupt status bits. It can also be used to determine |
| 131 | the source of the interrupt: The RS232 card (in its standard configuration) |
| 132 | uses the data bus bits 0 and 1 for its two UARTs, while in the second |
| 133 | configuration, it uses bits 4 and 5. |
| 91 | 134 | |
| 92 | | With SENILA* going low, a value shall be put on the data bus, |
| 93 | | representing the interrupt status bits. It can also be used to determine |
| 94 | | the source of the interrupt: The RS232 card (in its standard configuration) |
| 95 | | uses the data bus bits 0 and 1 for its two UARTs, while in the second |
| 96 | | configuration, it uses bits 4 and 5. Still note that the TI-99/4x does not make |
| 97 | | use of SENILA*. |
| 135 | SENILB* / INTB* was planned to be used with disk controllers. The PHP1240 disk |
| 136 | controller puts the value of INTB* on D0 when SENILB* gets active (low) which |
| 137 | reflects the INTRQ output pin of the WD1771. This signal is not used, however. |
| 138 | Instead, the disk controller combines DRQ and IRQ and makes use of a READY/HOLD |
| 139 | control of the CPU. |
| 98 | 140 | |
| 99 | | SENILB* / INTB* was planned to be used with disk controllers. The PHP1240 disk |
| 100 | | controller puts the value of INTB* on D0 when SENILB* gets active (low) which |
| 101 | | reflects the INTRQ output pin of the WD1771. This signal is not used, however. |
| 102 | | Instead, the disk controller combines DRQ and IRQ and makes use of a READY/HOLD |
| 103 | | control of the CPU. |
| 141 | Obviously, SENILA* and SENILB* should never be active at the same time, and |
| 142 | neither should any memory access to a card be active at the same time, for in |
| 143 | both cases, data bus lines may be set to different levels simultaneously. One |
| 144 | possible application case is to turn off all cards in the box, assert SENILA*, |
| 145 | and then do a read access in the memory area of any card in the P-Box (e.g. |
| 146 | 0x4000-0x5fff). Another possiblity is that the currently active card simply |
| 147 | does not respond to a certain memory access, and in this case the status bits |
| 148 | can be read. |
| 104 | 149 | |
| 105 | | Obviously, SENILA* and SENILB* should never be active at the same time, and |
| 106 | | neither should any memory access to a card be active at the same time, for in |
| 107 | | both cases, data bus lines may be set to different levels simultaneously. One |
| 108 | | possible application case is to turn off all cards in the box, lower SENILA*, |
| 109 | | and then do a read access in the memory area of any card in the P-Box (e.g. |
| 110 | | 0x4000-0x5fff). Another possiblity is that the currently active card simply |
| 111 | | does not respond to a certain memory access, and in this case the status bits |
| 112 | | can be read. |
| 150 | Also note that the SENILx lines access all cards in parallel, meaning that there |
| 151 | must be an agreement which cards may use which bits on the data bus. The lines |
| 152 | do not depend on the card being active at that time. |
| 113 | 153 | |
| 114 | | Also note that the SENILx lines access all cards in parallel, meaning that there |
| 115 | | must be an agreement which cards may use which bits on the data bus. The lines |
| 116 | | do not depend on the card being active at that time. |
| 117 | | */ |
| 154 | Emulation architecture |
| 118 | 155 | |
| 156 | console ---- peribox --+ [-- slot1 (always occupied by console connector) ] |
| 157 | | |
| 158 | +--- slot2 --- card |
| 159 | | |
| 160 | +--- slot3 --- card |
| 161 | : |
| 162 | +--- slot8 --- card (usually some floppy controller) |
| 163 | |
| 164 | We have an instance of peribox_device which contains 7 slots |
| 165 | (peribox_slot_device) which are subclasses of device_slot_interface. |
| 166 | Each slot may host one of several cards (ti_expansion_card_device), |
| 167 | which are subclassed from device_slot_card_interface. |
| 168 | |
| 169 | For bus8z_device consult ti99defs.h |
| 170 | --------------------- |
| 171 | |
| 172 | June 2010: Reimplemented using device structure (MZ) (obsoletes 99_peb.c) |
| 173 | January 2012: Reimplemented as class (MZ) |
| 174 | |
| 175 | *****************************************************************************/ |
| 176 | |
| 119 | 177 | #include "emu.h" |
| 120 | 178 | #include "peribox.h" |
| 121 | 179 | |
| 122 | | /* Expansion cards */ |
| 123 | | #include "p_code.h" |
| 180 | // The cards |
| 181 | #include "ti32kmem.h" |
| 124 | 182 | #include "ti_fdc.h" |
| 183 | #include "bwg.h" |
| 125 | 184 | #include "hfdc.h" |
| 126 | | #include "bwg.h" |
| 127 | | #include "ti_rs232.h" |
| 185 | #include "p_code.h" |
| 186 | #include "myarcmem.h" |
| 187 | #include "samsmem.h" |
| 188 | #include "tn_ide.h" |
| 128 | 189 | #include "tn_usbsm.h" |
| 129 | | #include "tn_ide.h" |
| 190 | #include "evpc.h" |
| 130 | 191 | #include "hsgpl.h" |
| 192 | #include "ti_rs232.h" |
| 131 | 193 | #include "spchsyn.h" |
| 132 | | #include "evpc.h" |
| 133 | 194 | #include "memex.h" |
| 134 | 195 | |
| 135 | | #include "imagedev/flopdrv.h" |
| 136 | | #include "imagedev/harddriv.h" |
| 137 | 196 | #include "formats/ti99_dsk.h" |
| 138 | | #include "ti99_hd.h" |
| 139 | 197 | |
| 198 | #define LOG logerror |
| 199 | #define VERBOSE 1 |
| 200 | |
| 201 | #define PEBSLOT2 "slot2" |
| 202 | #define PEBSLOT3 "slot3" |
| 203 | #define PEBSLOT4 "slot4" |
| 204 | #define PEBSLOT5 "slot5" |
| 205 | #define PEBSLOT6 "slot6" |
| 206 | #define PEBSLOT7 "slot7" |
| 207 | #define PEBSLOT8 "slot8" |
| 208 | |
| 209 | // TODO: Connect other lines (think about how to propagate to the controller) |
| 140 | 210 | static const floppy_interface ti99_4_floppy_interface = |
| 141 | 211 | { |
| 142 | | DEVCB_NULL, |
| 143 | | DEVCB_NULL, |
| 144 | | DEVCB_NULL, |
| 145 | | DEVCB_NULL, |
| 146 | | DEVCB_NULL, |
| 147 | | FLOPPY_STANDARD_5_25_DSHD, |
| 148 | | LEGACY_FLOPPY_OPTIONS_NAME(ti99), |
| 149 | | NULL, |
| 150 | | NULL |
| 212 | DEVCB_DEVICE_LINE_MEMBER( DEVICE_SELF_OWNER, peribox_device, indexhole ), // Index hole (floppy out, line) |
| 213 | DEVCB_NULL, // Motor (floppy in, line) |
| 214 | DEVCB_NULL, // Track 0 (out, line) |
| 215 | DEVCB_NULL, // Write protect (out, line) |
| 216 | DEVCB_NULL, // Ready (out, line) |
| 217 | FLOPPY_STANDARD_5_25_DSHD, // type |
| 218 | LEGACY_FLOPPY_OPTIONS_NAME(ti99), // image formats |
| 219 | NULL, // interface |
| 220 | NULL // display info |
| 151 | 221 | }; |
| 152 | 222 | |
| 153 | | typedef struct _ti99_peb_slot |
| 223 | peribox_device::peribox_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 224 | : bus8z_device(mconfig, PERIBOX, "Peripheral expansion box", tag, owner, clock) |
| 154 | 225 | { |
| 155 | | device_t *card; |
| 156 | | const ti99_peb_card *intf; |
| 157 | | } ti99_peb_slot; |
| 158 | | |
| 159 | | typedef struct _ti99_peb_state |
| 160 | | { |
| 161 | | ti99_peb_slot slot[MAXSLOTS]; |
| 162 | | |
| 163 | | // The next three members are used to emulate the collective lines |
| 164 | | // If any card goes L, L is propagated. We are using flags. |
| 165 | | UINT32 inta_state; |
| 166 | | UINT32 intb_state; |
| 167 | | UINT32 ready_state; |
| 168 | | |
| 169 | | int highest; |
| 170 | | |
| 171 | | /* Address bits that are preset to 1 (AMA/AMB/AMC) */ |
| 172 | | int address_prefix; |
| 173 | | |
| 174 | | // Callback to the main system |
| 175 | | ti99_peb_connect lines; |
| 176 | | |
| 177 | | } ti99_peb_state; |
| 178 | | |
| 179 | | INLINE ti99_peb_state *get_safe_token(device_t *device) |
| 180 | | { |
| 181 | | assert(device != NULL); |
| 182 | | assert(device->type() == PBOX4 || device->type() == PBOX4A || device->type() == PBOX8 || device->type() == PBOXEV || device->type() == PBOXSG || device->type() == PBOXGEN); |
| 183 | | |
| 184 | | return (ti99_peb_state *)downcast<legacy_device_base *>(device)->token(); |
| 226 | for (int i=2; i <= 8; i++) m_slot[i] = NULL; |
| 185 | 227 | } |
| 186 | 228 | |
| 187 | | INLINE const ti99_peb_config *get_config(device_t *device) |
| 229 | READ8Z_MEMBER(peribox_device::readz) |
| 188 | 230 | { |
| 189 | | assert(device != NULL); |
| 190 | | assert(device->type() == PBOX4 || device->type() == PBOX4A || device->type() == PBOX8 || device->type() == PBOXEV || device->type() == PBOXSG || device->type() == PBOXGEN); |
| 191 | | |
| 192 | | return (const ti99_peb_config *) downcast<const legacy_device_base *>(device)->inline_config(); |
| 193 | | } |
| 194 | | |
| 195 | | /* |
| 196 | | Callbacks |
| 197 | | /INTA is active low |
| 198 | | Input lines are active low; ASSERT_LINE means LOW in this case. |
| 199 | | */ |
| 200 | | static WRITE_LINE_DEVICE_HANDLER( inta ) |
| 201 | | { |
| 202 | | int slot = get_pebcard_config(device)->slot; |
| 203 | | ti99_peb_state *peb = get_safe_token(device->owner()); |
| 204 | | if (state==CLEAR_LINE) |
| 231 | for (int i=2; i <= 8; i++) |
| 205 | 232 | { |
| 206 | | // The flags are stored as inverted (inta_state=0 if all lines are H) |
| 207 | | // Unset the L flag of this slot |
| 208 | | peb->inta_state &= ~(1 << slot); |
| 233 | if (m_slot[i]!=NULL) m_slot[i]->readz(space, offset | m_address_prefix, value, mem_mask); |
| 209 | 234 | } |
| 210 | | else |
| 211 | | { |
| 212 | | // Set the L flag of this slot |
| 213 | | peb->inta_state |= (1 << slot); |
| 214 | | } |
| 215 | | // Call back the main system, setting the line to L if any PEB card set it to L |
| 216 | | // This is the case when inta_state is not 0 |
| 217 | | peb->lines.inta((peb->inta_state!=0)? ASSERT_LINE : CLEAR_LINE); |
| 218 | 235 | } |
| 219 | 236 | |
| 220 | | static WRITE_LINE_DEVICE_HANDLER( intb ) |
| 237 | WRITE8_MEMBER(peribox_device::write) |
| 221 | 238 | { |
| 222 | | int slot = get_pebcard_config(device)->slot; |
| 223 | | ti99_peb_state *peb = get_safe_token(device->owner()); |
| 224 | | if (state==CLEAR_LINE) |
| 225 | | peb->intb_state &= ~(1 << slot); |
| 226 | | else |
| 227 | | peb->intb_state |= (1 << slot); |
| 228 | | peb->lines.intb((peb->intb_state!=0)? ASSERT_LINE : CLEAR_LINE); |
| 229 | | } |
| 230 | | |
| 231 | | static WRITE_LINE_DEVICE_HANDLER( ready ) |
| 232 | | { |
| 233 | | int slot = get_pebcard_config(device)->slot; |
| 234 | | ti99_peb_state *peb = get_safe_token(device->owner()); |
| 235 | | if (state==CLEAR_LINE) |
| 236 | | peb->ready_state &= ~(1 << slot); |
| 237 | | else |
| 238 | | peb->ready_state |= (1 << slot); |
| 239 | | peb->lines.ready((peb->ready_state!=0)? ASSERT_LINE : CLEAR_LINE); |
| 240 | | } |
| 241 | | |
| 242 | | /* |
| 243 | | Declares the callbacks above that are called from the cards. This instance |
| 244 | | is passed to the cards with MCFG_PBOXCARD_ADD and must be handled as a |
| 245 | | static_config. |
| 246 | | */ |
| 247 | | const peb_callback_if peb_callback = |
| 248 | | { |
| 249 | | DEVCB_LINE( inta ), |
| 250 | | DEVCB_LINE( intb ), |
| 251 | | DEVCB_LINE( ready ) |
| 252 | | }; |
| 253 | | |
| 254 | | /* |
| 255 | | Mount the PEB card. Although possible, this is not done by the box itself; |
| 256 | | instead, the card must call this function on the box. The advantage is |
| 257 | | that we can assign the same slot to different cards which are selected |
| 258 | | by dip switches. Only the card which is selected will register itself; the |
| 259 | | other cards are stillborn. |
| 260 | | Returns TRUE when the card could be mounted. |
| 261 | | */ |
| 262 | | int mount_card(device_t *device, device_t *cardptr, const ti99_peb_card *cardintf, int slotindex) |
| 263 | | { |
| 264 | | ti99_peb_state *peb = get_safe_token(device); |
| 265 | | if ((slotindex > 0) && (slotindex < MAXSLOTS)) |
| 239 | for (int i=2; i <= 8; i++) |
| 266 | 240 | { |
| 267 | | if (peb->slot[slotindex].card == NULL) |
| 268 | | { |
| 269 | | peb->slot[slotindex].card = cardptr; |
| 270 | | peb->slot[slotindex].intf = cardintf; |
| 271 | | if (slotindex > peb->highest) peb->highest = slotindex; |
| 272 | | logerror("ti99_peb: registering the card at slot index %d\n", slotindex); |
| 273 | | return TRUE; |
| 274 | | } |
| 275 | | else |
| 276 | | { |
| 277 | | logerror("ti99_peb: Tried to mount a second card in slot %d\n", slotindex); |
| 278 | | } |
| 241 | if (m_slot[i]!=NULL) m_slot[i]->write(space, offset | m_address_prefix, data, mem_mask); |
| 279 | 242 | } |
| 280 | | else |
| 281 | | logerror("ti99_peb: Invalid slot number %d\n", slotindex); |
| 282 | | return FALSE; |
| 283 | 243 | } |
| 284 | 244 | |
| 285 | | void unmount_card(device_t *device, int slotindex) |
| 245 | void peribox_device::crureadz(offs_t offset, UINT8 *value) |
| 286 | 246 | { |
| 287 | | ti99_peb_state *peb = get_safe_token(device); |
| 288 | | peb->slot[slotindex].card = NULL; |
| 289 | | } |
| 290 | | |
| 291 | | /*************************************************************************** |
| 292 | | Memory and CRU access |
| 293 | | ***************************************************************************/ |
| 294 | | |
| 295 | | READ8Z_DEVICE_HANDLER( ti99_peb_data_rz ) |
| 296 | | { |
| 297 | | ti99_peb_state *peb = get_safe_token(device); |
| 298 | | int i; |
| 299 | | for (i=1; i <= peb->highest; i++) |
| 247 | for (int i=2; i <= 8; i++) |
| 300 | 248 | { |
| 301 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_read_data)) |
| 302 | | (*peb->slot[i].intf->card_read_data)(peb->slot[i].card, peb->address_prefix | offset, value); |
| 249 | if (m_slot[i]!=NULL) m_slot[i]->crureadz(offset, value); |
| 303 | 250 | } |
| 304 | 251 | } |
| 305 | 252 | |
| 306 | | WRITE8_DEVICE_HANDLER( ti99_peb_data_w ) |
| 253 | void peribox_device::cruwrite(offs_t offset, UINT8 data) |
| 307 | 254 | { |
| 308 | | ti99_peb_state *peb = get_safe_token(device); |
| 309 | | int i; |
| 310 | | for (i=1; i <= peb->highest; i++) |
| 255 | for (int i=2; i <= 8; i++) |
| 311 | 256 | { |
| 312 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_write_data)) |
| 313 | | (*peb->slot[i].intf->card_write_data)(peb->slot[i].card, peb->address_prefix | offset, data); |
| 257 | if (m_slot[i]!=NULL) m_slot[i]->cruwrite(offset, data); |
| 314 | 258 | } |
| 315 | 259 | } |
| 316 | 260 | |
| 317 | | READ8Z_DEVICE_HANDLER( ti99_peb_cru_rz ) |
| 261 | /* |
| 262 | And here are finally the two mythical lines SENILA* and SENILB*; mythical |
| 263 | since there is no report of any software that ever used them. |
| 264 | */ |
| 265 | WRITE_LINE_MEMBER(peribox_device::senila) |
| 318 | 266 | { |
| 319 | | ti99_peb_state *peb = get_safe_token(device); |
| 320 | | int i; |
| 321 | | for (i=1; i <= peb->highest; i++) |
| 267 | for (int i=2; i <= 8; i++) |
| 322 | 268 | { |
| 323 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_read_cru)) |
| 324 | | (*peb->slot[i].intf->card_read_cru)(peb->slot[i].card, offset, value); |
| 269 | if (m_slot[i]!=NULL) m_slot[i]->senila(state); |
| 325 | 270 | } |
| 326 | 271 | } |
| 327 | 272 | |
| 328 | | WRITE8_DEVICE_HANDLER( ti99_peb_cru_w ) |
| 273 | WRITE_LINE_MEMBER(peribox_device::senilb) |
| 329 | 274 | { |
| 330 | | ti99_peb_state *peb = get_safe_token(device); |
| 331 | | int i; |
| 332 | | for (i=1; i <= peb->highest; i++) |
| 275 | for (int i=2; i <= 8; i++) |
| 333 | 276 | { |
| 334 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_write_cru)) |
| 335 | | (*peb->slot[i].intf->card_write_cru)(peb->slot[i].card, offset, data); |
| 277 | if (m_slot[i]!=NULL) m_slot[i]->senilb(state); |
| 336 | 278 | } |
| 337 | 279 | } |
| 338 | 280 | |
| 339 | 281 | /* |
| 340 | | For SGCPU |
| 282 | The Genmod modification is only of interest for the Geneve. It requires |
| 283 | to modify the decoding of each single card. |
| 341 | 284 | */ |
| 342 | | READ16Z_DEVICE_HANDLER( ti99_peb_data16_rz ) |
| 285 | INPUT_CHANGED_MEMBER( peribox_device::genmod_changed ) |
| 343 | 286 | { |
| 344 | | ti99_peb_state *peb = get_safe_token(device); |
| 345 | | int i; |
| 346 | | for (i=1; i <= peb->highest; i++) |
| 347 | | { |
| 348 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_read_data16)) |
| 349 | | (*peb->slot[i].intf->card_read_data16)(peb->slot[i].card, peb->address_prefix | offset, value); |
| 350 | | } |
| 287 | set_genmod(newval==1); |
| 351 | 288 | } |
| 352 | 289 | |
| 353 | | /* |
| 354 | | For SGCPU |
| 355 | | */ |
| 356 | | WRITE16_DEVICE_HANDLER( ti99_peb_data16_w ) |
| 290 | void peribox_device::set_genmod(bool set) |
| 357 | 291 | { |
| 358 | | ti99_peb_state *peb = get_safe_token(device); |
| 359 | | int i; |
| 360 | | for (i=1; i <= peb->highest; i++) |
| 292 | for (int i=2; i <= 8; i++) |
| 361 | 293 | { |
| 362 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->card_write_data16)) |
| 363 | | (*peb->slot[i].intf->card_write_data16)(peb->slot[i].card, peb->address_prefix | offset, data); |
| 294 | if (m_slot[i]!=NULL) m_slot[i]->set_genmod(set); |
| 364 | 295 | } |
| 365 | 296 | } |
| 366 | 297 | |
| 367 | 298 | /* |
| 368 | | SENILx |
| 369 | | TODO: Check whether device is the correct pointer (seems to be wrong here, |
| 370 | | the device is usually the caller) |
| 299 | The INTA*, INTB*, and READY* lines are connected to each PEB card and are |
| 300 | pulled up when inactive. If any card asserts the line (pulling down), the |
| 301 | line state goes down. So we must keep a record which cards pull down the |
| 302 | line. |
| 371 | 303 | */ |
| 372 | | WRITE_LINE_DEVICE_HANDLER( ti99_peb_senila ) |
| 304 | void peribox_device::inta_join(int slot, int state) |
| 373 | 305 | { |
| 374 | | ti99_peb_state *peb = get_safe_token(device); |
| 375 | | int i; |
| 376 | | for (i=1; i <= peb->highest; i++) |
| 377 | | { |
| 378 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->senila)) |
| 379 | | (*peb->slot[i].intf->senila)(peb->slot[i].card, state); |
| 380 | | } |
| 306 | if (VERBOSE>7) LOG("Peribox propagating INTA from slot %d to console: %d\n", slot, state); |
| 307 | if (state==ASSERT_LINE) |
| 308 | m_inta_flag |= (1 << slot); |
| 309 | else |
| 310 | m_inta_flag &= ~(1 << slot); |
| 311 | |
| 312 | m_console_inta((m_inta_flag != 0)? ASSERT_LINE : CLEAR_LINE); |
| 381 | 313 | } |
| 382 | 314 | |
| 383 | | WRITE_LINE_DEVICE_HANDLER( ti99_peb_senilb ) |
| 315 | void peribox_device::intb_join(int slot, int state) |
| 384 | 316 | { |
| 385 | | ti99_peb_state *peb = get_safe_token(device); |
| 386 | | int i; |
| 387 | | for (i=1; i <= peb->highest; i++) |
| 388 | | { |
| 389 | | if ((peb->slot[i].card != NULL) && (*peb->slot[i].intf->senilb)) |
| 390 | | (*peb->slot[i].intf->senilb)(peb->slot[i].card, state); |
| 391 | | } |
| 317 | if (VERBOSE>7) LOG("Peribox propagating INTB from slot %d to console: %d\n", slot, state); |
| 318 | if (state==ASSERT_LINE) |
| 319 | m_intb_flag |= (1 << slot); |
| 320 | else |
| 321 | m_intb_flag &= ~(1 << slot); |
| 322 | |
| 323 | m_console_intb((m_intb_flag != 0)? ASSERT_LINE : CLEAR_LINE); |
| 392 | 324 | } |
| 393 | 325 | |
| 394 | | /*************************************************************************** |
| 395 | | DEVICE FUNCTIONS |
| 396 | | ***************************************************************************/ |
| 397 | | |
| 398 | | static DEVICE_START( ti99_peb ) |
| 326 | void peribox_device::ready_join(int slot, int state) |
| 399 | 327 | { |
| 400 | | ti99_peb_state *peb = get_safe_token(device); |
| 401 | | const ti99_peb_config* pebconf = (const ti99_peb_config*)get_config(device); |
| 328 | if (VERBOSE>7) LOG("Peribox propagating READY from slot %d to console: %d\n", slot, state); |
| 329 | if (state==ASSERT_LINE) |
| 330 | m_ready_flag |= (1 << slot); |
| 331 | else |
| 332 | m_ready_flag &= ~(1 << slot); |
| 402 | 333 | |
| 403 | | for (int slotindex=0; slotindex < MAXSLOTS; slotindex++) |
| 404 | | unmount_card(device, slotindex); |
| 334 | m_console_ready((m_ready_flag != 0)? ASSERT_LINE : CLEAR_LINE); |
| 335 | } |
| 405 | 336 | |
| 406 | | /* Resolve the callbacks to the console */ |
| 407 | | devcb_write_line inta = DEVCB_LINE(pebconf->inta); |
| 408 | | devcb_write_line intb = DEVCB_LINE(pebconf->intb); |
| 409 | | devcb_write_line ready = DEVCB_LINE(pebconf->ready); |
| 337 | void peribox_device::set_slot_loaded(int slot, peribox_slot_device* slotdev) |
| 338 | { |
| 339 | if (VERBOSE>6) |
| 340 | { |
| 341 | if (slotdev!=NULL) LOG("Setting slot %d to device %s\n", slot, slotdev->tag()); |
| 342 | else LOG("Setting slot %d to EMPTY\n", slot); |
| 343 | } |
| 344 | m_slot[slot] = slotdev; |
| 345 | } |
| 410 | 346 | |
| 411 | | peb->lines.ready.resolve(ready, *device); |
| 412 | | peb->lines.inta.resolve(inta, *device); |
| 413 | | peb->lines.intb.resolve(intb, *device); |
| 347 | void peribox_device::device_start(void) |
| 348 | { |
| 349 | if (VERBOSE>7) LOG("Peribox started\n"); |
| 414 | 350 | |
| 415 | | peb->address_prefix = (pebconf->amx << 16); |
| 351 | floppy_drive_set_rpm(subdevice(FLOPPY_0), 300.); |
| 352 | floppy_drive_set_rpm(subdevice(FLOPPY_1), 300.); |
| 353 | floppy_drive_set_rpm(subdevice(FLOPPY_2), 300.); |
| 354 | floppy_drive_set_rpm(subdevice(FLOPPY_3), 300.); |
| 416 | 355 | } |
| 417 | 356 | |
| 418 | | static DEVICE_STOP( ti99_peb ) |
| 357 | void peribox_device::device_config_complete() |
| 419 | 358 | { |
| 420 | | logerror("ti99_peb: stop\n"); |
| 421 | | } |
| 359 | // Resolve the callback lines to the console |
| 360 | const peribox_config *intf = reinterpret_cast<const peribox_config *>(static_config()); |
| 361 | assert (intf != NULL); |
| 362 | m_console_inta.resolve(intf->inta, *this); |
| 363 | m_console_intb.resolve(intf->intb, *this); |
| 364 | m_console_ready.resolve(intf->ready, *this); |
| 422 | 365 | |
| 423 | | static DEVICE_RESET( ti99_peb ) |
| 424 | | { |
| 425 | | ti99_peb_state *peb = get_safe_token(device); |
| 426 | | logerror("ti99_peb: reset\n"); |
| 427 | | peb->inta_state = 0; |
| 428 | | peb->intb_state = 0; |
| 429 | | peb->ready_state = 0; |
| 430 | | peb->highest = 0; |
| 431 | | for (int i=0; i < MAXSLOTS; i++) unmount_card(device, i); |
| 366 | m_inta_flag = 0; |
| 367 | m_intb_flag = 0; |
| 368 | m_ready_flag = 0; |
| 369 | |
| 370 | // The TI-99/4(A) Flex Cable Interface (slot 1) pulls up the AMA/AMB/AMC lines to 1/1/1. |
| 371 | m_address_prefix = intf->prefix; |
| 432 | 372 | } |
| 433 | 373 | |
| 434 | | #define MCFG_PBOXCARD_ADD( _tag, _type, _slot ) \ |
| 435 | | MCFG_DEVICE_ADD(_tag, _type, 0) \ |
| 436 | | MCFG_DEVICE_CONFIG_DATA32( ti99_pebcard_config, slot, _slot ) \ |
| 437 | | MCFG_DEVICE_CONFIG( peb_callback ) |
| 374 | SLOT_INTERFACE_START( peribox_slot ) |
| 375 | SLOT_INTERFACE("32kmem", TI_32KMEM) |
| 376 | SLOT_INTERFACE("myarcmem", TI99_MYARCMEM) |
| 377 | SLOT_INTERFACE("samsmem", TI99_SAMSMEM) |
| 378 | SLOT_INTERFACE("pcode", TI99_P_CODE) |
| 379 | SLOT_INTERFACE("hsgpl", TI99_HSGPL) |
| 380 | SLOT_INTERFACE("tirs232", TI99_RS232) |
| 381 | SLOT_INTERFACE("speech", TI99_SPEECH) |
| 382 | SLOT_INTERFACE_END |
| 438 | 383 | |
| 439 | | /* |
| 440 | | We're emulating a "super box" with more than 8 slots. The original |
| 441 | | box had 8 slots, but that's a bit too limiting. |
| 442 | | This may become organized differently in future versions; for now |
| 443 | | we'll go this way. |
| 384 | SLOT_INTERFACE_START( peribox_slot6 ) |
| 385 | SLOT_INTERFACE("ide", TI99_IDE) |
| 386 | SLOT_INTERFACE("usbsm", TI99_USBSM) |
| 387 | SLOT_INTERFACE("tirs232", TI99_RS232) |
| 388 | SLOT_INTERFACE("speech", TI99_SPEECH) |
| 389 | SLOT_INTERFACE_END |
| 444 | 390 | |
| 445 | | Slot 0 is the "Flex cable interface" / SGCPU / Geneve |
| 446 | | We assign the same slot number for some cards that cannot be used |
| 447 | | in parallel anyway. The config switch will determine which one to use. |
| 448 | | Future works: |
| 449 | | // WHTech SCSI controller |
| 450 | | // MCFG_PBOXCARD_ADD("SCSI", 4, scsi_intf) |
| 391 | SLOT_INTERFACE_START( peribox_slot7 ) |
| 392 | SLOT_INTERFACE("ide", TI99_IDE) |
| 393 | SLOT_INTERFACE("usbsm", TI99_USBSM) |
| 394 | SLOT_INTERFACE("bwg", TI99_BWG) |
| 395 | SLOT_INTERFACE("hfdc", TI99_HFDC) |
| 396 | SLOT_INTERFACE_END |
| 451 | 397 | |
| 452 | | // Horizon Ramdisk |
| 453 | | // MCFG_PBOXCARD_ADD("HRD", 10, ramdisk_intf) |
| 454 | | */ |
| 398 | SLOT_INTERFACE_START( peribox_slot8 ) |
| 399 | SLOT_INTERFACE("tifdc", TI99_FDC) |
| 400 | SLOT_INTERFACE("bwg", TI99_BWG) |
| 401 | SLOT_INTERFACE("hfdc", TI99_HFDC) |
| 402 | SLOT_INTERFACE_END |
| 455 | 403 | |
| 456 | | static MACHINE_CONFIG_FRAGMENT( ti99_peb ) |
| 457 | | MCFG_PBOXCARD_ADD( "mem_ti32k", TI32KMEM, 1 ) |
| 458 | | MCFG_PBOXCARD_ADD( "mem_sams1m", SAMSMEM, 1 ) |
| 459 | | MCFG_PBOXCARD_ADD( "mem_myarc512", MYARCMEM, 1 ) |
| 460 | | MCFG_PBOXCARD_ADD( "speech", TISPEECH, 2 ) |
| 461 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 3 ) |
| 462 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 4 ) |
| 463 | | MCFG_PBOXCARD_ADD( "hsgpl", HSGPL, 5 ) |
| 464 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 7 ) |
| 465 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 8 ) |
| 466 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 8 ) |
| 467 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 8 ) |
| 404 | MACHINE_CONFIG_FRAGMENT( peribox_device ) |
| 405 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT2, peribox_slot ) |
| 406 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT3, peribox_slot ) |
| 407 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT4, peribox_slot ) |
| 408 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT5, peribox_slot ) |
| 409 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT6, peribox_slot6 ) |
| 410 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT7, peribox_slot7 ) |
| 411 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT8, peribox_slot8 ) |
| 468 | 412 | |
| 469 | 413 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 470 | 414 | MCFG_MFMHD_3_DRIVES_ADD() |
| 471 | 415 | MACHINE_CONFIG_END |
| 472 | 416 | |
| 473 | | static MACHINE_CONFIG_FRAGMENT( ti994a_peb ) |
| 474 | | MCFG_PBOXCARD_ADD( "mem_ti32k", TI32KMEM, 1 ) |
| 475 | | MCFG_PBOXCARD_ADD( "mem_sams1m", SAMSMEM, 1 ) |
| 476 | | MCFG_PBOXCARD_ADD( "mem_myarc512", MYARCMEM, 1 ) |
| 477 | | MCFG_PBOXCARD_ADD( "speech", TISPEECH, 2 ) |
| 478 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 3 ) |
| 479 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 4 ) |
| 480 | | MCFG_PBOXCARD_ADD( "hsgpl", HSGPL, 5 ) |
| 481 | | MCFG_PBOXCARD_ADD( "p_code_card", PCODEN, 6 ) |
| 482 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 7 ) |
| 483 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 8 ) |
| 484 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 8 ) |
| 485 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 8 ) |
| 417 | machine_config_constructor peribox_device::device_mconfig_additions() const |
| 418 | { |
| 419 | return MACHINE_CONFIG_NAME( peribox_device ); |
| 420 | } |
| 486 | 421 | |
| 487 | | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 488 | | MCFG_MFMHD_3_DRIVES_ADD() |
| 489 | | MACHINE_CONFIG_END |
| 422 | /**************************************************************************** |
| 423 | A variant of the box used for the Geneve. |
| 424 | *****************************************************************************/ |
| 490 | 425 | |
| 491 | | static MACHINE_CONFIG_FRAGMENT( ti99ev_peb ) |
| 492 | | MCFG_PBOXCARD_ADD( "mem_ti32k", TI32KMEM, 1 ) |
| 493 | | MCFG_PBOXCARD_ADD( "mem_sams1m", SAMSMEM, 1 ) |
| 494 | | MCFG_PBOXCARD_ADD( "mem_myarc512", MYARCMEM, 1 ) |
| 495 | | MCFG_PBOXCARD_ADD( "speech", TISPEECH, 2 ) |
| 496 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 3 ) |
| 497 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 4 ) |
| 498 | | MCFG_PBOXCARD_ADD( "hsgpl", HSGPL, 5 ) |
| 499 | | MCFG_PBOXCARD_ADD( "p_code_card", PCODEN, 6 ) |
| 500 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 7 ) |
| 501 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 8 ) |
| 502 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 8 ) |
| 503 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 8 ) |
| 504 | | MCFG_PBOXCARD_ADD( "evpc", EVPC, 9 ) |
| 426 | peribox_gen_device::peribox_gen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 427 | : peribox_device(mconfig, tag, owner, clock) |
| 428 | { |
| 429 | }; |
| 505 | 430 | |
| 431 | SLOT_INTERFACE_START( peribox_slotg ) |
| 432 | SLOT_INTERFACE("memex", TI99_MEMEX) |
| 433 | SLOT_INTERFACE("myarcmem", TI99_MYARCMEM) |
| 434 | SLOT_INTERFACE("samsmem", TI99_SAMSMEM) |
| 435 | SLOT_INTERFACE("pcode", TI99_P_CODE) |
| 436 | SLOT_INTERFACE("tirs232", TI99_RS232) |
| 437 | SLOT_INTERFACE("speech", TI99_SPEECH) |
| 438 | SLOT_INTERFACE_END |
| 439 | |
| 440 | MACHINE_CONFIG_FRAGMENT( peribox_gen_device ) |
| 441 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT2, peribox_slotg ) |
| 442 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT3, peribox_slotg ) |
| 443 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT4, peribox_slotg ) |
| 444 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT5, peribox_slotg ) |
| 445 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT6, peribox_slot6 ) |
| 446 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT7, peribox_slot7 ) |
| 447 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT8, peribox_slot8 ) |
| 448 | |
| 506 | 449 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 507 | 450 | MCFG_MFMHD_3_DRIVES_ADD() |
| 508 | 451 | MACHINE_CONFIG_END |
| 509 | 452 | |
| 453 | machine_config_constructor peribox_gen_device::device_mconfig_additions() const |
| 454 | { |
| 455 | return MACHINE_CONFIG_NAME( peribox_gen_device ); |
| 456 | } |
| 510 | 457 | |
| 511 | | static MACHINE_CONFIG_FRAGMENT( ti998_peb ) |
| 512 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 1 ) |
| 513 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 2 ) |
| 514 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 3 ) |
| 515 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 8 ) |
| 516 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 8 ) |
| 517 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 8 ) |
| 458 | /**************************************************************************** |
| 459 | A variant of the box used for the SGCPU (aka TI-99/4P). |
| 460 | *****************************************************************************/ |
| 518 | 461 | |
| 519 | | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 520 | | MCFG_MFMHD_3_DRIVES_ADD() |
| 521 | | MACHINE_CONFIG_END |
| 462 | peribox_sg_device::peribox_sg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 463 | : peribox_device(mconfig, tag, owner, clock) |
| 464 | { |
| 465 | }; |
| 522 | 466 | |
| 523 | | static MACHINE_CONFIG_FRAGMENT( ti99sg_peb ) |
| 524 | | MCFG_PBOXCARD_ADD( "speech", TISPEECH, 1 ) |
| 525 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 2 ) |
| 526 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 3 ) |
| 527 | | MCFG_PBOXCARD_ADD( "hsgpl", HSGPL, 4 ) |
| 528 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 6 ) |
| 529 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 7 ) |
| 530 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 7 ) |
| 531 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 7 ) |
| 532 | | MCFG_PBOXCARD_ADD( "evpc", EVPC, 8 ) |
| 467 | SLOT_INTERFACE_START( peribox_slotp ) |
| 468 | SLOT_INTERFACE("pcode", TI99_P_CODE) |
| 469 | SLOT_INTERFACE("tirs232", TI99_RS232) |
| 470 | SLOT_INTERFACE("speech", TI99_SPEECH) |
| 471 | SLOT_INTERFACE_END |
| 533 | 472 | |
| 473 | SLOT_INTERFACE_START( peribox_ev_slot ) |
| 474 | SLOT_INTERFACE("evpc", TI99_EVPC) |
| 475 | SLOT_INTERFACE_END |
| 476 | |
| 477 | SLOT_INTERFACE_START( peribox_hs_slot ) |
| 478 | SLOT_INTERFACE("hsgpl", TI99_HSGPL) |
| 479 | SLOT_INTERFACE_END |
| 480 | |
| 481 | MACHINE_CONFIG_FRAGMENT( peribox_sg_device ) |
| 482 | MCFG_PERIBOX_SLOT_ADD_DEF( PEBSLOT2, peribox_ev_slot, "evpc" ) |
| 483 | MCFG_PERIBOX_SLOT_ADD_DEF( PEBSLOT3, peribox_hs_slot, "hsgpl" ) |
| 484 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT4, peribox_slotp ) |
| 485 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT5, peribox_slotp ) |
| 486 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT6, peribox_slot6 ) |
| 487 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT7, peribox_slot7 ) |
| 488 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT8, peribox_slot7 ) |
| 489 | |
| 534 | 490 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 535 | 491 | MCFG_MFMHD_3_DRIVES_ADD() |
| 536 | 492 | MACHINE_CONFIG_END |
| 537 | 493 | |
| 538 | | static MACHINE_CONFIG_FRAGMENT( geneve_peb ) |
| 539 | | MCFG_PBOXCARD_ADD( "memex", GENMEMEX, 1 ) |
| 540 | | MCFG_PBOXCARD_ADD( "speech", TISPEECH, 2 ) |
| 541 | | MCFG_PBOXCARD_ADD( "usbsmart", USBSMART, 3 ) |
| 542 | | MCFG_PBOXCARD_ADD( "ide", TNIDE, 4 ) |
| 543 | | MCFG_PBOXCARD_ADD( "rs232_card", TIRS232, 6 ) |
| 544 | | MCFG_PBOXCARD_ADD( "ti_fdc", TIFDC, 7 ) |
| 545 | | MCFG_PBOXCARD_ADD( "hfdc", HFDC, 7 ) |
| 546 | | MCFG_PBOXCARD_ADD( "bwg", BWG, 7 ) |
| 494 | machine_config_constructor peribox_sg_device::device_mconfig_additions() const |
| 495 | { |
| 496 | return MACHINE_CONFIG_NAME( peribox_sg_device ); |
| 497 | } |
| 547 | 498 | |
| 499 | |
| 500 | /**************************************************************************** |
| 501 | Another variant of the box; used for the TI with EVPC. The EVPC is |
| 502 | obviously required. |
| 503 | *****************************************************************************/ |
| 504 | |
| 505 | peribox_ev_device::peribox_ev_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 506 | : peribox_device(mconfig, tag, owner, clock) |
| 507 | { |
| 508 | }; |
| 509 | |
| 510 | MACHINE_CONFIG_FRAGMENT( peribox_ev_device ) |
| 511 | MCFG_PERIBOX_SLOT_ADD_DEF( PEBSLOT2, peribox_ev_slot, "evpc" ) |
| 512 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT3, peribox_slot ) |
| 513 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT4, peribox_slot ) |
| 514 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT5, peribox_slot ) |
| 515 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT6, peribox_slot6 ) |
| 516 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT7, peribox_slot7 ) |
| 517 | MCFG_PERIBOX_SLOT_ADD( PEBSLOT8, peribox_slot8 ) |
| 518 | |
| 548 | 519 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(ti99_4_floppy_interface) |
| 549 | 520 | MCFG_MFMHD_3_DRIVES_ADD() |
| 550 | 521 | MACHINE_CONFIG_END |
| 551 | 522 | |
| 552 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 523 | machine_config_constructor peribox_ev_device::device_mconfig_additions() const |
| 524 | { |
| 525 | return MACHINE_CONFIG_NAME( peribox_ev_device ); |
| 526 | } |
| 553 | 527 | |
| 554 | | #define DEVTEMPLATE_ID(p,s) p##ti99_peb##s |
| 555 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_MACHINE_CONFIG | DT_HAS_INLINE_CONFIG |
| 556 | | #define DEVTEMPLATE_NAME "TI-99 Peripheral Expansion System (99/4)" |
| 557 | | #define DEVTEMPLATE_FAMILY "External devices" |
| 558 | | #include "devtempl.h" |
| 528 | /*************************************************************************** |
| 529 | Floppy interface |
| 530 | ****************************************************************************/ |
| 559 | 531 | |
| 560 | | #define DEVTEMPLATE_DERIVED_ID(p,s) p##ti994a_peb##s |
| 561 | | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_MACHINE_CONFIG |
| 562 | | #define DEVTEMPLATE_DERIVED_NAME "TI-99 Peripheral Expansion System (99/4A)" |
| 563 | | #include "devtempl.h" |
| 532 | // TODO: won't be called unless motor_on is triggered |
| 533 | WRITE_LINE_MEMBER( peribox_device::indexhole ) |
| 534 | { |
| 535 | if (VERBOSE>4) LOG("peribox_device: indexhole\n"); |
| 536 | } |
| 564 | 537 | |
| 565 | | #define DEVTEMPLATE_DERIVED_ID(p,s) p##ti998_peb##s |
| 566 | | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_MACHINE_CONFIG |
| 567 | | #define DEVTEMPLATE_DERIVED_NAME "TI-99 Peripheral Expansion System (99/8)" |
| 568 | | #include "devtempl.h" |
| 538 | /*************************************************************************** |
| 539 | Implementation of a slot within the box. |
| 540 | ****************************************************************************/ |
| 569 | 541 | |
| 570 | | #define DEVTEMPLATE_DERIVED_ID(p,s) p##ti99ev_peb##s |
| 571 | | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_MACHINE_CONFIG |
| 572 | | #define DEVTEMPLATE_DERIVED_NAME "TI-99 Peripheral Expansion System (99/4a with EVPC)" |
| 573 | | #include "devtempl.h" |
| 542 | int peribox_slot_device::get_index_from_tagname() |
| 543 | { |
| 544 | const char *mytag = tag(); |
| 545 | int maxlen = strlen(mytag); |
| 546 | int i; |
| 547 | for (i=maxlen-1; i >=0; i--) |
| 548 | if (mytag[i] < 48 || mytag[i] > 57) break; |
| 574 | 549 | |
| 575 | | #define DEVTEMPLATE_DERIVED_ID(p,s) p##ti99sg_peb##s |
| 576 | | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_MACHINE_CONFIG |
| 577 | | #define DEVTEMPLATE_DERIVED_NAME "TI99 Peripheral Expansion System (SGCPU)" |
| 578 | | #include "devtempl.h" |
| 550 | return atoi(mytag+i+1); |
| 551 | } |
| 579 | 552 | |
| 580 | | #define DEVTEMPLATE_DERIVED_ID(p,s) p##geneve_peb##s |
| 581 | | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_MACHINE_CONFIG |
| 582 | | #define DEVTEMPLATE_DERIVED_NAME "TI99 Peripheral Expansion System (Geneve)" |
| 583 | | #include "devtempl.h" |
| 553 | peribox_slot_device::peribox_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 554 | : bus8z_device(mconfig, PERIBOX_SLOT, "TI P-Box slot", tag, owner, clock), device_slot_interface(mconfig, *this) |
| 555 | { |
| 556 | } |
| 584 | 557 | |
| 585 | | DEFINE_LEGACY_DEVICE( PBOX4, ti99_peb ); |
| 586 | | DEFINE_LEGACY_DEVICE( PBOX4A, ti994a_peb ); |
| 587 | | DEFINE_LEGACY_DEVICE( PBOXEV, ti99ev_peb ); |
| 588 | | DEFINE_LEGACY_DEVICE( PBOX8, ti998_peb ); |
| 589 | | DEFINE_LEGACY_DEVICE( PBOXSG, ti99sg_peb ); |
| 590 | | DEFINE_LEGACY_DEVICE( PBOXGEN, geneve_peb ); |
| 558 | READ8Z_MEMBER(peribox_slot_device::readz) |
| 559 | { |
| 560 | m_card->readz(space, offset, value, mem_mask); |
| 561 | } |
| 562 | |
| 563 | WRITE8_MEMBER(peribox_slot_device::write) |
| 564 | { |
| 565 | m_card->write(space, offset, data, mem_mask); |
| 566 | } |
| 567 | |
| 568 | void peribox_slot_device::crureadz(offs_t offset, UINT8 *value) |
| 569 | { |
| 570 | m_card->crureadz(offset, value); |
| 571 | } |
| 572 | |
| 573 | void peribox_slot_device::cruwrite(offs_t offset, UINT8 data) |
| 574 | { |
| 575 | m_card->cruwrite(offset, data); |
| 576 | } |
| 577 | |
| 578 | void peribox_slot_device::senila(int state) |
| 579 | { |
| 580 | m_card->set_senila(state); |
| 581 | } |
| 582 | |
| 583 | void peribox_slot_device::senilb(int state) |
| 584 | { |
| 585 | m_card->set_senilb(state); |
| 586 | } |
| 587 | |
| 588 | /* |
| 589 | Genmod support |
| 590 | */ |
| 591 | void peribox_slot_device::set_genmod(bool set) |
| 592 | { |
| 593 | m_card->m_genmod = set; |
| 594 | } |
| 595 | |
| 596 | void peribox_slot_device::device_start(void) |
| 597 | { |
| 598 | if (VERBOSE>7) LOG("Peribox slot started\n"); |
| 599 | } |
| 600 | |
| 601 | void peribox_slot_device::device_config_complete() |
| 602 | { |
| 603 | m_slotnumber = get_index_from_tagname(); |
| 604 | device_t *carddev = first_subdevice(); |
| 605 | peribox_device *peb = static_cast<peribox_device*>(owner()); |
| 606 | if (carddev != NULL) |
| 607 | { |
| 608 | peb->set_slot_loaded(m_slotnumber, this); |
| 609 | m_card = static_cast<ti_expansion_card_device*>(carddev); |
| 610 | } |
| 611 | else |
| 612 | { |
| 613 | peb->set_slot_loaded(m_slotnumber, NULL); |
| 614 | m_card = NULL; |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /* |
| 619 | Delivers the drives that are installed in the box. Called from a card. |
| 620 | */ |
| 621 | device_t* peribox_slot_device::get_drive(const char* name) |
| 622 | { |
| 623 | return owner()->subdevice(name); |
| 624 | } |
| 625 | |
| 626 | /* |
| 627 | These methods are called from the expansion cards. They add the |
| 628 | slot number to identify the slot to the box. |
| 629 | */ |
| 630 | WRITE_LINE_MEMBER( peribox_slot_device::set_inta ) |
| 631 | { |
| 632 | peribox_device *peb = static_cast<peribox_device*>(owner()); |
| 633 | peb->inta_join(m_slotnumber, state); |
| 634 | } |
| 635 | |
| 636 | WRITE_LINE_MEMBER( peribox_slot_device::set_intb ) |
| 637 | { |
| 638 | peribox_device *peb = static_cast<peribox_device*>(owner()); |
| 639 | peb->intb_join(m_slotnumber, state); |
| 640 | } |
| 641 | |
| 642 | WRITE_LINE_MEMBER( peribox_slot_device::set_ready ) |
| 643 | { |
| 644 | peribox_device *peb = static_cast<peribox_device*>(owner()); |
| 645 | peb->ready_join(m_slotnumber, state); |
| 646 | } |
| 647 | |
| 648 | /***************************************************************************/ |
| 649 | const device_type PERIBOX = &device_creator<peribox_device>; |
| 650 | const device_type PERIBOX_SLOT = &device_creator<peribox_slot_device>; |
| 651 | |
| 652 | const device_type PERIBOX_EV = &device_creator<peribox_ev_device>; |
| 653 | const device_type PERIBOX_SG = &device_creator<peribox_sg_device>; |
| 654 | const device_type PERIBOX_GEN = &device_creator<peribox_gen_device>; |
| 655 | |
| 656 | |
src/mess/machine/smc92x4.c
| r14513 | r14514 | |
| 1 | 1 | /* |
| 2 | | HDC9224 and HDC9234 Hard and Floppy Disk Controller (HFDC) |
| 2 | HDC9224 and HDC9234 Hard and Floppy Disk Controller |
| 3 | 3 | |
| 4 | 4 | This controller handles MFM and FM encoded floppy disks and hard disks. |
| 5 | 5 | The SMC9224 is used in some DEC systems. The HDC9234 is used in the |
| r14513 | r14514 | |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | #include "emu.h" |
| 19 | | #include "formats/imageutl.h" |
| 20 | | #include "imagedev/flopdrv.h" |
| 21 | | #include "imagedev/harddriv.h" |
| 22 | | #include "harddisk.h" |
| 23 | | |
| 24 | 19 | #include "smc92x4.h" |
| 25 | 20 | |
| 26 | 21 | /*************************************************************************** |
| r14513 | r14514 | |
| 134 | 129 | |
| 135 | 130 | #define MAX_SECTOR_LEN 256 |
| 136 | 131 | |
| 137 | | #define FORMAT_LONG FALSE |
| 132 | #define FORMAT_LONG false |
| 138 | 133 | |
| 139 | 134 | #define ERROR 0 |
| 140 | 135 | #define DONE 1 |
| 141 | 136 | #define AGAIN 2 |
| 142 | 137 | #define UNDEF 3 |
| 143 | 138 | |
| 144 | | typedef struct _smc92x4_state |
| 139 | enum |
| 145 | 140 | { |
| 146 | | devcb_resolved_write_line out_intrq_func; /* INT line */ |
| 147 | | devcb_resolved_write_line out_dip_func; /* DMA in progress line */ |
| 148 | | devcb_resolved_write8 out_auxbus_func; /* AB0-7 lines (using S0,S1 as address) */ |
| 149 | | devcb_resolved_read_line in_auxbus_func; /* AB0-7 lines (only single case) */ |
| 141 | DATA_TIMER, |
| 142 | READ_TIMER, |
| 143 | WRITE_TIMER, |
| 144 | SEEK_TIMER, |
| 145 | TRACK_TIMER |
| 146 | }; |
| 150 | 147 | |
| 151 | | UINT8 output1; /* UDC-internal register "output1" */ |
| 152 | | UINT8 output2; /* UDC-internal register "output2" */ |
| 153 | | |
| 154 | | int selected_drive_type; |
| 155 | | // We need to store the types, although this is not the case in the |
| 156 | | // real hardware. The reason is that poll_drives wants to select the |
| 157 | | // drives without knowing their kinds. In reality this does not matter, |
| 158 | | // since we only check for the seek_complete line, but in our case, |
| 159 | | // floppy and harddrive are pretty different, and we need to know which |
| 160 | | // one to check. |
| 161 | | int types[4]; |
| 162 | | int head_load_delay_enable; |
| 163 | | int register_pointer; |
| 164 | | |
| 165 | | UINT8 register_r[12]; |
| 166 | | UINT8 register_w[12]; |
| 167 | | |
| 168 | | /* timers to delay execution/completion of commands */ |
| 169 | | emu_timer *timer_data, *timer_rs, *timer_ws, *timer_seek, *timer_track; |
| 170 | | |
| 171 | | /* Flag which determines whether to use realistic timing. */ |
| 172 | | int use_real_timing; |
| 173 | | |
| 174 | | /* Required to store the current iteration within restore. */ |
| 175 | | int seek_count; |
| 176 | | |
| 177 | | /* Recent command. */ |
| 178 | | UINT8 command; |
| 179 | | |
| 180 | | /* Stores the step direction. */ |
| 181 | | int step_direction; |
| 182 | | |
| 183 | | /* Stores the buffered flag. */ |
| 184 | | int buffered; |
| 185 | | |
| 186 | | /* Stores the recent id field. */ |
| 187 | | chrn_id_hd recent_id; |
| 188 | | |
| 189 | | /* Indicates whether an ID has been found. */ |
| 190 | | int found_id; |
| 191 | | |
| 192 | | /* Indicates whether we are already past the seek_id phase in read/write sector. */ |
| 193 | | int after_seek; |
| 194 | | |
| 195 | | /* Determines whether the command will be continued. */ |
| 196 | | int to_be_continued; |
| 197 | | |
| 198 | | /* Pointer to interface */ |
| 199 | | const smc92x4_interface *intf; |
| 200 | | |
| 201 | | } smc92x4_state; |
| 202 | | |
| 203 | 148 | /* |
| 204 | 149 | Step rates in microseconds for MFM. This is set in the mode register, |
| 205 | 150 | bits 0-2. Single density doubles all values. |
| r14513 | r14514 | |
| 242 | 187 | #define VERBOSE 1 |
| 243 | 188 | #define LOG logerror |
| 244 | 189 | |
| 245 | | /*************************************************************************** |
| 246 | | PROTOTYPES |
| 247 | | ***************************************************************************/ |
| 248 | | |
| 249 | | static void smc92x4_process_after_callback(device_t *device); |
| 250 | | static void data_transfer_read(device_t *device, chrn_id_hd id, int transfer_enable); |
| 251 | | static void data_transfer_write(device_t *device, chrn_id_hd id, int deldata, int redcur, int precomp, int write_long); |
| 252 | | |
| 253 | | #if 0 |
| 254 | | static void dump_contents(UINT8 *buffer, int length) |
| 190 | smc92x4_device::smc92x4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 191 | : device_t(mconfig, SMC92X4, "SMC 9224/9234 Hard/Floppy Disk Controller", tag, owner, clock) |
| 255 | 192 | { |
| 256 | | for (int i=0; i < length; i+=16) |
| 257 | | { |
| 258 | | for (int j=0; j < 16; j+=2) |
| 259 | | { |
| 260 | | printf("%02x%02x ", buffer[i+j], buffer[i+j+1]); |
| 261 | | } |
| 262 | | printf("\n"); |
| 263 | | } |
| 264 | 193 | } |
| 265 | | #endif |
| 266 | 194 | |
| 267 | | INLINE smc92x4_state *get_safe_token(device_t *device) |
| 195 | int smc92x4_device::image_is_single_density() |
| 268 | 196 | { |
| 269 | | assert(device != NULL); |
| 270 | | return (smc92x4_state *)downcast<legacy_device_base *>(device)->token(); |
| 271 | | } |
| 272 | | |
| 273 | | |
| 274 | | static int image_is_single_density(device_t *current_floppy) |
| 275 | | { |
| 276 | | floppy_image_legacy *image = flopimg_get_image(current_floppy); |
| 197 | floppy_image_legacy *image = flopimg_get_image(m_drive); |
| 277 | 198 | return (floppy_get_track_size(image, 0, 0)<4000); |
| 278 | 199 | } |
| 279 | 200 | |
| 280 | | static int controller_set_to_single_density(device_t *device) |
| 201 | bool smc92x4_device::in_single_density_mode() |
| 281 | 202 | { |
| 282 | | smc92x4_state *w = get_safe_token(device); |
| 283 | | return ((w->register_w[MODE]&MO_DENSITY)!=0); |
| 203 | return ((m_register_w[MODE]&MO_DENSITY)!=0); |
| 284 | 204 | } |
| 285 | 205 | |
| 286 | | static void copyid(chrn_id id1, chrn_id_hd *id2) |
| 206 | void smc92x4_device::copyid(chrn_id id1, chrn_id_hd *id2) |
| 287 | 207 | { |
| 288 | 208 | id2->C = id1.C & 0xff; |
| 289 | 209 | id2->H = id1.H; |
| r14513 | r14514 | |
| 296 | 216 | /* |
| 297 | 217 | Set IRQ |
| 298 | 218 | */ |
| 299 | | static void smc92x4_set_interrupt(device_t *device) |
| 219 | void smc92x4_device::set_interrupt() |
| 300 | 220 | { |
| 301 | | smc92x4_state *w = get_safe_token(device); |
| 302 | | if ((w->register_r[INT_STATUS] & ST_INTPEND) == 0) |
| 221 | if ((m_register_r[INT_STATUS] & ST_INTPEND) == 0) |
| 303 | 222 | { |
| 304 | | w->register_r[INT_STATUS] |= ST_INTPEND; |
| 305 | | w->out_intrq_func(ASSERT_LINE); |
| 223 | m_register_r[INT_STATUS] |= ST_INTPEND; |
| 224 | m_out_intrq(ASSERT_LINE); |
| 306 | 225 | } |
| 307 | 226 | } |
| 308 | 227 | |
| 309 | 228 | /* |
| 310 | | Set DMA in progress |
| 311 | | */ |
| 312 | | static void smc92x4_set_dip(device_t *device, int value) |
| 313 | | { |
| 314 | | smc92x4_state *w = get_safe_token(device); |
| 315 | | w->out_dip_func(value); |
| 316 | | } |
| 317 | | |
| 318 | | /* |
| 319 | 229 | Assert Command Done status bit, triggering interrupts as needed |
| 320 | 230 | */ |
| 321 | | static void set_command_done(device_t *device, int flags) |
| 231 | void smc92x4_device::set_command_done(int flags) |
| 322 | 232 | { |
| 323 | | //assert(! (w->status & ST_DONE)) |
| 324 | | smc92x4_state *w = get_safe_token(device); |
| 325 | | if (VERBOSE>7) LOG("smc92x4 command %02x done, flags=%02x\n", w->command, flags); |
| 233 | //assert(! (m_status & ST_DONE)) |
| 234 | if (VERBOSE>7) LOG("smc92x4 command %02x done, flags=%02x\n", m_command, flags); |
| 326 | 235 | |
| 327 | | w->register_r[INT_STATUS] |= ST_DONE; |
| 328 | | w->register_r[INT_STATUS] &= ~ST_TERMCOD; /* clear the previously set flags */ |
| 329 | | w->register_r[INT_STATUS] |= flags; |
| 236 | m_register_r[INT_STATUS] |= ST_DONE; |
| 237 | m_register_r[INT_STATUS] &= ~ST_TERMCOD; /* clear the previously set flags */ |
| 238 | m_register_r[INT_STATUS] |= flags; |
| 330 | 239 | |
| 331 | 240 | /* sm92x4 spec, p. 6 */ |
| 332 | | if (w->register_w[INT_COMM_TERM] & TC_INTDONE) |
| 333 | | smc92x4_set_interrupt(device); |
| 241 | if (m_register_w[INT_COMM_TERM] & TC_INTDONE) |
| 242 | set_interrupt(); |
| 334 | 243 | } |
| 335 | 244 | |
| 336 | 245 | /* |
| 337 | 246 | Preserve previously set termination code |
| 338 | 247 | */ |
| 339 | | static void set_command_done(device_t *device) |
| 248 | void smc92x4_device::set_command_done() |
| 340 | 249 | { |
| 341 | | //assert(! (w->status & ST_DONE)) |
| 342 | | smc92x4_state *w = get_safe_token(device); |
| 343 | | if (VERBOSE>7) LOG("smc92x4 command %02x done\n", w->command); |
| 250 | //assert(! (m_status & ST_DONE)) |
| 251 | if (VERBOSE>7) LOG("smc92x4 command %02x done\n", m_command); |
| 344 | 252 | |
| 345 | | w->register_r[INT_STATUS] |= ST_DONE; |
| 253 | m_register_r[INT_STATUS] |= ST_DONE; |
| 346 | 254 | |
| 347 | 255 | /* sm92x4 spec, p. 6 */ |
| 348 | | if (w->register_w[INT_COMM_TERM] & TC_INTDONE) |
| 349 | | smc92x4_set_interrupt(device); |
| 256 | if (m_register_w[INT_COMM_TERM] & TC_INTDONE) |
| 257 | set_interrupt(); |
| 350 | 258 | } |
| 351 | 259 | |
| 352 | 260 | /* |
| 353 | 261 | Clear IRQ |
| 354 | 262 | */ |
| 355 | | static void smc92x4_clear_interrupt(device_t *device) |
| 263 | void smc92x4_device::clear_interrupt() |
| 356 | 264 | { |
| 357 | | smc92x4_state *w = get_safe_token(device); |
| 358 | | if ((w->register_r[INT_STATUS] & ST_INTPEND) != 0) |
| 359 | | { |
| 360 | | w->out_intrq_func(CLEAR_LINE); |
| 361 | | } |
| 265 | if ((m_register_r[INT_STATUS] & ST_INTPEND) != 0) |
| 266 | m_out_intrq(CLEAR_LINE); |
| 362 | 267 | } |
| 363 | 268 | |
| 364 | 269 | /* |
| 365 | 270 | Sets the DMA address on the external counter. This counter is attached |
| 366 | 271 | to the auxiliary bus on the PCB. |
| 367 | 272 | */ |
| 368 | | static void set_dma_address(device_t *device, int pos2316, int pos1508, int pos0700) |
| 273 | void smc92x4_device::set_dma_address(int pos2316, int pos1508, int pos0700) |
| 369 | 274 | { |
| 370 | | smc92x4_state *w = get_safe_token(device); |
| 371 | | w->out_auxbus_func(OUTPUT_DMA_ADDR, w->register_r[pos2316]); |
| 372 | | w->out_auxbus_func(OUTPUT_DMA_ADDR, w->register_r[pos1508]); |
| 373 | | w->out_auxbus_func(OUTPUT_DMA_ADDR, w->register_r[pos0700]); |
| 275 | m_out_auxbus(OUTPUT_DMA_ADDR, m_register_r[pos2316]); |
| 276 | m_out_auxbus(OUTPUT_DMA_ADDR, m_register_r[pos1508]); |
| 277 | m_out_auxbus(OUTPUT_DMA_ADDR, m_register_r[pos0700]); |
| 374 | 278 | } |
| 375 | 279 | |
| 376 | | static void dma_add_offset(device_t *device, int offset) |
| 280 | void smc92x4_device::dma_add_offset(int offset) |
| 377 | 281 | { |
| 378 | | smc92x4_state *w = get_safe_token(device); |
| 379 | | int dma_address = (w->register_w[DMA23_16]<<16) + (w->register_w[DMA15_8]<<8) + w->register_w[DMA7_0]; |
| 282 | int dma_address = (m_register_w[DMA23_16]<<16) + (m_register_w[DMA15_8]<<8) + m_register_w[DMA7_0]; |
| 380 | 283 | dma_address += offset; |
| 381 | 284 | |
| 382 | | w->register_w[DMA23_16] = w->register_r[DMA23_16] = (dma_address & 0xff0000)>>16; |
| 383 | | w->register_w[DMA15_8] = w->register_r[DMA15_8] = (dma_address & 0x00ff00)>>8; |
| 384 | | w->register_w[DMA7_0] = w->register_r[DMA7_0] = (dma_address & 0x0000ff); |
| 285 | m_register_w[DMA23_16] = m_register_r[DMA23_16] = (dma_address & 0xff0000)>>16; |
| 286 | m_register_w[DMA15_8] = m_register_r[DMA15_8] = (dma_address & 0x00ff00)>>8; |
| 287 | m_register_w[DMA7_0] = m_register_r[DMA7_0] = (dma_address & 0x0000ff); |
| 385 | 288 | } |
| 386 | 289 | |
| 387 | 290 | /* |
| r14513 | r14514 | |
| 390 | 293 | both the hard and floppy drives during S0=S1=0 and STB*=0 times via the |
| 391 | 294 | auxiliary bus. |
| 392 | 295 | */ |
| 393 | | static void sync_status_in(device_t *device) |
| 296 | void smc92x4_device::sync_status_in() |
| 394 | 297 | { |
| 395 | 298 | UINT8 prev; |
| 396 | | smc92x4_state *w = get_safe_token(device); |
| 299 | prev = m_register_r[DRIVE_STATUS]; |
| 300 | m_register_r[DRIVE_STATUS] = m_in_auxbus(0); |
| 397 | 301 | |
| 398 | | prev = w->register_r[DRIVE_STATUS]; |
| 399 | | w->register_r[DRIVE_STATUS] = w->in_auxbus_func(); |
| 400 | | |
| 401 | 302 | /* Raise interrupt if ready changes. TODO: Check this more closely. */ |
| 402 | | if (((w->register_r[DRIVE_STATUS] & DS_READY) != (prev & DS_READY)) |
| 403 | | & (w->register_r[INT_STATUS] & ST_RDYCHNG)) |
| 303 | if (((m_register_r[DRIVE_STATUS] & DS_READY) != (prev & DS_READY)) |
| 304 | & (m_register_r[INT_STATUS] & ST_RDYCHNG)) |
| 404 | 305 | { |
| 405 | | smc92x4_set_interrupt(device); |
| 306 | set_interrupt(); |
| 406 | 307 | } |
| 407 | 308 | } |
| 408 | 309 | |
| r14513 | r14514 | |
| 410 | 311 | Push the output registers over the auxiliary bus. It is expected that |
| 411 | 312 | the PCB contains latches to store the values. |
| 412 | 313 | */ |
| 413 | | static void sync_latches_out(device_t *device) |
| 314 | void smc92x4_device::sync_latches_out() |
| 414 | 315 | { |
| 415 | | smc92x4_state *w = get_safe_token(device); |
| 416 | | w->output1 = (w->output1 & 0xf0) | (w->register_w[RETRY_COUNT]&0x0f); |
| 417 | | |
| 418 | | w->out_auxbus_func(OUTPUT_OUTPUT1, w->output1); |
| 419 | | w->out_auxbus_func(OUTPUT_OUTPUT2, w->output2); |
| 316 | m_output1 = (m_output1 & 0xf0) | (m_register_w[RETRY_COUNT]&0x0f); |
| 317 | m_out_auxbus(OUTPUT_OUTPUT1, m_output1); |
| 318 | m_out_auxbus(OUTPUT_OUTPUT2, m_output2); |
| 420 | 319 | } |
| 421 | 320 | |
| 422 | 321 | /************************************************************* |
| r14513 | r14514 | |
| 424 | 323 | *************************************************************/ |
| 425 | 324 | #if 0 |
| 426 | 325 | /* setup a timed data request - data request will be triggered in a few usecs time */ |
| 427 | | static void smc92x4_timed_data_request(device_t *device) |
| 326 | void smc92x4_device::timed_data_request() |
| 428 | 327 | { |
| 429 | | smc92x4_state *w = get_safe_token(device); |
| 430 | | int time = controller_set_to_single_density(device)? 128 : 32; |
| 328 | int time = in_single_density_mode()? 128 : 32; |
| 431 | 329 | |
| 432 | | if (!w->use_real_timing) |
| 330 | if (!m_use_real_timing) |
| 433 | 331 | time = 1; |
| 434 | 332 | |
| 435 | 333 | /* set new timer */ |
| 436 | | w->timer_data->adjust(attotime::from_usec(time)); |
| 334 | m_timer_data->adjust(attotime::from_usec(time)); |
| 437 | 335 | } |
| 438 | 336 | #endif |
| 439 | 337 | |
| 440 | 338 | /* setup a timed read sector - read sector will be triggered in a few usecs time */ |
| 441 | | static void smc92x4_timed_sector_read_request(device_t *device) |
| 339 | void smc92x4_device::timed_sector_read_request() |
| 442 | 340 | { |
| 443 | | smc92x4_state *w = get_safe_token(device); |
| 444 | 341 | int time=0; |
| 445 | 342 | |
| 446 | | /* set new timer */ |
| 447 | | /* Average time from sector to sector. */ |
| 448 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 449 | | time = (controller_set_to_single_density(device))? 30000 : 15000; |
| 343 | // set new timer |
| 344 | // Average time from sector to sector. |
| 345 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 346 | time = (in_single_density_mode())? 30000 : 15000; |
| 450 | 347 | else |
| 451 | 348 | time = 1000; |
| 452 | 349 | |
| 453 | | if (!w->use_real_timing) |
| 350 | if (!m_use_real_timing) |
| 454 | 351 | time = 1; |
| 455 | 352 | |
| 456 | | w->timer_rs->adjust(attotime::from_usec(time)); |
| 457 | | w->to_be_continued = TRUE; |
| 353 | m_timer_rs->adjust(attotime::from_usec(time)); |
| 354 | m_to_be_continued = true; |
| 458 | 355 | } |
| 459 | 356 | |
| 460 | 357 | /* setup a timed write sector - write sector will be triggered in a few usecs time */ |
| 461 | | static void smc92x4_timed_sector_write_request(device_t *device) |
| 358 | void smc92x4_device::timed_sector_write_request() |
| 462 | 359 | { |
| 463 | | smc92x4_state *w = get_safe_token(device); |
| 464 | 360 | int time=0; |
| 465 | 361 | |
| 466 | 362 | /* Average time from sector to sector. */ |
| 467 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 468 | | time = (controller_set_to_single_density(device))? 30000 : 15000; |
| 363 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 364 | time = (in_single_density_mode())? 30000 : 15000; |
| 469 | 365 | else |
| 470 | 366 | time = 1000; |
| 471 | 367 | |
| 472 | | if (!w->use_real_timing) |
| 368 | if (!m_use_real_timing) |
| 473 | 369 | time = 1; |
| 474 | 370 | |
| 475 | | w->timer_ws->adjust(attotime::from_usec(time)); |
| 476 | | w->to_be_continued = TRUE; |
| 371 | m_timer_ws->adjust(attotime::from_usec(time)); |
| 372 | m_to_be_continued = true; |
| 477 | 373 | } |
| 478 | 374 | |
| 479 | 375 | /* |
| 480 | 376 | Set up a timed track read/write |
| 481 | 377 | */ |
| 482 | | static void smc92x4_timed_track_request(device_t *device) |
| 378 | void smc92x4_device::timed_track_request() |
| 483 | 379 | { |
| 484 | | smc92x4_state *w = get_safe_token(device); |
| 485 | 380 | int time = 0; |
| 486 | 381 | |
| 487 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 382 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 488 | 383 | time = TRACKTIME_FLOPPY; |
| 489 | 384 | else |
| 490 | 385 | time = TRACKTIME_HD; |
| 491 | 386 | |
| 492 | | if (!w->use_real_timing) |
| 387 | if (!m_use_real_timing) |
| 493 | 388 | time = 1; |
| 494 | 389 | |
| 495 | | w->timer_track->adjust(attotime::from_usec(time)); |
| 390 | m_timer_track->adjust(attotime::from_usec(time)); |
| 496 | 391 | |
| 497 | | w->to_be_continued = TRUE; |
| 392 | m_to_be_continued = true; |
| 498 | 393 | } |
| 499 | 394 | |
| 500 | 395 | /* |
| 501 | 396 | Set up a timed track seek |
| 502 | 397 | */ |
| 503 | | static void smc92x4_timed_seek_request(device_t *device) |
| 398 | void smc92x4_device::timed_seek_request() |
| 504 | 399 | { |
| 505 | | smc92x4_state *w = get_safe_token(device); |
| 506 | 400 | int time = 0; |
| 507 | 401 | |
| 508 | | int index = w->register_w[MODE] & MO_STEPRATE; |
| 509 | | int fm = controller_set_to_single_density(device); |
| 402 | int index = m_register_w[MODE] & MO_STEPRATE; |
| 403 | int fm = in_single_density_mode(); |
| 510 | 404 | |
| 511 | 405 | /* Get seek time. */ |
| 512 | | if ((w->selected_drive_type & DRIVE_TYPE) == TYPE_FLOPPY8) |
| 406 | if ((m_selected_drive_type & DRIVE_TYPE) == TYPE_FLOPPY8) |
| 513 | 407 | time = step_flop8[index]; |
| 514 | 408 | |
| 515 | | else if ((w->selected_drive_type & DRIVE_TYPE) == TYPE_FLOPPY5) |
| 409 | else if ((m_selected_drive_type & DRIVE_TYPE) == TYPE_FLOPPY5) |
| 516 | 410 | time = step_flop5[index]; |
| 517 | 411 | else |
| 518 | 412 | time = step_hd[index]; |
| r14513 | r14514 | |
| 520 | 414 | if (fm) |
| 521 | 415 | time = time * 2; |
| 522 | 416 | |
| 523 | | if (!w->use_real_timing) |
| 417 | if (!m_use_real_timing) |
| 524 | 418 | { |
| 525 | 419 | if (VERBOSE>5) LOG("smc92x4 info: Disk access without delays\n"); |
| 526 | 420 | time = 1; |
| 527 | 421 | } |
| 528 | | |
| 529 | | w->timer_seek->adjust(attotime::from_usec(time)); |
| 530 | | w->to_be_continued = TRUE; |
| 422 | m_timer_seek->adjust(attotime::from_usec(time)); |
| 423 | m_to_be_continued = true; |
| 531 | 424 | } |
| 532 | 425 | |
| 533 | | #if 0 |
| 534 | | static TIMER_CALLBACK(smc92x4_data_callback) |
| 426 | void smc92x4_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 535 | 427 | { |
| 536 | | /* device_t *device = (device_t *)ptr; |
| 537 | | smc92x4_state *w = get_safe_token(device); */ |
| 538 | | } |
| 539 | | #endif |
| 428 | int transfer_enabled; |
| 429 | int deldata; |
| 430 | int redcur; |
| 431 | int precomp; |
| 432 | int write_long; |
| 433 | mfm_harddisk_device *harddisk; |
| 540 | 434 | |
| 541 | | static TIMER_CALLBACK(smc92x4_read_sector_callback) |
| 542 | | { |
| 543 | | device_t *device = (device_t *)ptr; |
| 544 | | smc92x4_state *w = get_safe_token(device); |
| 545 | | int transfer_enabled = w->command & 0x01; |
| 435 | switch (id) |
| 436 | { |
| 437 | case DATA_TIMER: |
| 438 | // Not implemented yet |
| 439 | break; |
| 440 | case READ_TIMER: |
| 441 | transfer_enabled = m_command & 0x01; |
| 442 | // Now read the sector. |
| 443 | data_transfer_read(m_recent_id, transfer_enabled); |
| 444 | sync_status_in(); |
| 445 | break; |
| 446 | case WRITE_TIMER: |
| 447 | deldata = m_command & 0x10; |
| 448 | redcur = m_command & 0x08; |
| 449 | precomp = m_command & 0x07; |
| 450 | write_long = ((m_register_w[MODE]& MO_CRCECC)==0x40); |
| 546 | 451 | |
| 547 | | /* Now read the sector. */ |
| 548 | | data_transfer_read(device, w->recent_id, transfer_enabled); |
| 549 | | sync_status_in(device); |
| 550 | | smc92x4_process_after_callback(device); |
| 551 | | } |
| 452 | if (deldata) |
| 453 | if (VERBOSE>0) LOG("smc92x4 warn: Write deleted data mark not supported. Writing normal mark.\n"); |
| 552 | 454 | |
| 553 | | static TIMER_CALLBACK(smc92x4_write_sector_callback) |
| 554 | | { |
| 555 | | device_t *device = (device_t *)ptr; |
| 556 | | smc92x4_state *w = get_safe_token(device); |
| 557 | | int deldata = w->command & 0x10; |
| 558 | | int redcur = w->command & 0x08; |
| 559 | | int precomp = w->command & 0x07; |
| 560 | | int write_long = ((w->register_w[MODE]& MO_CRCECC)==0x40); |
| 455 | // Now write the sector. |
| 456 | data_transfer_write(m_recent_id, deldata, redcur, precomp, write_long); |
| 457 | sync_status_in(); |
| 458 | break; |
| 459 | case SEEK_TIMER: |
| 460 | // Callback for seek request. |
| 461 | /* int buffered = ((m_register_w[MODE] & MO_STEPRATE)==0); */ |
| 462 | /* int buffered = (m_command & 0x01); */ |
| 561 | 463 | |
| 562 | | if (deldata) |
| 563 | | if (VERBOSE>0) LOG("smc92x4 warn: Write deleted data mark not supported. Writing normal mark.\n"); |
| 564 | | |
| 565 | | /* Now write the sector. */ |
| 566 | | data_transfer_write(device, w->recent_id, deldata, redcur, precomp, write_long); |
| 567 | | sync_status_in(device); |
| 568 | | smc92x4_process_after_callback(device); |
| 569 | | } |
| 570 | | |
| 571 | | /* |
| 572 | | Callback for track access. Nothing interesting here, just used for |
| 573 | | delaying. |
| 574 | | */ |
| 575 | | static TIMER_CALLBACK(smc92x4_track_callback) |
| 576 | | { |
| 577 | | device_t *device = (device_t *)ptr; |
| 578 | | sync_status_in(device); |
| 579 | | smc92x4_process_after_callback(device); |
| 580 | | } |
| 581 | | |
| 582 | | /* |
| 583 | | Callback for seek request. |
| 584 | | */ |
| 585 | | static TIMER_CALLBACK(smc92x4_seek_callback) |
| 586 | | { |
| 587 | | device_t *device = (device_t *)ptr; |
| 588 | | smc92x4_state *w = get_safe_token(device); |
| 589 | | device_t *current_floppy = NULL; |
| 590 | | /* int buffered = ((w->register_w[MODE] & MO_STEPRATE)==0); */ |
| 591 | | /* int buffered = (w->command & 0x01); */ |
| 592 | | |
| 593 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 594 | | { |
| 595 | | current_floppy = (*w->intf->current_floppy)(device); |
| 596 | | if (current_floppy==NULL) |
| 464 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 597 | 465 | { |
| 598 | | if (VERBOSE>0) LOG("smc92x4 error: seek callback: no floppy\n"); |
| 599 | | w->register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 466 | if (m_drive==NULL) |
| 467 | { |
| 468 | if (VERBOSE>0) LOG("smc92x4 error: seek callback: no floppy\n"); |
| 469 | m_register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | if (VERBOSE>5) LOG("smc92x4 step %s direction %d\n", m_drive->tag(), m_step_direction); |
| 474 | floppy_drive_seek(m_drive, m_step_direction); |
| 475 | } |
| 600 | 476 | } |
| 601 | 477 | else |
| 602 | 478 | { |
| 603 | | if (VERBOSE>5) LOG("smc92x4 step %s direction %d\n", current_floppy->tag(), w->step_direction); |
| 604 | | floppy_drive_seek(current_floppy, w->step_direction); |
| 479 | if (VERBOSE>6) LOG("smc92x4 step harddisk direction %d\n", m_step_direction); |
| 480 | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 481 | harddisk->seek(m_step_direction); |
| 605 | 482 | } |
| 483 | sync_status_in(); |
| 484 | break; |
| 485 | case TRACK_TIMER: |
| 486 | // Callback for track access. Nothing interesting here, just used for |
| 487 | // delaying. |
| 488 | break; |
| 606 | 489 | } |
| 607 | | else |
| 608 | | { |
| 609 | | if (VERBOSE>6) LOG("smc92x4 step harddisk direction %d\n", w->step_direction); |
| 610 | | (*w->intf->mfmhd_seek)(device, w->step_direction); |
| 611 | | } |
| 612 | | sync_status_in(device); |
| 613 | | |
| 614 | | smc92x4_process_after_callback(device); |
| 490 | process_after_callback(); |
| 615 | 491 | } |
| 616 | 492 | |
| 493 | |
| 617 | 494 | /********************************************************************* |
| 618 | 495 | Common functions |
| 619 | 496 | *********************************************************************/ |
| r14513 | r14514 | |
| 623 | 500 | define idents beyond cylinder 1023, but formatting programs seem to |
| 624 | 501 | continue with 0xfd for cylinders between 1024 and 2047. |
| 625 | 502 | */ |
| 626 | | UINT8 cylinder_to_ident(int cylinder) |
| 503 | UINT8 smc92x4_device::cylinder_to_ident(int cylinder) |
| 627 | 504 | { |
| 628 | 505 | if (cylinder < 256) return 0xfe; |
| 629 | 506 | if (cylinder < 512) return 0xff; |
| r14513 | r14514 | |
| 636 | 513 | Calculate the offset from the ident. This is only useful for AT drives; |
| 637 | 514 | these drives cannot have more than 1024 cylinders. |
| 638 | 515 | */ |
| 639 | | static int ident_to_cylinder(UINT8 ident) |
| 516 | int smc92x4_device::ident_to_cylinder(UINT8 ident) |
| 640 | 517 | { |
| 641 | 518 | switch (ident) |
| 642 | 519 | { |
| r14513 | r14514 | |
| 651 | 528 | /* |
| 652 | 529 | Common function to set the read registers from the recently read id. |
| 653 | 530 | */ |
| 654 | | static void update_id_regs(device_t *device, chrn_id_hd id) |
| 531 | void smc92x4_device::update_id_regs(chrn_id_hd id) |
| 655 | 532 | { |
| 656 | 533 | // Flags for current head register. Note that the sizes are not in |
| 657 | 534 | // sequence (128, 256, 512, 1024). This is only interesting for AT |
| 658 | 535 | // mode. |
| 659 | 536 | static const UINT8 sizeflag[] = { 0x60, 0x00, 0x20, 0x40 }; |
| 660 | | smc92x4_state *w = get_safe_token(device); |
| 661 | 537 | |
| 662 | | w->register_r[CURRENT_CYLINDER] = id.C & 0xff; |
| 538 | m_register_r[CURRENT_CYLINDER] = id.C & 0xff; |
| 539 | m_register_r[CURRENT_HEAD] = id.H & 0x0f; |
| 663 | 540 | |
| 664 | | w->register_r[CURRENT_HEAD] = id.H & 0x0f; |
| 665 | | |
| 666 | 541 | if (id.flags & BAD_SECTOR) |
| 667 | | w->register_r[CURRENT_HEAD] |= 0x80; |
| 542 | m_register_r[CURRENT_HEAD] |= 0x80; |
| 668 | 543 | |
| 669 | | if ((w->selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 670 | | w->register_r[CURRENT_HEAD] |= sizeflag[id.N]; |
| 544 | if ((m_selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 545 | m_register_r[CURRENT_HEAD] |= sizeflag[id.N]; |
| 671 | 546 | else |
| 672 | | w->register_r[CURRENT_HEAD] |= ((id.C & 0x700)>>4); |
| 547 | m_register_r[CURRENT_HEAD] |= ((id.C & 0x700)>>4); |
| 673 | 548 | |
| 674 | | w->register_r[CURRENT_IDENT] = cylinder_to_ident(id.C); |
| 549 | m_register_r[CURRENT_IDENT] = cylinder_to_ident(id.C); |
| 675 | 550 | } |
| 676 | 551 | |
| 677 | 552 | /* |
| 678 | 553 | Common procedure: read_id_field (as described in the specification) |
| 679 | 554 | */ |
| 680 | | static void read_id_field(device_t *device, int *steps, int *direction, chrn_id_hd *id) |
| 555 | void smc92x4_device::read_id_field(int *steps, int *direction, chrn_id_hd *id) |
| 681 | 556 | { |
| 682 | | smc92x4_state *w = get_safe_token(device); |
| 683 | 557 | int des_cylinder, cur_cylinder; |
| 684 | | int found = FALSE; |
| 685 | | sync_latches_out(device); |
| 686 | | sync_status_in(device); |
| 558 | bool found = false; |
| 559 | mfm_harddisk_device *harddisk; |
| 687 | 560 | |
| 561 | sync_latches_out(); |
| 562 | sync_status_in(); |
| 563 | |
| 688 | 564 | // Set command termination code. The error code is set first, and |
| 689 | 565 | // on success, it is cleared. |
| 690 | | w->register_r[INT_STATUS] |= ST_TC_RDIDERR; |
| 566 | m_register_r[INT_STATUS] |= ST_TC_RDIDERR; |
| 691 | 567 | |
| 692 | 568 | /* Try to find an ID field. */ |
| 693 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 569 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 694 | 570 | { |
| 695 | 571 | chrn_id idflop; |
| 696 | | device_t *disk_img = (*w->intf->current_floppy)(device); |
| 697 | | if (flopimg_get_image(disk_img) == NULL) |
| 572 | if (flopimg_get_image(m_drive) == NULL) |
| 698 | 573 | { |
| 699 | 574 | if (VERBOSE>2) LOG("smc92x4 warn: No disk in drive\n"); |
| 700 | | w->register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 575 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 701 | 576 | return; |
| 702 | 577 | } |
| 703 | 578 | |
| 704 | 579 | /* Check whether image and controller are set to the same density. */ |
| 705 | | if ((image_is_single_density(disk_img) && controller_set_to_single_density(device)) |
| 706 | | || (!image_is_single_density(disk_img) && !controller_set_to_single_density(device)) |
| 707 | | ) |
| 580 | if ((image_is_single_density() && in_single_density_mode()) |
| 581 | || (!image_is_single_density() && !in_single_density_mode())) |
| 708 | 582 | { |
| 709 | | found = floppy_drive_get_next_id(disk_img, w->register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 583 | found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 710 | 584 | copyid(idflop, id); /* Need to use bigger values for HD, but we don't use separate variables here */ |
| 711 | 585 | } |
| 712 | 586 | else |
| 713 | 587 | { |
| 714 | 588 | if (VERBOSE>2) LOG("smc92x4 warn: Controller and medium density do not match.\n"); |
| 715 | 589 | } |
| 716 | | sync_status_in(device); |
| 590 | sync_status_in(); |
| 717 | 591 | |
| 718 | 592 | if (!found) |
| 719 | 593 | { |
| 720 | 594 | if (VERBOSE>1) LOG("smc92x4 error: read_id_field (floppy): sync error\n"); |
| 721 | | w->register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 595 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 722 | 596 | return; |
| 723 | 597 | } |
| 724 | 598 | } |
| 725 | 599 | else |
| 726 | 600 | { |
| 727 | | (*w->intf->mfmhd_get_next_id)(device, w->register_w[DESIRED_HEAD]&0x0f, id); |
| 728 | | sync_status_in(device); |
| 729 | | if (!(w->register_r[DRIVE_STATUS]& DS_READY)) |
| 601 | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 602 | |
| 603 | harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 604 | sync_status_in(); |
| 605 | if (!(m_register_r[DRIVE_STATUS]& DS_READY)) |
| 730 | 606 | { |
| 731 | 607 | if (VERBOSE>1) LOG("smc92x4 error: read_id_field (harddisk): sync error\n"); |
| 732 | | w->register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 608 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 733 | 609 | return; |
| 734 | 610 | } |
| 735 | 611 | } |
| 736 | 612 | |
| 737 | | w->register_r[CHIP_STATUS] &= ~CS_SYNCERR; |
| 613 | m_register_r[CHIP_STATUS] &= ~CS_SYNCERR; |
| 738 | 614 | |
| 739 | 615 | /* Update the registers. */ |
| 740 | | update_id_regs(device, *id); |
| 616 | update_id_regs(*id); |
| 741 | 617 | |
| 742 | 618 | if (id->flags & BAD_CRC) |
| 743 | 619 | { |
| 744 | | w->register_r[CHIP_STATUS] |= CS_CRCERR; |
| 620 | m_register_r[CHIP_STATUS] |= CS_CRCERR; |
| 745 | 621 | return; |
| 746 | 622 | } |
| 747 | 623 | |
| 748 | 624 | /* Calculate the steps. */ |
| 749 | | if ((w->selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 625 | if ((m_selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 750 | 626 | { |
| 751 | 627 | /* Note: the spec says CURRENT_REGISTER, but that seems wrong. */ |
| 752 | | des_cylinder = ((w->register_r[DATA] & 0x03)<<8) | w->register_w[DESIRED_CYLINDER]; |
| 753 | | cur_cylinder = ident_to_cylinder(w->register_r[CURRENT_IDENT]) + w->register_r[CURRENT_CYLINDER]; |
| 628 | des_cylinder = ((m_register_r[DATA] & 0x03)<<8) | m_register_w[DESIRED_CYLINDER]; |
| 629 | cur_cylinder = ident_to_cylinder(m_register_r[CURRENT_IDENT]) + m_register_r[CURRENT_CYLINDER]; |
| 754 | 630 | } |
| 755 | 631 | else |
| 756 | 632 | { |
| 757 | | des_cylinder = ((w->register_w[DESIRED_HEAD] & 0x70)<<4) | w->register_w[DESIRED_CYLINDER]; |
| 758 | | cur_cylinder = ((w->register_r[CURRENT_HEAD] & 0x70)<<4) | w->register_r[CURRENT_CYLINDER]; |
| 633 | des_cylinder = ((m_register_w[DESIRED_HEAD] & 0x70)<<4) | m_register_w[DESIRED_CYLINDER]; |
| 634 | cur_cylinder = ((m_register_r[CURRENT_HEAD] & 0x70)<<4) | m_register_r[CURRENT_CYLINDER]; |
| 759 | 635 | } |
| 760 | 636 | |
| 761 | 637 | if (des_cylinder >= cur_cylinder) |
| r14513 | r14514 | |
| 771 | 647 | |
| 772 | 648 | if (VERBOSE>6) LOG("smc92x4 seek required: %d steps\n", *steps); |
| 773 | 649 | |
| 774 | | w->register_r[INT_STATUS] &= ~ST_TC_RDIDERR; |
| 775 | | return; |
| 650 | m_register_r[INT_STATUS] &= ~ST_TC_RDIDERR; |
| 776 | 651 | } |
| 777 | 652 | |
| 778 | 653 | /* |
| 779 | 654 | Common procedure: verify (as described in the specification) |
| 780 | 655 | */ |
| 781 | | static int verify(device_t *device, chrn_id_hd *id, int check_sector) |
| 656 | int smc92x4_device::verify(chrn_id_hd *id, bool check_sector) |
| 782 | 657 | { |
| 783 | | smc92x4_state *w = get_safe_token(device); |
| 784 | 658 | int maxtry = 132; /* approx. 33792/(256*32) */ |
| 785 | 659 | int pass = 0; |
| 786 | | int found = FALSE; |
| 787 | | int foundsect = FALSE; |
| 660 | int found = false; |
| 661 | int foundsect = false; |
| 788 | 662 | int des_cylinder = 0; |
| 663 | mfm_harddisk_device *harddisk; |
| 789 | 664 | |
| 790 | 665 | // Set command termination code. The error code is set first, and |
| 791 | 666 | // on success, it is cleared. |
| 792 | | w->register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 667 | m_register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 793 | 668 | |
| 794 | 669 | while (pass < maxtry && !foundsect) |
| 795 | 670 | { |
| 796 | 671 | pass++; |
| 797 | 672 | /* Try to find an ID field. */ |
| 798 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 673 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 799 | 674 | { |
| 800 | 675 | chrn_id idflop; |
| 801 | | device_t *disk_img = (*w->intf->current_floppy)(device); |
| 802 | | found = floppy_drive_get_next_id(disk_img, w->register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 676 | found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop); |
| 803 | 677 | copyid(idflop, id); |
| 804 | 678 | if (/* pass==1 && */!found) |
| 805 | 679 | { |
| 806 | | w->register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 680 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 807 | 681 | if (VERBOSE>1) LOG("smc92x4 error: verify (floppy): sync error\n"); |
| 808 | 682 | return ERROR; |
| 809 | 683 | } |
| 810 | 684 | } |
| 811 | 685 | else |
| 812 | 686 | { |
| 813 | | (*w->intf->mfmhd_get_next_id)(device, w->register_w[DESIRED_HEAD]&0x0f, id); |
| 814 | | sync_status_in(device); |
| 815 | | if (!(w->register_r[DRIVE_STATUS]& DS_READY)) |
| 687 | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 688 | harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id); |
| 689 | sync_status_in(); |
| 690 | if (!(m_register_r[DRIVE_STATUS]& DS_READY)) |
| 816 | 691 | { |
| 817 | 692 | if (VERBOSE>1) LOG("smc92x4 error: verify (harddisk): sync error\n"); |
| 818 | | w->register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 693 | m_register_r[CHIP_STATUS] |= CS_SYNCERR; |
| 819 | 694 | return ERROR; |
| 820 | 695 | } |
| 821 | 696 | } |
| 822 | 697 | |
| 823 | | w->register_r[CHIP_STATUS] &= ~CS_SYNCERR; |
| 698 | m_register_r[CHIP_STATUS] &= ~CS_SYNCERR; |
| 824 | 699 | |
| 825 | 700 | /* Compare with the desired sector ID. */ |
| 826 | | if ((w->selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 701 | if ((m_selected_drive_type & DRIVE_TYPE) == TYPE_AT) |
| 827 | 702 | { |
| 828 | 703 | /* Note: the spec says CURRENT_CYLINDER, but that seems wrong. */ |
| 829 | | des_cylinder = ((w->register_r[DATA] & 0x03)<<8) | w->register_w[DESIRED_CYLINDER]; |
| 704 | des_cylinder = ((m_register_r[DATA] & 0x03)<<8) | m_register_w[DESIRED_CYLINDER]; |
| 830 | 705 | } |
| 831 | 706 | else |
| 832 | 707 | { |
| 833 | | des_cylinder = ((w->register_w[DESIRED_HEAD] & 0x70)<<4) | w->register_w[DESIRED_CYLINDER]; |
| 708 | des_cylinder = ((m_register_w[DESIRED_HEAD] & 0x70)<<4) | m_register_w[DESIRED_CYLINDER]; |
| 834 | 709 | } |
| 835 | | if (VERBOSE>6) LOG("smc92x4 check id: current = (%d,%d,%d), required = (%d,%d,%d)\n", id->C, id->H, id->R, des_cylinder, w->register_w[DESIRED_HEAD] & 0x0f, w->register_w[DESIRED_SECTOR]); |
| 710 | if (VERBOSE>6) LOG("smc92x4 check id: current = (%d,%d,%d), required = (%d,%d,%d)\n", id->C, id->H, id->R, des_cylinder, m_register_w[DESIRED_HEAD] & 0x0f, m_register_w[DESIRED_SECTOR]); |
| 836 | 711 | if ((des_cylinder == id->C) |
| 837 | | && ((w->register_w[DESIRED_HEAD] & 0x0f) == id->H)) |
| 712 | && ((m_register_w[DESIRED_HEAD] & 0x0f) == id->H)) |
| 838 | 713 | { |
| 839 | | if (!check_sector || (w->register_w[DESIRED_SECTOR] == id->R)) |
| 840 | | foundsect = TRUE; |
| 714 | if (!check_sector || (m_register_w[DESIRED_SECTOR] == id->R)) |
| 715 | foundsect = true; |
| 841 | 716 | } |
| 842 | 717 | } |
| 843 | 718 | if (!foundsect) |
| 844 | 719 | { |
| 845 | | w->register_r[CHIP_STATUS] |= CS_COMPERR; |
| 846 | | if (VERBOSE>1) LOG("smc92x4 error: verify: sector not found, seek error (desired cyl=%d/sec=%d, current cyl=%d/sec=%d)\n", des_cylinder, w->register_w[DESIRED_SECTOR], id->C, id->R); |
| 720 | m_register_r[CHIP_STATUS] |= CS_COMPERR; |
| 721 | if (VERBOSE>1) LOG("smc92x4 error: verify: sector not found, seek error (desired cyl=%d/sec=%d, current cyl=%d/sec=%d)\n", des_cylinder, m_register_w[DESIRED_SECTOR], id->C, id->R); |
| 847 | 722 | return ERROR; |
| 848 | 723 | } |
| 849 | 724 | |
| 850 | | w->register_r[INT_STATUS] &= ~ST_TC_SEEKERR; |
| 725 | m_register_r[INT_STATUS] &= ~ST_TC_SEEKERR; |
| 851 | 726 | return DONE; |
| 852 | 727 | } |
| 853 | 728 | |
| 854 | 729 | /* |
| 855 | 730 | Common procedure: data_transfer(read) (as described in the specification) |
| 856 | 731 | */ |
| 857 | | static void data_transfer_read(device_t *device, chrn_id_hd id, int transfer_enable) |
| 732 | void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable) |
| 858 | 733 | { |
| 859 | 734 | int i, retry, sector_len; |
| 860 | | smc92x4_state *w = get_safe_token(device); |
| 861 | | device_t *current_floppy = NULL; |
| 735 | mfm_harddisk_device *harddisk; |
| 862 | 736 | |
| 863 | 737 | int sector_data_id; |
| 864 | 738 | UINT8 *buf; |
| 865 | 739 | |
| 866 | | sync_latches_out(device); |
| 867 | | sync_status_in(device); |
| 740 | sync_latches_out(); |
| 741 | sync_status_in(); |
| 868 | 742 | |
| 869 | | current_floppy = (*w->intf->current_floppy)(device); |
| 870 | | |
| 871 | 743 | // Set command termination code. The error code is set first, and |
| 872 | 744 | // on success, it is cleared. |
| 873 | | w->register_r[INT_STATUS] |= ST_TC_DATAERR; |
| 745 | m_register_r[INT_STATUS] |= ST_TC_DATAERR; |
| 874 | 746 | |
| 875 | 747 | // Save the value. Note that the retry count is only in the first four |
| 876 | 748 | // bits, and it is stored in one's complement. In this implementation |
| 877 | 749 | // we don't work with it. |
| 878 | | retry = w->register_w[RETRY_COUNT]; |
| 750 | retry = m_register_w[RETRY_COUNT]; |
| 879 | 751 | |
| 880 | 752 | /* We are already at the correct sector (found by the verify sequence) */ |
| 881 | 753 | |
| 882 | 754 | /* Find the data sync mark. Easy, we assume it has been found. */ |
| 883 | 755 | |
| 884 | 756 | if (id.flags & ID_FLAG_DELETED_DATA) |
| 885 | | w->register_r[CHIP_STATUS] |= CS_DELDATA; |
| 757 | m_register_r[CHIP_STATUS] |= CS_DELDATA; |
| 886 | 758 | else |
| 887 | | w->register_r[CHIP_STATUS] &= ~CS_DELDATA; |
| 759 | m_register_r[CHIP_STATUS] &= ~CS_DELDATA; |
| 888 | 760 | |
| 889 | 761 | /* Found. Now update the current cylinder/head registers. */ |
| 890 | | update_id_regs(device, id); |
| 762 | update_id_regs(id); |
| 891 | 763 | |
| 892 | 764 | /* Initiate the DMA. We assume the DMARQ is positive. */ |
| 893 | | w->register_r[INT_STATUS] &= ~ST_OVRUN; |
| 765 | m_register_r[INT_STATUS] &= ~ST_OVRUN; |
| 894 | 766 | |
| 895 | 767 | sector_len = 1 << (id.N+7); |
| 896 | 768 | sector_data_id = id.data_id; |
| 769 | buf = (UINT8 *)malloc(sector_len); |
| 897 | 770 | |
| 898 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 771 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 899 | 772 | { |
| 900 | | buf = (UINT8 *)malloc(sector_len); |
| 901 | | floppy_drive_read_sector_data(current_floppy, id.H, sector_data_id, buf, sector_len); |
| 773 | floppy_drive_read_sector_data(m_drive, id.H, sector_data_id, buf, sector_len); |
| 902 | 774 | } |
| 903 | 775 | else |
| 904 | 776 | { |
| 905 | | /* buf is allocated within the function, and sector_len is also set */ |
| 906 | | (*w->intf->mfmhd_read_sector)(device, id.C, id.H, id.R, &buf, §or_len); |
| 777 | // TODO: Should we get the sector length from the harddisk? |
| 778 | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 779 | harddisk->read_sector(id.C, id.H, id.R, buf); |
| 907 | 780 | } |
| 908 | | sync_status_in(device); |
| 781 | sync_status_in(); |
| 909 | 782 | |
| 910 | 783 | if (transfer_enable) |
| 911 | 784 | { |
| 912 | 785 | /* Copy via DMA into controller RAM. */ |
| 913 | | set_dma_address(device, DMA23_16, DMA15_8, DMA7_0); |
| 786 | set_dma_address(DMA23_16, DMA15_8, DMA7_0); |
| 914 | 787 | |
| 915 | | smc92x4_set_dip(device, TRUE); |
| 788 | m_out_dip(ASSERT_LINE); |
| 916 | 789 | for (i=0; i < sector_len; i++) |
| 917 | 790 | { |
| 918 | | (*w->intf->dma_write_callback)(device, buf[i]); |
| 791 | m_out_dma(0, buf[i]); |
| 919 | 792 | } |
| 920 | | smc92x4_set_dip(device, FALSE); |
| 793 | m_out_dip(CLEAR_LINE); |
| 921 | 794 | } |
| 922 | 795 | free(buf); |
| 923 | 796 | |
| 924 | 797 | /* Check CRC. We assume everything is OK, no retry required. */ |
| 925 | | w->register_r[CHIP_STATUS] &= ~CS_RETREQ; |
| 926 | | w->register_r[CHIP_STATUS] &= ~CS_CRCERR; |
| 927 | | w->register_r[CHIP_STATUS] &= ~CS_ECCATT; |
| 798 | m_register_r[CHIP_STATUS] &= ~CS_RETREQ; |
| 799 | m_register_r[CHIP_STATUS] &= ~CS_CRCERR; |
| 800 | m_register_r[CHIP_STATUS] &= ~CS_ECCATT; |
| 928 | 801 | |
| 929 | 802 | /* Update the DMA registers. */ |
| 930 | | if (transfer_enable) |
| 931 | | dma_add_offset(device, sector_len); |
| 803 | if (transfer_enable) dma_add_offset(sector_len); |
| 932 | 804 | |
| 933 | 805 | /* Decrement sector count. */ |
| 934 | | w->register_w[SECTOR_COUNT] = (w->register_w[SECTOR_COUNT]-1)&0xff; |
| 806 | m_register_w[SECTOR_COUNT] = (m_register_w[SECTOR_COUNT]-1)&0xff; |
| 935 | 807 | |
| 936 | 808 | /* Clear the error bits. */ |
| 937 | | w->register_r[INT_STATUS] &= ~ST_TC_DATAERR; |
| 809 | m_register_r[INT_STATUS] &= ~ST_TC_DATAERR; |
| 938 | 810 | |
| 939 | | if (w->register_w[SECTOR_COUNT] == 0) |
| 811 | if (m_register_w[SECTOR_COUNT] == 0) |
| 940 | 812 | return; |
| 941 | 813 | |
| 942 | 814 | /* Else this is a multi-sector operation. */ |
| 943 | | w->register_w[DESIRED_SECTOR] = |
| 944 | | w->register_r[DESIRED_SECTOR] = |
| 945 | | (w->register_w[DESIRED_SECTOR]+1) & 0xff; |
| 815 | m_register_w[DESIRED_SECTOR] = |
| 816 | m_register_r[DESIRED_SECTOR] = |
| 817 | (m_register_w[DESIRED_SECTOR]+1) & 0xff; |
| 946 | 818 | |
| 947 | 819 | /* Reinitialize retry count. */ |
| 948 | | w->register_w[RETRY_COUNT] = retry; |
| 820 | m_register_w[RETRY_COUNT] = retry; |
| 949 | 821 | } |
| 950 | 822 | |
| 951 | 823 | /* |
| 952 | 824 | Common procedure: data_transfer(write) (as described in the specification) |
| 953 | 825 | */ |
| 954 | | static void data_transfer_write(device_t *device, chrn_id_hd id, int deldata, int redcur, int precomp, int write_long) |
| 826 | void smc92x4_device::data_transfer_write(chrn_id_hd id, int deldata, int redcur, int precomp, bool write_long) |
| 955 | 827 | { |
| 956 | 828 | int retry, i, sector_len; |
| 957 | | smc92x4_state *w = get_safe_token(device); |
| 958 | | device_t *current_floppy = NULL; |
| 959 | 829 | UINT8 *buf; |
| 960 | 830 | int sector_data_id; |
| 831 | mfm_harddisk_device *harddisk; |
| 832 | sync_latches_out(); |
| 833 | sync_status_in(); |
| 961 | 834 | |
| 962 | | sync_latches_out(device); |
| 963 | | sync_status_in(device); |
| 964 | | |
| 965 | | current_floppy = (*w->intf->current_floppy)(device); |
| 966 | | |
| 967 | 835 | // Set command termination code. The error code is set first, and |
| 968 | 836 | // on success, it is cleared. |
| 969 | | w->register_r[INT_STATUS] |= ST_TC_DATAERR; |
| 837 | m_register_r[INT_STATUS] |= ST_TC_DATAERR; |
| 970 | 838 | |
| 971 | 839 | // Save the value. Note that the retry count is only in the first four |
| 972 | 840 | // bits, and it is stored in one's complement. In this implementation |
| 973 | 841 | // we don't work with it. |
| 974 | | retry = w->register_w[RETRY_COUNT]; |
| 842 | retry = m_register_w[RETRY_COUNT]; |
| 975 | 843 | |
| 976 | 844 | /* Initiate the DMA. We assume the DMARQ is positive. */ |
| 977 | | w->register_r[INT_STATUS] &= ~ST_OVRUN; |
| 845 | m_register_r[INT_STATUS] &= ~ST_OVRUN; |
| 978 | 846 | |
| 979 | 847 | sector_len = 1 << (id.N+7); |
| 980 | 848 | sector_data_id = id.data_id; |
| r14513 | r14514 | |
| 982 | 850 | buf = (UINT8 *)malloc(sector_len); |
| 983 | 851 | |
| 984 | 852 | /* Copy via DMA from controller RAM. */ |
| 985 | | set_dma_address(device, DMA23_16, DMA15_8, DMA7_0); |
| 853 | set_dma_address(DMA23_16, DMA15_8, DMA7_0); |
| 986 | 854 | |
| 987 | | smc92x4_set_dip(device, TRUE); |
| 855 | m_out_dip(ASSERT_LINE); |
| 988 | 856 | for (i=0; i<sector_len; i++) |
| 989 | 857 | { |
| 990 | | buf[i] = (*w->intf->dma_read_callback)(device); |
| 858 | buf[i] = m_in_dma(0); |
| 991 | 859 | } |
| 992 | | smc92x4_set_dip(device, FALSE); |
| 860 | m_out_dip(CLEAR_LINE); |
| 993 | 861 | |
| 994 | 862 | if (write_long) |
| 995 | 863 | { |
| 996 | 864 | if (VERBOSE>1) LOG("smc92x4 warn: write sector: Write_long not supported. Performing a normal write.\n"); |
| 997 | 865 | } |
| 998 | 866 | |
| 999 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 867 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 1000 | 868 | { |
| 1001 | | floppy_drive_write_sector_data(current_floppy, id.H, sector_data_id, (char *) buf, sector_len, FALSE); |
| 869 | floppy_drive_write_sector_data(m_drive, id.H, sector_data_id, (char *) buf, sector_len, false); |
| 1002 | 870 | } |
| 1003 | 871 | else |
| 1004 | 872 | { |
| 1005 | | (*w->intf->mfmhd_write_sector)(device, id.C, id.H, id.R, buf, sector_len); |
| 873 | harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 874 | harddisk->write_sector(id.C, id.H, id.R, buf); |
| 1006 | 875 | } |
| 1007 | 876 | free(buf); |
| 1008 | | sync_status_in(device); |
| 877 | sync_status_in(); |
| 1009 | 878 | |
| 1010 | | w->register_r[CHIP_STATUS] &= ~CS_RETREQ; |
| 1011 | | w->register_r[CHIP_STATUS] &= ~CS_CRCERR; |
| 1012 | | w->register_r[CHIP_STATUS] &= ~CS_ECCATT; |
| 879 | m_register_r[CHIP_STATUS] &= ~CS_RETREQ; |
| 880 | m_register_r[CHIP_STATUS] &= ~CS_CRCERR; |
| 881 | m_register_r[CHIP_STATUS] &= ~CS_ECCATT; |
| 1013 | 882 | |
| 1014 | 883 | /* Update the DMA registers. */ |
| 1015 | | dma_add_offset(device, sector_len); |
| 884 | dma_add_offset(sector_len); |
| 1016 | 885 | |
| 1017 | 886 | /* Decrement sector count. */ |
| 1018 | | w->register_w[SECTOR_COUNT] = (w->register_w[SECTOR_COUNT]-1)&0xff; |
| 887 | m_register_w[SECTOR_COUNT] = (m_register_w[SECTOR_COUNT]-1)&0xff; |
| 1019 | 888 | |
| 1020 | 889 | /* Clear the error bits. */ |
| 1021 | | w->register_r[INT_STATUS] &= ~ST_TC_DATAERR; |
| 890 | m_register_r[INT_STATUS] &= ~ST_TC_DATAERR; |
| 1022 | 891 | |
| 1023 | | if (w->register_w[SECTOR_COUNT] == 0) |
| 1024 | | return; |
| 892 | if (m_register_w[SECTOR_COUNT] == 0) return; |
| 1025 | 893 | |
| 1026 | 894 | /* Else this is a multi-sector operation. */ |
| 1027 | | w->register_w[DESIRED_SECTOR] = |
| 1028 | | w->register_r[DESIRED_SECTOR] = |
| 1029 | | (w->register_w[DESIRED_SECTOR]+1) & 0xff; |
| 895 | m_register_w[DESIRED_SECTOR] = m_register_r[DESIRED_SECTOR] = (m_register_w[DESIRED_SECTOR]+1) & 0xff; |
| 1030 | 896 | |
| 1031 | 897 | /* Reinitialize retry count. */ |
| 1032 | | w->register_w[RETRY_COUNT] = retry; |
| 898 | m_register_w[RETRY_COUNT] = retry; |
| 1033 | 899 | } |
| 1034 | 900 | |
| 1035 | | static void read_sectors_continue(device_t *device); |
| 1036 | | static void write_sectors_continue(device_t *device); |
| 1037 | | |
| 1038 | 901 | /* |
| 1039 | 902 | Read sectors physical / logical. Physical means that the first, the |
| 1040 | 903 | second, the third sector appearing under the head will be read. These |
| 1041 | 904 | sectors are usually not in logical sequence. The ordering depends on |
| 1042 | 905 | the interleave pattern. |
| 1043 | 906 | */ |
| 1044 | | static void read_write_sectors(device_t *device) |
| 907 | void smc92x4_device::read_write_sectors() |
| 1045 | 908 | { |
| 1046 | | smc92x4_state *w = get_safe_token(device); |
| 909 | int logical = m_command & 0x04; |
| 910 | int implied_seek_disabled = m_command & 0x02; /* for read */ |
| 911 | int write = (m_command & 0x80); |
| 1047 | 912 | |
| 1048 | | int logical = w->command & 0x04; |
| 1049 | | int implied_seek_disabled = w->command & 0x02; /* for read */ |
| 1050 | | int write = (w->command & 0x80); |
| 913 | m_after_seek = false; |
| 1051 | 914 | |
| 1052 | | w->after_seek = FALSE; |
| 915 | m_to_be_continued = false; |
| 1053 | 916 | |
| 1054 | | w->to_be_continued = FALSE; |
| 1055 | | |
| 1056 | 917 | if (write) /* write sectors */ |
| 1057 | 918 | { |
| 1058 | | logical = w->command & 0x20; |
| 1059 | | implied_seek_disabled = w->command & 0x40; |
| 919 | logical = m_command & 0x20; |
| 920 | implied_seek_disabled = m_command & 0x40; |
| 1060 | 921 | } |
| 1061 | 922 | |
| 1062 | 923 | if (!logical) |
| 1063 | | implied_seek_disabled = FALSE; |
| 924 | implied_seek_disabled = false; |
| 1064 | 925 | |
| 1065 | | if (!w->found_id) |
| 926 | if (!m_found_id) |
| 1066 | 927 | { |
| 1067 | 928 | /* First start. */ |
| 1068 | | read_id_field(device, &w->seek_count, &w->step_direction, &w->recent_id); |
| 929 | read_id_field(&m_seek_count, &m_step_direction, &m_recent_id); |
| 1069 | 930 | } |
| 1070 | 931 | |
| 1071 | | if ((w->register_r[INT_STATUS] & ST_TC_DATAERR) == ST_TC_SUCCESS) |
| 932 | if ((m_register_r[INT_STATUS] & ST_TC_DATAERR) == ST_TC_SUCCESS) |
| 1072 | 933 | { |
| 1073 | | w->found_id = TRUE; |
| 934 | m_found_id = true; |
| 1074 | 935 | /* Perform the seek for the cylinder. */ |
| 1075 | | if (!implied_seek_disabled && w->seek_count > 0) |
| 936 | if (!implied_seek_disabled && m_seek_count > 0) |
| 1076 | 937 | { |
| 1077 | | smc92x4_timed_seek_request(device); |
| 938 | timed_seek_request(); |
| 1078 | 939 | } |
| 1079 | 940 | else |
| 1080 | 941 | { |
| 1081 | | if (write) |
| 1082 | | write_sectors_continue(device); |
| 1083 | | else |
| 1084 | | read_sectors_continue(device); |
| 942 | if (write) write_sectors_continue(); |
| 943 | else read_sectors_continue(); |
| 1085 | 944 | } |
| 1086 | | |
| 1087 | 945 | } |
| 1088 | 946 | else |
| 1089 | 947 | { |
| 1090 | | set_command_done(device, ST_TC_RDIDERR); |
| 948 | set_command_done(ST_TC_RDIDERR); |
| 1091 | 949 | } |
| 1092 | 950 | } |
| 1093 | 951 | |
| 1094 | 952 | |
| 1095 | | static void read_sectors_continue(device_t *device) |
| 953 | void smc92x4_device::read_sectors_continue() |
| 1096 | 954 | { |
| 1097 | | smc92x4_state *w = get_safe_token(device); |
| 1098 | | |
| 1099 | | int check_sector = TRUE; /* always check the first sector */ |
| 955 | bool check_sector = true; /* always check the first sector */ |
| 1100 | 956 | int state = AGAIN; |
| 1101 | | int logical = w->command & 0x04; |
| 957 | int logical = m_command & 0x04; |
| 1102 | 958 | |
| 1103 | 959 | /* Needed for the two ways of re-entry: during the seek process, and during sector read */ |
| 1104 | | if (!w->after_seek) |
| 960 | if (!m_after_seek) |
| 1105 | 961 | { |
| 1106 | 962 | if (VERBOSE>7) LOG("smc92x4 continue with sector read\n"); |
| 1107 | | w->seek_count--; |
| 1108 | | if (w->seek_count > 0) |
| 963 | m_seek_count--; |
| 964 | if (m_seek_count > 0) |
| 1109 | 965 | { |
| 1110 | | read_write_sectors(device); |
| 966 | read_write_sectors(); |
| 1111 | 967 | return; |
| 1112 | 968 | } |
| 1113 | | w->after_seek = TRUE; |
| 969 | m_after_seek = true; |
| 1114 | 970 | } |
| 1115 | 971 | else |
| 1116 | 972 | { |
| 1117 | 973 | /* we are here after the sector read. */ |
| 1118 | | w->to_be_continued = FALSE; |
| 1119 | | if (w->register_r[INT_STATUS] & ST_TERMCOD) |
| 974 | m_to_be_continued = false; |
| 975 | if (m_register_r[INT_STATUS] & ST_TERMCOD) |
| 1120 | 976 | { |
| 1121 | | if (VERBOSE>1) LOG("smc92x4 error: data error during sector read: INTSTATUS=%02x\n", w->register_r[INT_STATUS]); |
| 1122 | | set_command_done(device, ST_TC_DATAERR); |
| 977 | if (VERBOSE>1) LOG("smc92x4 error: data error during sector read: INTSTATUS=%02x\n", m_register_r[INT_STATUS]); |
| 978 | set_command_done(ST_TC_DATAERR); |
| 1123 | 979 | return; |
| 1124 | 980 | } |
| 1125 | 981 | } |
| 1126 | 982 | |
| 1127 | | w->to_be_continued = FALSE; |
| 983 | m_to_be_continued = false; |
| 1128 | 984 | |
| 1129 | 985 | /* Wait for SEEK_COMPLETE. We assume the signal has appeared. */ |
| 1130 | 986 | |
| 1131 | | if (w->register_w[SECTOR_COUNT] > 0 /* && !(w->register_r[DRIVE_STATUS] & DS_INDEX) */) |
| 987 | if (m_register_w[SECTOR_COUNT] > 0 /* && !(m_register_r[DRIVE_STATUS] & DS_INDEX) */) |
| 1132 | 988 | { |
| 1133 | 989 | /* Call the verify sequence. */ |
| 1134 | | state = verify(device, &w->recent_id, check_sector); |
| 990 | state = verify(&m_recent_id, check_sector); |
| 1135 | 991 | if (state==ERROR) |
| 1136 | 992 | { |
| 1137 | 993 | // TODO: set command done? |
| r14513 | r14514 | |
| 1141 | 997 | |
| 1142 | 998 | /* For read physical, only verify the first sector. */ |
| 1143 | 999 | if (!logical) |
| 1144 | | check_sector = FALSE; |
| 1000 | check_sector = false; |
| 1145 | 1001 | |
| 1146 | | if (w->recent_id.flags & BAD_SECTOR) |
| 1002 | if (m_recent_id.flags & BAD_SECTOR) |
| 1147 | 1003 | { |
| 1148 | 1004 | if (VERBOSE>0) LOG("smc92x4 error: Bad sector, seek error\n"); |
| 1149 | | set_command_done(device, ST_TC_SEEKERR); |
| 1005 | set_command_done(ST_TC_SEEKERR); |
| 1150 | 1006 | } |
| 1151 | 1007 | else |
| 1152 | 1008 | { |
| 1153 | | smc92x4_timed_sector_read_request(device); |
| 1009 | timed_sector_read_request(); |
| 1154 | 1010 | } |
| 1155 | 1011 | } |
| 1156 | 1012 | else |
| 1157 | 1013 | { |
| 1158 | | set_command_done(device, ST_TC_SUCCESS); |
| 1014 | set_command_done(ST_TC_SUCCESS); |
| 1159 | 1015 | if (VERBOSE>7) LOG("smc92x4 read sector command done\n"); |
| 1160 | 1016 | } |
| 1161 | 1017 | } |
| 1162 | 1018 | |
| 1163 | | static void write_sectors_continue(device_t *device) |
| 1019 | void smc92x4_device::write_sectors_continue() |
| 1164 | 1020 | { |
| 1165 | | smc92x4_state *w = get_safe_token(device); |
| 1166 | | |
| 1167 | | int check_sector = TRUE; /* always check the first sector */ |
| 1021 | bool check_sector = true; /* always check the first sector */ |
| 1168 | 1022 | int state = AGAIN; |
| 1169 | | int logical = w->command & 0x20; |
| 1023 | int logical = m_command & 0x20; |
| 1170 | 1024 | |
| 1171 | 1025 | /* Needed for the two ways of re-entry: during the seek process, and during sector write */ |
| 1172 | | if (!w->after_seek) |
| 1026 | if (!m_after_seek) |
| 1173 | 1027 | { |
| 1174 | | w->seek_count--; |
| 1175 | | if (w->seek_count > 0) |
| 1028 | m_seek_count--; |
| 1029 | if (m_seek_count > 0) |
| 1176 | 1030 | { |
| 1177 | | read_write_sectors(device); |
| 1031 | read_write_sectors(); |
| 1178 | 1032 | return; |
| 1179 | 1033 | } |
| 1180 | | w->after_seek = TRUE; |
| 1034 | m_after_seek = true; |
| 1181 | 1035 | } |
| 1182 | 1036 | else |
| 1183 | 1037 | { |
| 1184 | 1038 | /* we are here after the sector write. */ |
| 1185 | | w->to_be_continued = FALSE; |
| 1186 | | if (w->register_r[INT_STATUS] & ST_TERMCOD) |
| 1039 | m_to_be_continued = false; |
| 1040 | if (m_register_r[INT_STATUS] & ST_TERMCOD) |
| 1187 | 1041 | { |
| 1188 | 1042 | if (VERBOSE>0) LOG("smc92x4 error: data error during sector write\n"); |
| 1189 | | set_command_done(device, ST_TC_DATAERR); |
| 1043 | set_command_done(ST_TC_DATAERR); |
| 1190 | 1044 | return; |
| 1191 | 1045 | } |
| 1192 | 1046 | } |
| 1193 | 1047 | |
| 1194 | | w->to_be_continued = FALSE; |
| 1048 | m_to_be_continued = false; |
| 1195 | 1049 | |
| 1196 | | if ((w->register_w[RETRY_COUNT] & 0xf0)!= 0xf0) |
| 1050 | if ((m_register_w[RETRY_COUNT] & 0xf0)!= 0xf0) |
| 1197 | 1051 | if (VERBOSE>1) LOG("smc92x4 warn: RETRY_COUNT in write sector should be set to 0. Ignored.\n"); |
| 1198 | 1052 | |
| 1199 | 1053 | /* Wait for SEEK_COMPLETE. We assume the signal has appeared. */ |
| 1200 | | if (w->register_w[SECTOR_COUNT] > 0) |
| 1054 | if (m_register_w[SECTOR_COUNT] > 0) |
| 1201 | 1055 | { |
| 1202 | 1056 | /* Call the verify sequence. */ |
| 1203 | | state = verify(device, &w->recent_id, check_sector); |
| 1057 | state = verify(&m_recent_id, check_sector); |
| 1204 | 1058 | if (state==ERROR) |
| 1205 | 1059 | { |
| 1206 | 1060 | if (VERBOSE>0) LOG("smc92x4 error: verify error during sector write\n"); |
| r14513 | r14514 | |
| 1209 | 1063 | |
| 1210 | 1064 | /* For write physical, only verify the first sector. */ |
| 1211 | 1065 | if (!logical) |
| 1212 | | check_sector = FALSE; |
| 1066 | check_sector = false; |
| 1213 | 1067 | |
| 1214 | 1068 | /* printf("smc92x4 write sectors CYL=%02x, HEA=%02x, SEC=%02x, MOD=%02x, CNT=%02x, TRY=%02x\n", |
| 1215 | | w->register_w[DESIRED_CYLINDER], |
| 1216 | | w->register_w[DESIRED_HEAD], |
| 1217 | | w->register_w[DESIRED_SECTOR], |
| 1218 | | w->register_w[MODE], |
| 1219 | | w->register_w[SECTOR_COUNT], |
| 1220 | | w->register_w[RETRY_COUNT]); */ |
| 1221 | | smc92x4_timed_sector_write_request(device); |
| 1069 | m_register_w[DESIRED_CYLINDER], |
| 1070 | m_register_w[DESIRED_HEAD], |
| 1071 | m_register_w[DESIRED_SECTOR], |
| 1072 | m_register_w[MODE], |
| 1073 | m_register_w[SECTOR_COUNT], |
| 1074 | m_register_w[RETRY_COUNT]); */ |
| 1075 | timed_sector_write_request(); |
| 1222 | 1076 | } |
| 1223 | 1077 | else |
| 1224 | 1078 | { |
| 1225 | | set_command_done(device, ST_TC_SUCCESS); |
| 1079 | set_command_done(ST_TC_SUCCESS); |
| 1226 | 1080 | if (VERBOSE>7) LOG("smc92x4 write sector command done\n"); |
| 1227 | 1081 | } |
| 1228 | 1082 | } |
| r14513 | r14514 | |
| 1234 | 1088 | /* |
| 1235 | 1089 | Handle the restore command |
| 1236 | 1090 | */ |
| 1237 | | static void restore_drive(device_t *device) |
| 1091 | void smc92x4_device::restore_drive() |
| 1238 | 1092 | { |
| 1239 | | smc92x4_state *w = get_safe_token(device); |
| 1240 | | |
| 1241 | 1093 | /* TODO: int_after_seek_complete required for buffered seeks */ |
| 1242 | | sync_status_in(device); |
| 1094 | sync_status_in(); |
| 1243 | 1095 | |
| 1244 | | if (w->seek_count>=4096 || !(w->register_r[DRIVE_STATUS] & DS_READY)) |
| 1096 | if (m_seek_count>=4096 || !(m_register_r[DRIVE_STATUS] & DS_READY)) |
| 1245 | 1097 | { |
| 1246 | 1098 | if (VERBOSE>0) LOG("smc92x4 error: seek error in restore\n"); |
| 1247 | | w->register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 1099 | m_register_r[INT_STATUS] |= ST_TC_SEEKERR; |
| 1248 | 1100 | return; |
| 1249 | 1101 | } |
| 1250 | 1102 | |
| 1251 | | if (w->register_r[DRIVE_STATUS] & DS_TRK00) |
| 1103 | if (m_register_r[DRIVE_STATUS] & DS_TRK00) |
| 1252 | 1104 | { |
| 1253 | | w->register_r[INT_STATUS] |= ST_TC_SUCCESS; |
| 1105 | m_register_r[INT_STATUS] |= ST_TC_SUCCESS; |
| 1254 | 1106 | /* Issue interrupt */ |
| 1255 | | smc92x4_set_interrupt(device); |
| 1107 | set_interrupt(); |
| 1256 | 1108 | return; |
| 1257 | 1109 | } |
| 1258 | 1110 | |
| 1259 | | w->step_direction = -1; |
| 1260 | | smc92x4_timed_seek_request(device); |
| 1111 | m_step_direction = -1; |
| 1112 | timed_seek_request(); |
| 1261 | 1113 | } |
| 1262 | 1114 | |
| 1263 | | static void restore_continue(device_t *device) |
| 1115 | void smc92x4_device::restore_continue() |
| 1264 | 1116 | { |
| 1265 | | smc92x4_state *w = get_safe_token(device); |
| 1117 | m_seek_count++; |
| 1266 | 1118 | |
| 1267 | | w->seek_count++; |
| 1268 | | |
| 1269 | 1119 | /* Next iteration */ |
| 1270 | | restore_drive(device); |
| 1120 | restore_drive(); |
| 1271 | 1121 | |
| 1272 | | w->to_be_continued = FALSE; |
| 1122 | m_to_be_continued = false; |
| 1273 | 1123 | } |
| 1274 | 1124 | |
| 1275 | 1125 | /* |
| 1276 | 1126 | Handle the step command. Note that the CURRENT_CYLINDER register is not |
| 1277 | 1127 | updated (this would break the format procedure). |
| 1278 | 1128 | */ |
| 1279 | | static void step_in_out(device_t *device) |
| 1129 | void smc92x4_device::step_in_out() |
| 1280 | 1130 | { |
| 1281 | | smc92x4_state *w = get_safe_token(device); |
| 1282 | | int direction = (w->command & 0x02)? -1 : +1; |
| 1131 | int direction = (m_command & 0x02)? -1 : +1; |
| 1283 | 1132 | // bit 0: 0 -> command ends after last seek pulse, 1 -> command |
| 1284 | 1133 | // ends when the drive asserts the seek complete pin |
| 1285 | | int buffered = w->command & 0x01; |
| 1134 | int buffered = m_command & 0x01; |
| 1286 | 1135 | |
| 1287 | | w->step_direction = direction; |
| 1288 | | w->buffered = buffered; |
| 1136 | m_step_direction = direction; |
| 1137 | m_buffered = (buffered!=0); |
| 1289 | 1138 | |
| 1290 | | smc92x4_timed_seek_request(device); |
| 1139 | timed_seek_request(); |
| 1291 | 1140 | if (VERBOSE>6) LOG("smc92x4 waiting for drive step\n"); |
| 1292 | 1141 | } |
| 1293 | 1142 | |
| 1294 | | static void step_continue(device_t *device) |
| 1143 | void smc92x4_device::step_continue() |
| 1295 | 1144 | { |
| 1296 | | smc92x4_state *w = get_safe_token(device); |
| 1297 | 1145 | if (VERBOSE>7) LOG("smc92x4 step continue\n"); |
| 1298 | | w->to_be_continued = FALSE; |
| 1299 | | set_command_done(device, ST_TC_SUCCESS); |
| 1146 | m_to_be_continued = false; |
| 1147 | set_command_done(ST_TC_SUCCESS); |
| 1300 | 1148 | } |
| 1301 | 1149 | |
| 1302 | | |
| 1303 | | static void drive_select(device_t *device, int drive); |
| 1304 | | |
| 1305 | 1150 | /* |
| 1306 | 1151 | Poll drives |
| 1307 | 1152 | This command is used to find out which drive has complete a buffered |
| 1308 | 1153 | seek (RESTORE, SEEK IN/OUT with BUFFERED set to one) |
| 1309 | 1154 | */ |
| 1310 | | static void poll_drives(device_t *device) |
| 1155 | void smc92x4_device::poll_drives() |
| 1311 | 1156 | { |
| 1312 | 1157 | int mask = 0x08; |
| 1313 | | smc92x4_state *w = get_safe_token(device); |
| 1314 | 1158 | int i; |
| 1315 | | int flags = w->command & 0x0f; |
| 1159 | int flags = m_command & 0x0f; |
| 1316 | 1160 | |
| 1317 | 1161 | /* Spec is unclear: Do we continue to poll the drives after we have checked each |
| 1318 | 1162 | one for the first time? We are not interested in locking up the emulator, so |
| r14513 | r14514 | |
| 1322 | 1166 | if (flags & mask) |
| 1323 | 1167 | { |
| 1324 | 1168 | /* Poll drive */ |
| 1325 | | drive_select(device, i|((w->types[i])<<2)); |
| 1326 | | sync_latches_out(device); |
| 1327 | | sync_status_in(device); |
| 1328 | | if (w->register_r[DRIVE_STATUS] & DS_SKCOM) return; |
| 1169 | drive_select(i|((m_types[i])<<2)); |
| 1170 | if (m_register_r[DRIVE_STATUS] & DS_SKCOM) return; |
| 1329 | 1171 | } |
| 1330 | 1172 | mask = mask>>1; |
| 1331 | 1173 | } |
| 1332 | 1174 | } |
| 1333 | 1175 | |
| 1334 | | static void drive_select(device_t *device, int driveparm) |
| 1176 | void smc92x4_device::drive_select(int driveparm) |
| 1335 | 1177 | { |
| 1336 | | smc92x4_state *w = get_safe_token(device); |
| 1178 | m_output1 = (0x10 << (driveparm & 0x03)) | (m_register_w[RETRY_COUNT]&0x0f); |
| 1179 | m_selected_drive_type = (driveparm>>2) & 0x03; |
| 1180 | m_head_load_delay_enable = (driveparm>>4)&0x01; |
| 1337 | 1181 | |
| 1338 | | w->output1 = (0x10 << (driveparm & 0x03)) | (w->register_w[RETRY_COUNT]&0x0f); |
| 1339 | | w->selected_drive_type = (driveparm>>2) & 0x03; |
| 1340 | | w->head_load_delay_enable = (driveparm>>4)&0x01; |
| 1341 | | |
| 1342 | 1182 | // We need to store the type of the drive for the poll_drives command |
| 1343 | 1183 | // to be able to correctly select the device (floppy or hard disk). |
| 1344 | | w->types[driveparm&0x03] = w->selected_drive_type; |
| 1184 | m_types[driveparm&0x03] = m_selected_drive_type; |
| 1345 | 1185 | |
| 1346 | 1186 | // Copy the DMA registers to registers CURRENT_HEAD, CURRENT_CYLINDER, |
| 1347 | 1187 | // and CURRENT_IDENT. This is required during formatting (p. 14) as the |
| 1348 | 1188 | // format command reuses the registers for formatting parameters. |
| 1349 | | w->register_r[CURRENT_HEAD] = w->register_r[DMA7_0]; |
| 1350 | | w->register_r[CURRENT_CYLINDER] = w->register_r[DMA15_8]; |
| 1351 | | w->register_r[CURRENT_IDENT] = w->register_r[DMA23_16]; |
| 1189 | m_register_r[CURRENT_HEAD] = m_register_r[DMA7_0]; |
| 1190 | m_register_r[CURRENT_CYLINDER] = m_register_r[DMA15_8]; |
| 1191 | m_register_r[CURRENT_IDENT] = m_register_r[DMA23_16]; |
| 1352 | 1192 | |
| 1353 | | sync_latches_out(device); |
| 1354 | | sync_status_in(device); |
| 1193 | sync_latches_out(); |
| 1194 | sync_status_in(); |
| 1355 | 1195 | } |
| 1356 | 1196 | |
| 1357 | 1197 | /* |
| 1358 | 1198 | Command SEEK/READID |
| 1359 | 1199 | */ |
| 1360 | | static void seek_read_id(device_t *device) |
| 1200 | void smc92x4_device::seek_read_id() |
| 1361 | 1201 | { |
| 1362 | | smc92x4_state *w = get_safe_token(device); |
| 1363 | | int step_enable = (w->command & 0x04); |
| 1364 | | int verify_id = (w->command & 0x01); |
| 1365 | | int wait = (w->command & 0x02); |
| 1202 | int step_enable = (m_command & 0x04); |
| 1203 | int verify_id = (m_command & 0x01); |
| 1204 | int wait = (m_command & 0x02); |
| 1366 | 1205 | |
| 1367 | | w->to_be_continued = FALSE; |
| 1206 | m_to_be_continued = false; |
| 1368 | 1207 | |
| 1369 | | if (!w->found_id) |
| 1208 | if (!m_found_id) |
| 1370 | 1209 | { |
| 1371 | 1210 | /* First start. */ |
| 1372 | | read_id_field(device, &w->seek_count, &w->step_direction, &w->recent_id); |
| 1373 | | w->found_id = TRUE; |
| 1211 | read_id_field(&m_seek_count, &m_step_direction, &m_recent_id); |
| 1212 | m_found_id = true; |
| 1374 | 1213 | } |
| 1375 | 1214 | |
| 1376 | | if ((w->register_r[INT_STATUS] & ST_TC_DATAERR) == ST_TC_SUCCESS) |
| 1215 | if ((m_register_r[INT_STATUS] & ST_TC_DATAERR) == ST_TC_SUCCESS) |
| 1377 | 1216 | { |
| 1378 | 1217 | /* Perform the seek for the cylinder. */ |
| 1379 | | if (step_enable && w->seek_count > 0) |
| 1218 | if (step_enable && m_seek_count > 0) |
| 1380 | 1219 | { |
| 1381 | | smc92x4_timed_seek_request(device); |
| 1220 | timed_seek_request(); |
| 1382 | 1221 | } |
| 1383 | 1222 | else |
| 1384 | 1223 | { |
| r14513 | r14514 | |
| 1387 | 1226 | |
| 1388 | 1227 | if (verify_id) |
| 1389 | 1228 | { |
| 1390 | | verify(device, &w->recent_id, TRUE); |
| 1229 | verify(&m_recent_id, true); |
| 1391 | 1230 | } |
| 1392 | 1231 | } |
| 1393 | 1232 | } |
| 1394 | 1233 | else |
| 1395 | 1234 | { |
| 1396 | | set_command_done(device, ST_TC_RDIDERR); |
| 1235 | set_command_done(ST_TC_RDIDERR); |
| 1397 | 1236 | } |
| 1398 | 1237 | } |
| 1399 | 1238 | |
| 1400 | | static void seek_read_id_continue(device_t *device) |
| 1239 | void smc92x4_device::seek_read_id_continue() |
| 1401 | 1240 | { |
| 1402 | | smc92x4_state *w = get_safe_token(device); |
| 1403 | | w->seek_count--; |
| 1404 | | seek_read_id(device); |
| 1405 | | w->to_be_continued = FALSE; |
| 1241 | m_seek_count--; |
| 1242 | seek_read_id(); |
| 1243 | m_to_be_continued = false; |
| 1406 | 1244 | } |
| 1407 | 1245 | |
| 1408 | 1246 | /* |
| r14513 | r14514 | |
| 1480 | 1318 | The formats are determined by setting the flag in the smc92x4 |
| 1481 | 1319 | interface structure. |
| 1482 | 1320 | */ |
| 1483 | | static void format_floppy_track(device_t *device, int flags) |
| 1321 | void smc92x4_device::format_floppy_track(int flags) |
| 1484 | 1322 | { |
| 1485 | | smc92x4_state *w = get_safe_token(device); |
| 1486 | | device_t *current_floppy = NULL; |
| 1487 | | |
| 1488 | 1323 | floppy_image_legacy *floppy; |
| 1489 | 1324 | int i,index,j, exp_size; |
| 1490 | 1325 | int gap0, gap1, gap2, gap3, gap4, sync1, sync2, count, size, fm; |
| r14513 | r14514 | |
| 1498 | 1333 | /* Determine the track size. We cannot allow different sizes in this design. */ |
| 1499 | 1334 | int data_count = 0; |
| 1500 | 1335 | |
| 1501 | | sync_status_in(device); |
| 1336 | sync_status_in(); |
| 1502 | 1337 | |
| 1503 | | current_floppy = (*w->intf->current_floppy)(device); |
| 1504 | | floppy = flopimg_get_image(current_floppy); |
| 1338 | floppy = flopimg_get_image(m_drive); |
| 1505 | 1339 | |
| 1506 | 1340 | if (floppy != NULL) |
| 1507 | 1341 | data_count = floppy_get_track_size(floppy, 0, 0); |
| 1508 | 1342 | |
| 1509 | 1343 | if (data_count==0) |
| 1510 | 1344 | { |
| 1511 | | if (controller_set_to_single_density(device)) |
| 1345 | if (in_single_density_mode()) |
| 1512 | 1346 | data_count = TRKSIZE_SD; |
| 1513 | 1347 | else |
| 1514 | 1348 | data_count = TRKSIZE_DD; |
| r14513 | r14514 | |
| 1517 | 1351 | /* Build buffer */ |
| 1518 | 1352 | buffer = (UINT8*)malloc(data_count); |
| 1519 | 1353 | |
| 1520 | | fm = controller_set_to_single_density(device); |
| 1354 | fm = in_single_density_mode(); |
| 1521 | 1355 | |
| 1522 | | sync2 = (~w->register_w[DESIRED_CYLINDER])&0xff; |
| 1523 | | gap2 = (-w->register_w[DMA23_16])&0xff; |
| 1524 | | count = (~w->register_w[SECTOR_COUNT])&0xff; |
| 1525 | | size = (~w->register_w[RETRY_COUNT])&0xff; |
| 1356 | sync2 = (~m_register_w[DESIRED_CYLINDER])&0xff; |
| 1357 | gap2 = (-m_register_w[DMA23_16])&0xff; |
| 1358 | count = (~m_register_w[SECTOR_COUNT])&0xff; |
| 1359 | size = (~m_register_w[RETRY_COUNT])&0xff; |
| 1526 | 1360 | gap_byte = (fm)? 0xff : 0x4e; |
| 1527 | 1361 | |
| 1528 | | if (w->intf->full_track_layout) |
| 1362 | if (m_full_track_layout) |
| 1529 | 1363 | { |
| 1530 | 1364 | /* Including the index AM. */ |
| 1531 | | gap0 = (-w->register_w[DMA7_0])&0xff; |
| 1532 | | gap1 = (-w->register_w[DMA15_8])&0xff; |
| 1533 | | gap3 = (-w->register_w[DESIRED_SECTOR])&0xff; |
| 1365 | gap0 = (-m_register_w[DMA7_0])&0xff; |
| 1366 | gap1 = (-m_register_w[DMA15_8])&0xff; |
| 1367 | gap3 = (-m_register_w[DESIRED_SECTOR])&0xff; |
| 1534 | 1368 | gap4 = (fm)? 247 : 598; |
| 1535 | 1369 | pre_gap = gap_byte; |
| 1536 | 1370 | sync1 = sync2; |
| r14513 | r14514 | |
| 1558 | 1392 | if (VERBOSE>0) LOG("smc92x4 warn: The current track length in the image (%d) does not match the new track length (%d). Keeping the old length. This will break the image (sorry).\n", data_count, exp_size); |
| 1559 | 1393 | |
| 1560 | 1394 | /* use the backup registers set up during drive_select */ |
| 1561 | | set_dma_address(device, CURRENT_IDENT, CURRENT_CYLINDER, CURRENT_HEAD); |
| 1395 | set_dma_address(CURRENT_IDENT, CURRENT_CYLINDER, CURRENT_HEAD); |
| 1562 | 1396 | |
| 1563 | 1397 | memset(&buffer[index], pre_gap, gap0); |
| 1564 | 1398 | index += gap0; |
| 1565 | 1399 | |
| 1566 | | if (w->intf->full_track_layout) |
| 1400 | if (m_full_track_layout) |
| 1567 | 1401 | { |
| 1568 | 1402 | /* Create the Index AM */ |
| 1569 | 1403 | memset(&buffer[index], 0x00, sync1); |
| r14513 | r14514 | |
| 1591 | 1425 | |
| 1592 | 1426 | buffer[index++] = 0xfe; |
| 1593 | 1427 | |
| 1594 | | smc92x4_set_dip(device, TRUE); |
| 1595 | | // if (!fm) curr_ident = (*w->intf->dma_read_callback)(device); |
| 1596 | | if (!fm) (*w->intf->dma_read_callback)(device); |
| 1597 | | curr_cyl = (*w->intf->dma_read_callback)(device); |
| 1598 | | curr_head = (*w->intf->dma_read_callback)(device); |
| 1599 | | curr_sect = (*w->intf->dma_read_callback)(device); |
| 1600 | | curr_size = (*w->intf->dma_read_callback)(device); |
| 1601 | | smc92x4_set_dip(device, FALSE); |
| 1428 | m_out_dip(ASSERT_LINE); |
| 1429 | // if (!fm) curr_ident = m_in_dma(); |
| 1430 | if (!fm) m_in_dma(0); |
| 1431 | curr_cyl = m_in_dma(0); |
| 1432 | curr_head = m_in_dma(0); |
| 1433 | curr_sect = m_in_dma(0); |
| 1434 | curr_size = m_in_dma(0); |
| 1435 | m_out_dip(CLEAR_LINE); |
| 1602 | 1436 | |
| 1603 | 1437 | buffer[index++] = curr_cyl; |
| 1604 | 1438 | buffer[index++] = curr_head; |
| r14513 | r14514 | |
| 1606 | 1440 | buffer[index++] = curr_size; |
| 1607 | 1441 | |
| 1608 | 1442 | if (j==0) |
| 1609 | | if (VERBOSE>6) LOG("current_floppy=%s, format track %d, head %d\n", current_floppy->tag(), curr_cyl, curr_head); |
| 1443 | if (VERBOSE>6) LOG("current_floppy=%s, format track %d, head %d\n", m_drive->tag(), curr_cyl, curr_head); |
| 1610 | 1444 | |
| 1611 | 1445 | /* Calculate CRC16 (5 bytes for ID) */ |
| 1612 | 1446 | crc = ccitt_crc16(0xffff, &buffer[index-5], 5); |
| r14513 | r14514 | |
| 1643 | 1477 | memset(&buffer[index], gap_byte, gap4); |
| 1644 | 1478 | index += gap4; |
| 1645 | 1479 | |
| 1646 | | floppy_drive_write_track_data_info_buffer(current_floppy, w->register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1480 | floppy_drive_write_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1647 | 1481 | free(buffer); |
| 1648 | | sync_status_in(device); |
| 1482 | sync_status_in(); |
| 1649 | 1483 | } |
| 1650 | 1484 | |
| 1651 | 1485 | /* |
| r14513 | r14514 | |
| 1655 | 1489 | |
| 1656 | 1490 | For more explanations see the comments to format_floppy_track. |
| 1657 | 1491 | */ |
| 1658 | | static void format_harddisk_track(device_t *device, int flags) |
| 1492 | void smc92x4_device::format_harddisk_track(int flags) |
| 1659 | 1493 | { |
| 1660 | | smc92x4_state *w = get_safe_token(device); |
| 1661 | 1494 | int i,index,j; |
| 1662 | 1495 | int gap1, gap2, gap3, gap4, sync, count, size, gap_byte, crc; |
| 1663 | 1496 | UINT8 curr_ident, curr_cyl, curr_head, curr_sect, curr_size; |
| r14513 | r14514 | |
| 1665 | 1498 | int normal_data_mark = flags & 0x10; |
| 1666 | 1499 | int data_count=0; |
| 1667 | 1500 | |
| 1501 | mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 1502 | |
| 1668 | 1503 | UINT8 *buffer; |
| 1669 | 1504 | |
| 1670 | | sync_status_in(device); |
| 1505 | sync_status_in(); |
| 1671 | 1506 | |
| 1672 | 1507 | /* Build buffer */ |
| 1673 | | // gap0 = (-w->register_w[DMA7_0])&0xff; |
| 1674 | | gap1 = (-w->register_w[DMA15_8])&0xff; |
| 1675 | | gap2 = (-w->register_w[DMA23_16])&0xff; |
| 1676 | | gap3 = (-w->register_w[DESIRED_SECTOR])&0xff; |
| 1508 | // gap0 = (-m_register_w[DMA7_0])&0xff; |
| 1509 | gap1 = (-m_register_w[DMA15_8])&0xff; |
| 1510 | gap2 = (-m_register_w[DMA23_16])&0xff; |
| 1511 | gap3 = (-m_register_w[DESIRED_SECTOR])&0xff; |
| 1677 | 1512 | gap4 = 340; |
| 1678 | 1513 | |
| 1679 | | sync = (~w->register_w[DESIRED_CYLINDER])&0xff; |
| 1680 | | count = (~w->register_w[SECTOR_COUNT])&0xff; |
| 1681 | | size = (~w->register_w[RETRY_COUNT])&0xff; |
| 1514 | sync = (~m_register_w[DESIRED_CYLINDER])&0xff; |
| 1515 | count = (~m_register_w[SECTOR_COUNT])&0xff; |
| 1516 | size = (~m_register_w[RETRY_COUNT])&0xff; |
| 1682 | 1517 | |
| 1683 | 1518 | data_count = gap1 + count*(sync+12+gap2+sync+size*128+gap3)+gap4; |
| 1684 | 1519 | |
| 1685 | 1520 | buffer = (UINT8*)malloc(data_count); |
| 1686 | 1521 | |
| 1687 | 1522 | index = 0; |
| 1688 | | // fm = controller_set_to_single_density(device); |
| 1689 | | controller_set_to_single_density(device); |
| 1690 | 1523 | gap_byte = 0x4e; |
| 1691 | 1524 | |
| 1692 | 1525 | /* use the backup registers set up during drive_select */ |
| 1693 | | set_dma_address(device, CURRENT_IDENT, CURRENT_CYLINDER, CURRENT_HEAD); |
| 1526 | set_dma_address(CURRENT_IDENT, CURRENT_CYLINDER, CURRENT_HEAD); |
| 1694 | 1527 | |
| 1695 | 1528 | for (i=0; i < gap1; i++) buffer[index++] = gap_byte; |
| 1696 | 1529 | |
| r14513 | r14514 | |
| 1700 | 1533 | for (i=0; i < sync; i++) buffer[index++] = 0x00; |
| 1701 | 1534 | buffer[index++] = 0xa1; |
| 1702 | 1535 | |
| 1703 | | smc92x4_set_dip(device, TRUE); |
| 1704 | | curr_ident = (*w->intf->dma_read_callback)(device); |
| 1705 | | curr_cyl = (*w->intf->dma_read_callback)(device); |
| 1706 | | curr_head = (*w->intf->dma_read_callback)(device); |
| 1707 | | curr_sect = (*w->intf->dma_read_callback)(device); |
| 1708 | | curr_size = (*w->intf->dma_read_callback)(device); |
| 1709 | | smc92x4_set_dip(device, FALSE); |
| 1536 | m_out_dip(ASSERT_LINE); |
| 1537 | curr_ident = m_in_dma(0); |
| 1538 | curr_cyl = m_in_dma(0); |
| 1539 | curr_head = m_in_dma(0); |
| 1540 | curr_sect = m_in_dma(0); |
| 1541 | curr_size = m_in_dma(0); |
| 1542 | m_out_dip(CLEAR_LINE); |
| 1710 | 1543 | |
| 1711 | 1544 | buffer[index++] = curr_ident; |
| 1712 | 1545 | buffer[index++] = curr_cyl; |
| r14513 | r14514 | |
| 1743 | 1576 | /* GAP 4 */ |
| 1744 | 1577 | for (i=0; i < gap4; i++) buffer[index++] = gap_byte; |
| 1745 | 1578 | |
| 1746 | | (*w->intf->mfmhd_write_track)(device, w->register_w[DESIRED_HEAD]&0x0f, buffer, data_count); |
| 1579 | // Now write the whole track |
| 1580 | harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count); |
| 1581 | |
| 1747 | 1582 | free(buffer); |
| 1748 | | sync_status_in(device); |
| 1583 | sync_status_in(); |
| 1749 | 1584 | } |
| 1750 | 1585 | |
| 1751 | 1586 | /* |
| r14513 | r14514 | |
| 1766 | 1601 | format or generally to the PC99 format between controller and format. |
| 1767 | 1602 | Format is the image is always PC99.) |
| 1768 | 1603 | */ |
| 1769 | | static void read_floppy_track(device_t *device, int transfer_only_ids) |
| 1604 | void smc92x4_device::read_floppy_track(bool transfer_only_ids) |
| 1770 | 1605 | { |
| 1771 | | smc92x4_state *w = get_safe_token(device); |
| 1772 | | device_t *current_floppy = (*w->intf->current_floppy)(device); |
| 1773 | | |
| 1774 | 1606 | floppy_image_legacy *floppy; |
| 1775 | 1607 | /* Determine the track size. We cannot allow different sizes in this design. */ |
| 1776 | 1608 | int data_count = 0; |
| 1777 | 1609 | int i; |
| 1778 | 1610 | UINT8 *buffer; |
| 1779 | 1611 | |
| 1780 | | sync_latches_out(device); |
| 1612 | sync_latches_out(); |
| 1781 | 1613 | |
| 1782 | | floppy = flopimg_get_image(current_floppy); |
| 1614 | floppy = flopimg_get_image(m_drive); |
| 1783 | 1615 | |
| 1784 | 1616 | /* Determine the track size. We cannot allow different sizes in this design. */ |
| 1785 | 1617 | if (floppy != NULL) |
| r14513 | r14514 | |
| 1787 | 1619 | |
| 1788 | 1620 | if (data_count==0) |
| 1789 | 1621 | { |
| 1790 | | if (controller_set_to_single_density(device)) |
| 1622 | if (in_single_density_mode()) |
| 1791 | 1623 | data_count = TRKSIZE_SD; |
| 1792 | 1624 | else |
| 1793 | 1625 | data_count = TRKSIZE_DD; |
| r14513 | r14514 | |
| 1795 | 1627 | |
| 1796 | 1628 | buffer = (UINT8*)malloc(data_count); |
| 1797 | 1629 | |
| 1798 | | floppy_drive_read_track_data_info_buffer( current_floppy, w->register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1799 | | sync_status_in(device); |
| 1630 | floppy_drive_read_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count); |
| 1631 | sync_status_in(); |
| 1800 | 1632 | |
| 1801 | 1633 | // Transfer the buffer to the external memory. We assume the memory |
| 1802 | 1634 | // pointer has been set appropriately in the registers. |
| 1803 | | set_dma_address(device, DMA23_16, DMA15_8, DMA7_0); |
| 1635 | set_dma_address(DMA23_16, DMA15_8, DMA7_0); |
| 1804 | 1636 | |
| 1805 | 1637 | if (transfer_only_ids) |
| 1806 | 1638 | { |
| 1807 | 1639 | if (VERBOSE>1) LOG("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n"); |
| 1808 | 1640 | } |
| 1809 | 1641 | |
| 1810 | | smc92x4_set_dip(device, TRUE); |
| 1642 | m_out_dip(ASSERT_LINE); |
| 1811 | 1643 | for (i=0; i < data_count; i++) |
| 1812 | 1644 | { |
| 1813 | | (*w->intf->dma_write_callback)(device, buffer[i]); |
| 1645 | m_out_dma(0, buffer[i]); |
| 1814 | 1646 | } |
| 1815 | | smc92x4_set_dip(device, FALSE); |
| 1647 | m_out_dip(CLEAR_LINE); |
| 1816 | 1648 | |
| 1817 | 1649 | free(buffer); |
| 1818 | 1650 | } |
| 1819 | 1651 | |
| 1820 | | static void read_harddisk_track(device_t *device, int transfer_only_ids) |
| 1652 | void smc92x4_device::read_harddisk_track(bool transfer_only_ids) |
| 1821 | 1653 | { |
| 1822 | | smc92x4_state *w = get_safe_token(device); |
| 1823 | | |
| 1824 | 1654 | /* Determine the track size. We cannot allow different sizes in this design. */ |
| 1825 | 1655 | int i; |
| 1826 | 1656 | UINT8 *buffer; |
| 1827 | 1657 | int data_count=0; |
| 1658 | mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive); |
| 1828 | 1659 | |
| 1829 | | sync_latches_out(device); |
| 1660 | sync_latches_out(); |
| 1830 | 1661 | |
| 1662 | data_count = harddisk->get_track_length(); |
| 1663 | buffer = (UINT8*)malloc(data_count); |
| 1664 | |
| 1831 | 1665 | /* buffer and data_count are allocated and set by the function. */ |
| 1832 | | (*w->intf->mfmhd_read_track)(device, w->register_w[DESIRED_HEAD]&0x0f, &buffer, &data_count); |
| 1833 | | sync_status_in(device); |
| 1666 | harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer); |
| 1667 | sync_status_in(); |
| 1834 | 1668 | |
| 1835 | | if (!(w->register_r[DRIVE_STATUS] & DS_READY)) |
| 1669 | if (!(m_register_r[DRIVE_STATUS] & DS_READY)) |
| 1836 | 1670 | { |
| 1837 | 1671 | if (VERBOSE>0) LOG("smc92x4 error: read harddisk track failed.\n"); |
| 1838 | | /* no buffer was allocated */ |
| 1839 | 1672 | } |
| 1840 | 1673 | |
| 1841 | 1674 | // Transfer the buffer to the external memory. We assume the memory |
| 1842 | 1675 | // pointer has been set appropriately in the registers. |
| 1843 | | set_dma_address(device, DMA23_16, DMA15_8, DMA7_0); |
| 1676 | set_dma_address(DMA23_16, DMA15_8, DMA7_0); |
| 1844 | 1677 | |
| 1845 | 1678 | if (transfer_only_ids) |
| 1846 | 1679 | { |
| 1847 | 1680 | if (VERBOSE>1) LOG("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n"); |
| 1848 | 1681 | } |
| 1849 | 1682 | |
| 1850 | | smc92x4_set_dip(device, TRUE); |
| 1683 | m_out_dip(ASSERT_LINE); |
| 1851 | 1684 | for (i=0; i < data_count; i++) |
| 1852 | 1685 | { |
| 1853 | | (*w->intf->dma_write_callback)(device, buffer[i]); |
| 1686 | m_out_dma(0, buffer[i]); |
| 1854 | 1687 | } |
| 1855 | | smc92x4_set_dip(device, FALSE); |
| 1688 | m_out_dip(CLEAR_LINE); |
| 1856 | 1689 | |
| 1857 | 1690 | free(buffer); |
| 1858 | 1691 | } |
| 1859 | 1692 | |
| 1860 | 1693 | |
| 1861 | | static void read_track(device_t *device) |
| 1694 | void smc92x4_device::read_track() |
| 1862 | 1695 | { |
| 1863 | | smc92x4_state *w = get_safe_token(device); |
| 1864 | | int transfer_only_ids = w->command & 0x01; |
| 1696 | int transfer_only_ids = m_command & 0x01; |
| 1865 | 1697 | |
| 1866 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 1698 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 1867 | 1699 | { |
| 1868 | | read_floppy_track(device, transfer_only_ids); |
| 1700 | read_floppy_track(transfer_only_ids); |
| 1869 | 1701 | } |
| 1870 | 1702 | else |
| 1871 | 1703 | { |
| 1872 | | read_harddisk_track(device, transfer_only_ids); |
| 1704 | read_harddisk_track(transfer_only_ids); |
| 1873 | 1705 | } |
| 1874 | | |
| 1875 | | smc92x4_timed_track_request(device); |
| 1706 | timed_track_request(); |
| 1876 | 1707 | } |
| 1877 | 1708 | |
| 1878 | | static void read_track_continue(device_t *device) |
| 1709 | void smc92x4_device::read_track_continue() |
| 1879 | 1710 | { |
| 1880 | | smc92x4_state *w = get_safe_token(device); |
| 1881 | | w->to_be_continued = FALSE; |
| 1882 | | set_command_done(device, ST_TC_SUCCESS); |
| 1711 | m_to_be_continued = false; |
| 1712 | set_command_done(ST_TC_SUCCESS); |
| 1883 | 1713 | } |
| 1884 | 1714 | |
| 1885 | | static void format_track(device_t *device) |
| 1715 | void smc92x4_device::format_track() |
| 1886 | 1716 | { |
| 1887 | | smc92x4_state *w = get_safe_token(device); |
| 1888 | | int flags = w->command & 0x1f; |
| 1717 | int flags = m_command & 0x1f; |
| 1889 | 1718 | |
| 1890 | | if (w->selected_drive_type & TYPE_FLOPPY) |
| 1891 | | format_floppy_track(device, flags); |
| 1719 | if (m_selected_drive_type & TYPE_FLOPPY) |
| 1720 | format_floppy_track(flags); |
| 1892 | 1721 | else |
| 1893 | | format_harddisk_track(device, flags); |
| 1722 | format_harddisk_track(flags); |
| 1894 | 1723 | |
| 1895 | | smc92x4_timed_track_request(device); |
| 1724 | timed_track_request(); |
| 1896 | 1725 | } |
| 1897 | 1726 | |
| 1898 | | static void format_track_continue(device_t *device) |
| 1727 | void smc92x4_device::format_track_continue() |
| 1899 | 1728 | { |
| 1900 | | smc92x4_state *w = get_safe_token(device); |
| 1901 | | w->to_be_continued = FALSE; |
| 1902 | | set_command_done(device, ST_TC_SUCCESS); |
| 1729 | m_to_be_continued = false; |
| 1730 | set_command_done(ST_TC_SUCCESS); |
| 1903 | 1731 | } |
| 1904 | 1732 | |
| 1905 | 1733 | /* |
| 1906 | 1734 | Continue to process after callback |
| 1907 | 1735 | */ |
| 1908 | | static void smc92x4_process_after_callback(device_t *device) |
| 1736 | void smc92x4_device::process_after_callback() |
| 1909 | 1737 | { |
| 1910 | | smc92x4_state *w = get_safe_token(device); |
| 1911 | | UINT8 opcode = w->command; |
| 1738 | UINT8 opcode = m_command; |
| 1912 | 1739 | if (opcode >= 0x02 && opcode <= 0x03) |
| 1913 | 1740 | { |
| 1914 | | restore_continue(device); |
| 1741 | restore_continue(); |
| 1915 | 1742 | } |
| 1916 | 1743 | else if (opcode >= 0x04 && opcode <= 0x07) |
| 1917 | 1744 | { |
| 1918 | | step_continue(device); |
| 1745 | step_continue(); |
| 1919 | 1746 | } |
| 1920 | 1747 | else if (opcode >= 0x50 && opcode <= 0x57) |
| 1921 | 1748 | { |
| 1922 | | seek_read_id_continue(device); |
| 1749 | seek_read_id_continue(); |
| 1923 | 1750 | } |
| 1924 | 1751 | else if ((opcode >= 0x58 && opcode <= 0x59)||(opcode >= 0x5C && opcode <= 0x5f)) |
| 1925 | 1752 | { |
| 1926 | | read_sectors_continue(device); |
| 1753 | read_sectors_continue(); |
| 1927 | 1754 | } |
| 1928 | 1755 | else if (opcode >= 0x5a && opcode <= 0x5b) |
| 1929 | 1756 | { |
| 1930 | | read_track_continue(device); |
| 1757 | read_track_continue(); |
| 1931 | 1758 | } |
| 1932 | 1759 | else if (opcode >= 0x60 && opcode <= 0x7f) |
| 1933 | 1760 | { |
| 1934 | | format_track_continue(device); |
| 1761 | format_track_continue(); |
| 1935 | 1762 | } |
| 1936 | 1763 | else if (opcode >= 0x80) |
| 1937 | 1764 | { |
| 1938 | | write_sectors_continue(device); |
| 1765 | write_sectors_continue(); |
| 1939 | 1766 | } |
| 1940 | 1767 | else |
| 1941 | 1768 | { |
| r14513 | r14514 | |
| 1946 | 1773 | /* |
| 1947 | 1774 | Process a command |
| 1948 | 1775 | */ |
| 1949 | | static void smc92x4_process_command(device_t *device, UINT8 opcode) |
| 1776 | void smc92x4_device::process_command(UINT8 opcode) |
| 1950 | 1777 | { |
| 1951 | | smc92x4_state *w = get_safe_token(device); |
| 1952 | | |
| 1953 | 1778 | if (VERBOSE>6) LOG("smc92x4 process command %02x\n", opcode); |
| 1954 | | if (w->to_be_continued) |
| 1779 | if (m_to_be_continued) |
| 1955 | 1780 | { |
| 1956 | | if (VERBOSE>1) LOG("smc92x4 warn: previous command %02x not complete\n", w->command); |
| 1781 | if (VERBOSE>1) LOG("smc92x4 warn: previous command %02x not complete\n", m_command); |
| 1957 | 1782 | } |
| 1958 | 1783 | |
| 1959 | 1784 | /* Reset DONE and BAD_SECTOR. */ |
| 1960 | | w->register_r[INT_STATUS] &= ~(ST_DONE | ST_BADSECT); |
| 1785 | m_register_r[INT_STATUS] &= ~(ST_DONE | ST_BADSECT); |
| 1961 | 1786 | |
| 1962 | | /* Reset interrupt line (not explicitly mentioned in spec, but seems |
| 1963 | | reasonable) */ |
| 1964 | | smc92x4_clear_interrupt(device); |
| 1965 | | w->register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG); |
| 1787 | // Reset interrupt line (not explicitly mentioned in spec, but seems reasonable |
| 1788 | clear_interrupt(); |
| 1789 | m_register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG); |
| 1966 | 1790 | |
| 1967 | | w->command = opcode; |
| 1968 | | w->found_id = FALSE; |
| 1969 | | w->seek_count = 0; |
| 1791 | m_command = opcode; |
| 1792 | m_found_id = false; |
| 1793 | m_seek_count = 0; |
| 1970 | 1794 | |
| 1971 | 1795 | if (opcode == 0x00) |
| 1972 | 1796 | { |
| 1973 | 1797 | /* RESET */ |
| 1974 | 1798 | /* same effect as the RST* pin being active */ |
| 1975 | 1799 | if (VERBOSE>0) LOG("smc92x4 info: reset command\n"); |
| 1976 | | smc92x4_reset(device); |
| 1800 | reset(); |
| 1977 | 1801 | } |
| 1978 | 1802 | else if (opcode == 0x01) |
| 1979 | 1803 | { |
| 1980 | 1804 | /* DESELECT DRIVE */ |
| 1981 | 1805 | /* done when no drive is in use */ |
| 1982 | 1806 | if (VERBOSE>2) LOG("smc92x4 info: drdeselect command\n"); |
| 1983 | | w->output1 &= ~(OUT1_DRVSEL3|OUT1_DRVSEL2|OUT1_DRVSEL1|OUT1_DRVSEL0); |
| 1984 | | w->output2 |= OUT2_DRVSEL3_; |
| 1807 | m_output1 &= ~(OUT1_DRVSEL3|OUT1_DRVSEL2|OUT1_DRVSEL1|OUT1_DRVSEL0); |
| 1808 | m_output2 |= OUT2_DRVSEL3_; |
| 1985 | 1809 | /* sync the latches on the PCB */ |
| 1986 | | sync_latches_out(device); |
| 1987 | | sync_status_in(device); |
| 1810 | sync_latches_out(); |
| 1811 | sync_status_in(); |
| 1988 | 1812 | } |
| 1989 | 1813 | else if (opcode >= 0x02 && opcode <= 0x03) |
| 1990 | 1814 | { |
| r14513 | r14514 | |
| 1992 | 1816 | // bit 0: 0 -> command ends after last seek pulse, 1 -> command |
| 1993 | 1817 | // ends when the drive asserts the seek complete pin |
| 1994 | 1818 | if (VERBOSE>2) LOG("smc92x4 info: restore command %X\n", opcode); |
| 1995 | | restore_drive(device); |
| 1819 | restore_drive(); |
| 1996 | 1820 | } |
| 1997 | 1821 | else if (opcode >= 0x04 && opcode <= 0x07) |
| 1998 | 1822 | { |
| 1999 | 1823 | /* STEP IN/OUT ONE CYLINDER */ |
| 2000 | 1824 | if (VERBOSE>2) LOG("smc92x4 info: step in/out command %X\n", opcode); |
| 2001 | | step_in_out(device); |
| 1825 | step_in_out(); |
| 2002 | 1826 | } |
| 2003 | 1827 | else if (opcode >= 0x08 && opcode <= 0x0f) |
| 2004 | 1828 | { |
| r14513 | r14514 | |
| 2009 | 1833 | { |
| 2010 | 1834 | /* POLLDRIVE */ |
| 2011 | 1835 | if (VERBOSE>2) LOG("smc92x4 info: polldrive command %X\n", opcode); |
| 2012 | | poll_drives(device); |
| 1836 | poll_drives(); |
| 2013 | 1837 | } |
| 2014 | 1838 | else if (opcode >= 0x20 && opcode <= 0x3f) |
| 2015 | 1839 | { |
| 2016 | 1840 | /* DRIVE SELECT */ |
| 2017 | 1841 | if (VERBOSE>2) LOG("smc92x4 info: drselect command %X\n", opcode); |
| 2018 | | drive_select(device, opcode&0x1f); |
| 1842 | drive_select(opcode&0x1f); |
| 2019 | 1843 | } |
| 2020 | 1844 | else if (opcode >= 0x40 && opcode <= 0x4f) |
| 2021 | 1845 | { |
| 2022 | 1846 | /* SETREGPTR */ |
| 2023 | 1847 | if (VERBOSE>2) LOG("smc92x4 info: setregptr command %X\n", opcode); |
| 2024 | | w->register_pointer = opcode & 0xf; |
| 1848 | m_register_pointer = opcode & 0xf; |
| 2025 | 1849 | // Spec does not say anything about the effect of setting an |
| 2026 | 1850 | // invalid value (only "care should be taken") |
| 2027 | | if (w->register_pointer > 10) |
| 1851 | if (m_register_pointer > 10) |
| 2028 | 1852 | { |
| 2029 | | if (VERBOSE>1) LOG("smc92x4 error: set register pointer: Invalid register number: %d. Setting to 10.\n", w->register_pointer); |
| 2030 | | w->register_pointer = 10; |
| 1853 | if (VERBOSE>1) LOG("smc92x4 error: set register pointer: Invalid register number: %d. Setting to 10.\n", m_register_pointer); |
| 1854 | m_register_pointer = 10; |
| 2031 | 1855 | } |
| 2032 | 1856 | } |
| 2033 | 1857 | else if (opcode >= 0x50 && opcode <= 0x57) |
| 2034 | 1858 | { |
| 2035 | 1859 | /* SEEK/READ ID */ |
| 2036 | 1860 | if (VERBOSE>2) LOG("smc92x4 seekreadid command %X\n", opcode); |
| 2037 | | seek_read_id(device); |
| 1861 | seek_read_id(); |
| 2038 | 1862 | } |
| 2039 | 1863 | else if ((opcode >= 0x58 && opcode <= 0x59) |
| 2040 | 1864 | || (opcode >= 0x5C && opcode <= 0x5f) |
| r14513 | r14514 | |
| 2042 | 1866 | { |
| 2043 | 1867 | /* READ/WRITE SECTORS PHYSICAL/LOGICAL */ |
| 2044 | 1868 | if (VERBOSE>2) LOG("smc92x4 info: read/write sector command %X\n", opcode); |
| 2045 | | read_write_sectors(device); |
| 1869 | read_write_sectors(); |
| 2046 | 1870 | } |
| 2047 | 1871 | else if (opcode >= 0x5A && opcode <= 0x5b) |
| 2048 | 1872 | { |
| 2049 | 1873 | /* READ TRACK */ |
| 2050 | 1874 | if (VERBOSE>2) LOG("smc92x4 info: read track command %X\n", opcode); |
| 2051 | | read_track(device); |
| 1875 | read_track(); |
| 2052 | 1876 | } |
| 2053 | 1877 | else if (opcode >= 0x60 && opcode <= 0x7f) |
| 2054 | 1878 | { |
| 2055 | 1879 | /* FORMAT TRACK */ |
| 2056 | 1880 | if (VERBOSE>2) LOG("smc92x4 info: format track command %X\n", opcode); |
| 2057 | | format_track(device); |
| 1881 | format_track(); |
| 2058 | 1882 | } |
| 2059 | 1883 | else |
| 2060 | 1884 | { |
| 2061 | 1885 | if (VERBOSE>0) LOG("smc92x4 error: Invalid command %x, ignored\n", opcode); |
| 2062 | 1886 | } |
| 2063 | 1887 | |
| 2064 | | if (!w->to_be_continued) |
| 2065 | | set_command_done(device); |
| 1888 | if (!m_to_be_continued) |
| 1889 | set_command_done(); |
| 2066 | 1890 | } |
| 2067 | 1891 | |
| 2068 | 1892 | /*************************************************************************** |
| r14513 | r14514 | |
| 2073 | 1897 | Read a byte of data from a smc92x4 controller |
| 2074 | 1898 | The address (offset) encodes the C/D* line (command and /data) |
| 2075 | 1899 | */ |
| 2076 | | READ8_DEVICE_HANDLER( smc92x4_r ) |
| 1900 | READ8_MEMBER( smc92x4_device::read ) |
| 2077 | 1901 | { |
| 2078 | 1902 | UINT8 reply = 0; |
| 2079 | | smc92x4_state *w = get_safe_token(device); |
| 2080 | 1903 | |
| 2081 | 1904 | if ((offset & 1) == 0) |
| 2082 | 1905 | { |
| 2083 | 1906 | /* data register */ |
| 2084 | | reply = w->register_r[w->register_pointer]; |
| 2085 | | if (VERBOSE>6) LOG("smc92x4 register_r[%d] -> %02x\n", w->register_pointer, reply); |
| 1907 | reply = m_register_r[m_register_pointer]; |
| 1908 | if (VERBOSE>6) LOG("smc92x4 register_r[%d] -> %02x\n", m_register_pointer, reply); |
| 2086 | 1909 | /* Autoincrement until DATA is reached. */ |
| 2087 | | if (w->register_pointer < DATA) |
| 2088 | | w->register_pointer++; |
| 1910 | if (m_register_pointer < DATA) |
| 1911 | m_register_pointer++; |
| 2089 | 1912 | } |
| 2090 | 1913 | else |
| 2091 | 1914 | { |
| 2092 | 1915 | /* status register */ |
| 2093 | | reply = w->register_r[INT_STATUS]; |
| 1916 | reply = m_register_r[INT_STATUS]; |
| 2094 | 1917 | // Spec (p.3) : The interrupt pin is reset to its inactive state |
| 2095 | 1918 | // when the UDC interrupt status register is read. |
| 2096 | 1919 | if (VERBOSE>6) LOG("smc92x4 interrupt status read = %02x\n", reply); |
| 2097 | | smc92x4_clear_interrupt(device); |
| 1920 | clear_interrupt(); |
| 2098 | 1921 | /* Clear the bits due to int status register read. */ |
| 2099 | | w->register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG); |
| 1922 | m_register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG); |
| 2100 | 1923 | } |
| 2101 | 1924 | return reply; |
| 2102 | 1925 | } |
| r14513 | r14514 | |
| 2105 | 1928 | Write a byte to a smc99x4 controller |
| 2106 | 1929 | The address (offset) encodes the C/D* line (command and /data) |
| 2107 | 1930 | */ |
| 2108 | | WRITE8_DEVICE_HANDLER( smc92x4_w ) |
| 1931 | WRITE8_MEMBER( smc92x4_device::write ) |
| 2109 | 1932 | { |
| 2110 | | smc92x4_state *w = get_safe_token(device); |
| 2111 | 1933 | data &= 0xff; |
| 2112 | 1934 | |
| 2113 | 1935 | if ((offset & 1) == 0) |
| 2114 | 1936 | { |
| 2115 | 1937 | /* data register */ |
| 2116 | | if (VERBOSE>6) LOG("smc92x4 register_w[%d] <- %X\n", w->register_pointer, data); |
| 2117 | | w->register_w[w->register_pointer] = data; |
| 1938 | if (VERBOSE>6) LOG("smc92x4 register_w[%d] <- %X\n", m_register_pointer, data); |
| 1939 | m_register_w[m_register_pointer] = data; |
| 2118 | 1940 | |
| 2119 | 1941 | // The DMA registers and the sector register for read and |
| 2120 | 1942 | // write are identical. |
| 2121 | | if (w->register_pointer < DESIRED_HEAD) |
| 2122 | | w->register_r[w->register_pointer] = data; |
| 1943 | if (m_register_pointer < DESIRED_HEAD) |
| 1944 | m_register_r[m_register_pointer] = data; |
| 2123 | 1945 | |
| 2124 | 1946 | /* Autoincrement until DATA is reached. */ |
| 2125 | | if (w->register_pointer < DATA) |
| 2126 | | w->register_pointer++; |
| 1947 | if (m_register_pointer < DATA) |
| 1948 | m_register_pointer++; |
| 2127 | 1949 | } |
| 2128 | 1950 | else |
| 2129 | | { |
| 2130 | | /* command register */ |
| 2131 | | smc92x4_process_command(device, data); |
| 2132 | | } |
| 1951 | process_command(data); // command register |
| 2133 | 1952 | } |
| 2134 | 1953 | |
| 2135 | 1954 | |
| r14513 | r14514 | |
| 2138 | 1957 | DEVICE FUNCTIONS |
| 2139 | 1958 | ***************************************************************************/ |
| 2140 | 1959 | |
| 2141 | | static DEVICE_START( smc92x4 ) |
| 1960 | void smc92x4_device::device_start() |
| 2142 | 1961 | { |
| 2143 | | smc92x4_state *w = get_safe_token(device); |
| 2144 | | assert(device->static_config() != NULL); |
| 1962 | const smc92x4_interface *intf = reinterpret_cast<const smc92x4_interface *>(static_config()); |
| 2145 | 1963 | |
| 2146 | | w->intf = (const smc92x4_interface*)device->static_config(); |
| 2147 | | w->out_intrq_func.resolve(w->intf->out_intrq_func, *device); |
| 2148 | | w->out_dip_func.resolve(w->intf->out_dip_func, *device); |
| 2149 | | w->out_auxbus_func.resolve(w->intf->out_auxbus_func, *device); |
| 2150 | | w->in_auxbus_func.resolve(w->intf->in_auxbus_func, *device); |
| 1964 | m_out_intrq.resolve(intf->out_intrq, *this); |
| 1965 | m_out_dip.resolve(intf->out_dip, *this); |
| 1966 | m_out_auxbus.resolve(intf->out_auxbus, *this); |
| 1967 | m_in_auxbus.resolve(intf->in_auxbus, *this); |
| 1968 | m_out_dma.resolve(intf->dma_write, *this); |
| 1969 | m_in_dma.resolve(intf->dma_read, *this); |
| 2151 | 1970 | |
| 2152 | | /* allocate timers */ |
| 2153 | | /* w->timer_data = device->machine().scheduler().timer_alloc(FUNC(smc92x4_data_callback), (void *)device); */ |
| 2154 | | w->timer_rs = device->machine().scheduler().timer_alloc(FUNC(smc92x4_read_sector_callback), (void *)device); |
| 2155 | | w->timer_ws = device->machine().scheduler().timer_alloc(FUNC(smc92x4_write_sector_callback), (void *)device); |
| 2156 | | w->timer_track = device->machine().scheduler().timer_alloc(FUNC(smc92x4_track_callback), (void *)device); |
| 2157 | | w->timer_seek = device->machine().scheduler().timer_alloc(FUNC(smc92x4_seek_callback), (void *)device); |
| 1971 | m_full_track_layout = intf->full_track_layout; |
| 2158 | 1972 | |
| 2159 | | w->use_real_timing = TRUE; |
| 1973 | // allocate timers |
| 1974 | // m_timer_data = timer_alloc(DATA_TIMER); |
| 1975 | m_timer_rs = timer_alloc(READ_TIMER); |
| 1976 | m_timer_ws = timer_alloc(WRITE_TIMER); |
| 1977 | m_timer_track = timer_alloc(TRACK_TIMER); |
| 1978 | m_timer_seek = timer_alloc(SEEK_TIMER); |
| 1979 | |
| 1980 | m_use_real_timing = true; |
| 2160 | 1981 | } |
| 2161 | 1982 | |
| 2162 | | static DEVICE_RESET( smc92x4 ) |
| 1983 | void smc92x4_device::device_reset() |
| 2163 | 1984 | { |
| 2164 | | smc92x4_state *w = get_safe_token(device); |
| 2165 | | smc92x4_clear_interrupt(device); |
| 2166 | | smc92x4_set_dip(device, FALSE); |
| 1985 | clear_interrupt(); |
| 1986 | m_out_dip(CLEAR_LINE); |
| 2167 | 1987 | |
| 2168 | | for (int i=0; i<11; i++) |
| 2169 | | w->register_r[i] = w->register_w[i] = 0; |
| 1988 | for (int i=0; i<=11; i++) |
| 1989 | m_register_r[i] = m_register_w[i] = 0; |
| 1990 | |
| 1991 | m_to_be_continued = false; |
| 2170 | 1992 | } |
| 2171 | 1993 | |
| 2172 | | void smc92x4_reset(device_t *device) |
| 1994 | void smc92x4_device::set_timing(bool realistic) |
| 2173 | 1995 | { |
| 2174 | | DEVICE_RESET_CALL( smc92x4 ); |
| 1996 | m_use_real_timing = realistic; |
| 1997 | if (VERBOSE>0) LOG("smc92x4: use realistic timing: %02x\n", realistic); |
| 2175 | 1998 | } |
| 2176 | 1999 | |
| 2177 | | void smc92x4_set_timing(device_t *device, int realistic) |
| 2000 | void smc92x4_device::connect_drive(device_t *drive) |
| 2178 | 2001 | { |
| 2179 | | smc92x4_state *w = get_safe_token(device); |
| 2180 | | w->use_real_timing = realistic; |
| 2181 | | if (VERBOSE>0) LOG("smc92x4: use realistic timing: %02x\n", realistic); |
| 2002 | m_drive = drive; |
| 2003 | if (VERBOSE>3) |
| 2004 | { |
| 2005 | if (drive==NULL) LOG("smc92x4: Unselect all drives\n"); |
| 2006 | else LOG("smc92x4: Connect drive %s\n", drive->tag()); |
| 2007 | } |
| 2182 | 2008 | } |
| 2183 | 2009 | |
| 2184 | | /*************************************************************************** |
| 2185 | | DEVICE GETINFO |
| 2186 | | ***************************************************************************/ |
| 2010 | void smc92x4_device::reset() |
| 2011 | { |
| 2012 | device_reset(); |
| 2013 | } |
| 2187 | 2014 | |
| 2188 | | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 2189 | | |
| 2190 | | #define DEVTEMPLATE_ID(p,s) p##smc92x4##s |
| 2191 | | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET |
| 2192 | | #define DEVTEMPLATE_NAME "SMC92x4" |
| 2193 | | #define DEVTEMPLATE_FAMILY "SMC92x4" |
| 2194 | | #define DEVTEMPLATE_VERSION "1.0" |
| 2195 | | #define DEVTEMPLATE_CREDITS "Copyright MESS Team" |
| 2196 | | #include "devtempl.h" |
| 2197 | | |
| 2198 | | DEFINE_LEGACY_DEVICE(SMC92X4, smc92x4); |
| 2015 | const device_type SMC92X4 = &device_creator<smc92x4_device>; |
src/mess/drivers/ti99_8.c
| r14513 | r14514 | |
| 1 | | /* |
| 2 | | MESS Driver for TI-99/8 Computer. |
| 3 | | Raphael Nabet, 2003. |
| 4 | | */ |
| 5 | | /* |
| 6 | | TI-99/8 preliminary info: |
| 1 | /**************************************************************************** |
| 7 | 2 | |
| 3 | The MESS TI-99/8 emulation driver |
| 4 | |
| 5 | The TI-99/8 was the envisaged successor to the TI-99/4A but never passed |
| 6 | its prototype state. Only a few consoles were built. The ROMs were not |
| 7 | even finalized, so the few available consoles may have different |
| 8 | operating system versions. |
| 9 | |
| 10 | There is some preliminary info: |
| 11 | |
| 8 | 12 | Name: Texas Instruments Computer TI-99/8 (no "Home") |
| 9 | 13 | |
| 10 | 14 | References: |
| r14513 | r14514 | |
| 186 | 190 | - SAVE and OLD MINIMEM do not work properly in XB II. It seems as if the |
| 187 | 191 | mapper shadows the NVRAM of the cartridge. You will lose the contents when |
| 188 | 192 | you turn off the machine. |
| 189 | | =========================================================================== |
| 190 | 193 | |
| 191 | | */ |
| 194 | Raphael Nabet, 2003. |
| 195 | Michael Zapf |
| 192 | 196 | |
| 197 | February 2012: Rewritten as class |
| 198 | |
| 199 | *****************************************************************************/ |
| 200 | |
| 201 | #define ADDRESS_MAP_MODERN |
| 202 | |
| 193 | 203 | #include "emu.h" |
| 194 | 204 | #include "cpu/tms9900/tms9900.h" |
| 195 | 205 | #include "sound/sn76496.h" |
| 196 | | //#include "video/tms9928a.h" |
| 197 | 206 | #include "sound/wave.h" |
| 198 | 207 | #include "machine/tms9901.h" |
| 199 | 208 | #include "imagedev/cassette.h" |
| 200 | 209 | |
| 201 | | #include "machine/ti99/tiboard.h" |
| 202 | | |
| 203 | 210 | #include "machine/ti99/videowrp.h" |
| 204 | 211 | #include "machine/ti99/speech8.h" |
| 205 | 212 | |
| r14513 | r14514 | |
| 210 | 217 | #include "machine/ti99/gromport.h" |
| 211 | 218 | #include "machine/ti99/mecmouse.h" |
| 212 | 219 | |
| 220 | #define VERBOSE 1 |
| 221 | #define LOG logerror |
| 213 | 222 | |
| 214 | | class ti99_8_state : public driver_device |
| 223 | class ti99_8 : public driver_device |
| 215 | 224 | { |
| 216 | 225 | public: |
| 217 | | ti99_8_state(const machine_config &mconfig, device_type type, const char *tag) |
| 226 | ti99_8(const machine_config &mconfig, device_type type, const char *tag) |
| 218 | 227 | : driver_device(mconfig, type, tag) { } |
| 219 | 228 | |
| 229 | // CRU (Communication Register Unit) handling |
| 230 | DECLARE_READ8_MEMBER(cruread); |
| 231 | DECLARE_WRITE8_MEMBER(cruwrite); |
| 232 | |
| 233 | // Forwarding interrupts to the CPU or CRU |
| 234 | DECLARE_WRITE_LINE_MEMBER( console_ready ); |
| 235 | DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT2 ); |
| 236 | DECLARE_WRITE_LINE_MEMBER( extint ); |
| 237 | DECLARE_WRITE_LINE_MEMBER( notconnected ); |
| 238 | |
| 239 | // Connections with the system interface TMS9901 |
| 240 | DECLARE_READ8_MEMBER(read_by_9901); |
| 241 | DECLARE_WRITE_LINE_MEMBER(keyC0); |
| 242 | DECLARE_WRITE_LINE_MEMBER(keyC1); |
| 243 | DECLARE_WRITE_LINE_MEMBER(keyC2); |
| 244 | DECLARE_WRITE_LINE_MEMBER(keyC3); |
| 245 | DECLARE_WRITE_LINE_MEMBER(CRUS); |
| 246 | DECLARE_WRITE_LINE_MEMBER(PTGEN); |
| 247 | DECLARE_WRITE_LINE_MEMBER(audio_gate); |
| 248 | DECLARE_WRITE_LINE_MEMBER(cassette_output); |
| 249 | DECLARE_WRITE_LINE_MEMBER(cassette_motor); |
| 250 | DECLARE_WRITE8_MEMBER(tms9901_interrupt); |
| 251 | |
| 252 | // Some values to keep |
| 253 | device_t *m_cpu; |
| 254 | tms9901_device *m_tms9901; |
| 255 | gromport_device *m_gromport; |
| 256 | peribox_device *m_peribox; |
| 257 | mecmouse_device *m_mecmouse; |
| 258 | ti998_mapper_device *m_mapper; |
| 259 | |
| 260 | private: |
| 261 | /* Keyboard support */ |
| 262 | void set_key(int number, int data); |
| 263 | int m_keyboard_column; |
| 264 | int m_alphalock_line; |
| 220 | 265 | }; |
| 221 | 266 | |
| 222 | 267 | |
| 223 | 268 | /* |
| 224 | | Memory map - see description above |
| 269 | Memory map. We have a configurable mapper, so we need to delegate the |
| 270 | job to the mapper completely. |
| 225 | 271 | */ |
| 226 | | |
| 227 | | static ADDRESS_MAP_START(ti99_8_memmap, AS_PROGRAM, 8) |
| 228 | | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE("mapper", ti99_mapper8_r, ti99_mapper8_w ) |
| 272 | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 8, ti99_8) |
| 273 | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE(MAPPER_TAG, ti998_mapper_device, readm, writem ) |
| 229 | 274 | ADDRESS_MAP_END |
| 230 | 275 | |
| 231 | | |
| 232 | 276 | /* |
| 233 | 277 | CRU map - see description above |
| 234 | 278 | The TMS9901 is fully decoded according to the specification, so we only |
| r14513 | r14514 | |
| 237 | 281 | TODO: Check whether the CRU address space goes up to 7fff (15 bit) |
| 238 | 282 | */ |
| 239 | 283 | |
| 240 | | static ADDRESS_MAP_START(ti99_8_cru_map, AS_IO, 8) |
| 241 | | AM_RANGE(0x0000, 0x0003) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 242 | | AM_RANGE(0x0000, 0x02ff) AM_DEVREAD("crubus", ti99_crubus_r ) |
| 284 | static ADDRESS_MAP_START(crumap, AS_IO, 8, ti99_8) |
| 285 | AM_RANGE(0x0000, 0x0003) AM_DEVREAD(TMS9901_TAG, tms9901_device, read) |
| 286 | AM_RANGE(0x0000, 0x02ff) AM_READ(cruread) |
| 243 | 287 | |
| 244 | | AM_RANGE(0x0000, 0x001f) AM_DEVWRITE("tms9901", tms9901_cru_w) |
| 245 | | AM_RANGE(0x0000, 0x17ff) AM_DEVWRITE("crubus", ti99_crubus_w ) |
| 288 | AM_RANGE(0x0000, 0x001f) AM_DEVWRITE(TMS9901_TAG, tms9901_device, write) |
| 289 | AM_RANGE(0x0000, 0x17ff) AM_WRITE(cruwrite) |
| 246 | 290 | ADDRESS_MAP_END |
| 247 | 291 | |
| 248 | 292 | /* ti99/8 : 54-key keyboard */ |
| 249 | 293 | static INPUT_PORTS_START(ti99_8) |
| 250 | | PORT_START( "DISKCTRL" ) |
| 251 | | PORT_CONFNAME( 0x07, 0x00, "Disk controller" ) |
| 252 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 253 | | PORT_CONFSETTING( 0x01, "TI SD Floppy Controller" ) |
| 254 | | PORT_CONFSETTING( 0x02, "SNUG BwG Controller" ) |
| 255 | | PORT_CONFSETTING( 0x03, "Myarc HFDC" ) |
| 256 | | |
| 257 | | PORT_START( "HDCTRL" ) |
| 258 | | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 259 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 260 | | PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 261 | | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 262 | | PORT_CONFNAME( 0x08, 0x00, "USB-SM card" ) |
| 294 | PORT_START( "MECMOUSE" ) |
| 295 | PORT_CONFNAME( 0x01, 0x00, "Mechatronics Mouse" ) |
| 263 | 296 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 264 | | PORT_CONFSETTING( 0x08, DEF_STR( On ) ) |
| 297 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 265 | 298 | |
| 266 | | PORT_START( "SERIAL" ) |
| 267 | | PORT_CONFNAME( 0x03, 0x00, "Serial/Parallel interface" ) |
| 268 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 269 | | PORT_CONFSETTING( 0x01, "TI RS-232 card" ) |
| 270 | | |
| 271 | | PORT_START( "SERIALMAP" ) |
| 272 | | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) PORT_CONDITION( "SERIAL", 0x03, PORTCOND_NOTEQUALS, 0x00 ) |
| 273 | | PORT_CONFSETTING( 0x00, "6-20" ) |
| 274 | | PORT_CONFSETTING( 0x01, "8-20" ) |
| 275 | | PORT_CONFSETTING( 0x02, "5-20" ) |
| 276 | | |
| 277 | | PORT_START( "HCI" ) |
| 278 | | PORT_CONFNAME( 0x01, 0x00, "Mouse support" ) |
| 279 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 280 | | PORT_CONFSETTING( 0x01, "Mechatronics Mouse" ) |
| 281 | | |
| 282 | | PORT_START( "CARTSLOT" ) |
| 283 | | PORT_DIPNAME( 0x0f, 0x00, "Cartridge slot" ) |
| 284 | | PORT_DIPSETTING( 0x00, "Auto" ) |
| 285 | | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 286 | | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 287 | | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 288 | | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 289 | | |
| 290 | | PORT_START( "BWGDIP1" ) |
| 291 | | PORT_DIPNAME( 0x01, 0x00, "BwG step rate" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 292 | | PORT_DIPSETTING( 0x00, "6 ms") |
| 293 | | PORT_DIPSETTING( 0x01, "20 ms") |
| 294 | | |
| 295 | | PORT_START( "BWGDIP2" ) |
| 296 | | PORT_DIPNAME( 0x01, 0x00, "BwG date/time display" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 297 | | PORT_DIPSETTING( 0x00, "Hide") |
| 298 | | PORT_DIPSETTING( 0x01, "Show") |
| 299 | | |
| 300 | | PORT_START( "BWGDIP34" ) |
| 301 | | PORT_DIPNAME( 0x03, 0x00, "BwG drives" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 302 | | PORT_DIPSETTING( 0x00, "DSK1 only") |
| 303 | | PORT_DIPSETTING( 0x01, "DSK1-DSK2") |
| 304 | | PORT_DIPSETTING( 0x02, "DSK1-DSK3") |
| 305 | | PORT_DIPSETTING( 0x03, "DSK1-DSK4") |
| 306 | | |
| 307 | | PORT_START( "HFDCDIP" ) |
| 308 | | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 309 | | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 310 | | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 311 | | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 312 | | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 313 | | |
| 314 | | PORT_START( "DRVSPD" ) |
| 315 | | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 316 | | PORT_CONFSETTING( 0x00, "No delay") |
| 317 | | PORT_CONFSETTING( 0x01, "Realistic") |
| 318 | | |
| 319 | | // We do not want to show this setting; makes only sense for Geneve |
| 320 | | PORT_START( "MODE" ) |
| 321 | | PORT_CONFNAME( 0x01, 0x00, "Ext. cards modification" ) PORT_CONDITION( "HFDCDIP", 0xff, PORTCOND_EQUALS, GM_NEVER ) |
| 322 | | PORT_CONFSETTING( 0x00, "Standard" ) |
| 323 | | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 324 | | |
| 325 | 299 | /* 3 ports for mouse */ |
| 326 | 300 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 327 | 301 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| r14513 | r14514 | |
| 445 | 419 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1/*, "(2FIRE)", CODE_NONE, OSD_JOY2_FIRE, 0*/) PORT_PLAYER(2) |
| 446 | 420 | INPUT_PORTS_END |
| 447 | 421 | |
| 422 | /***************************************************************************** |
| 423 | Components |
| 424 | ******************************************************************************/ |
| 448 | 425 | |
| 449 | | /* F4 Character Displayer */ |
| 450 | | static const gfx_layout ti99_7_charlayout = |
| 426 | static GROM_CONFIG(grom0_config) |
| 451 | 427 | { |
| 452 | | 8, 7, /* 8 x 7 characters */ |
| 453 | | 96, /* 96 characters */ |
| 454 | | 1, /* 1 bits per pixel */ |
| 455 | | { 0 }, /* no bitplanes */ |
| 456 | | /* x offsets */ |
| 457 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 458 | | /* y offsets */ |
| 459 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8 }, |
| 460 | | 8*7 /* every char takes 7 bytes */ |
| 428 | false, 0, region_grom, 0x0000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_8, console_ready) |
| 461 | 429 | }; |
| 462 | 430 | |
| 463 | | static const gfx_layout ti99_8_charlayout = |
| 431 | static GROM_CONFIG(grom1_config) |
| 464 | 432 | { |
| 465 | | 8, 8, /* 8 x 8 characters */ |
| 466 | | 64, /* 64 characters */ |
| 467 | | 1, /* 1 bits per pixel */ |
| 468 | | { 0 }, /* no bitplanes */ |
| 469 | | /* x offsets */ |
| 470 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 471 | | /* y offsets */ |
| 472 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 473 | | 8*8 /* every char takes 8 bytes */ |
| 433 | false, 1, region_grom, 0x2000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_8, console_ready) |
| 474 | 434 | }; |
| 475 | 435 | |
| 476 | | static const gfx_layout ti99_c_charlayout = |
| 436 | static GROM_CONFIG(grom2_config) |
| 477 | 437 | { |
| 478 | | 8, 8, /* 8 x 8 characters */ |
| 479 | | 1, /* 1 characters */ |
| 480 | | 1, /* 1 bits per pixel */ |
| 481 | | { 0 }, /* no bitplanes */ |
| 482 | | /* x offsets */ |
| 483 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 484 | | /* y offsets */ |
| 485 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 486 | | 8*8 /* every char takes 8 bytes */ |
| 438 | false, 2, region_grom, 0x4000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_8, console_ready) |
| 487 | 439 | }; |
| 488 | 440 | |
| 489 | | static const gfx_layout ti99_24_charlayout = |
| 441 | static GROMPORT_CONFIG(console_cartslot) |
| 490 | 442 | { |
| 491 | | 24, 24, /* 24 x 24 characters */ |
| 492 | | 1, /* 1 characters */ |
| 493 | | 1, /* 1 bits per pixel */ |
| 494 | | { 0 }, /* no bitplanes */ |
| 495 | | /* x offsets */ |
| 496 | | { 0, 1, 2, 3, 4, 5, 6, 7, 64, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 }, |
| 497 | | /* y offsets */ |
| 498 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8, 48*8, 49*8, 50*8, 51*8, 52*8, 53*8, 54*8, 55*8 }, |
| 499 | | 24*24 /* every char takes 72 bytes */ |
| 443 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, console_ready) |
| 500 | 444 | }; |
| 501 | 445 | |
| 502 | | static GFXDECODE_START( ti99_8 ) |
| 503 | | GFXDECODE_ENTRY( region_grom, 0x050d, ti99_8_charlayout, 0, 8 ) // large |
| 504 | | GFXDECODE_ENTRY( region_grom, 0x070d, ti99_7_charlayout, 0, 8 ) // small |
| 505 | | GFXDECODE_ENTRY( region_grom, 0x09b4, ti99_24_charlayout, 0, 8 )// TI logo |
| 506 | | GFXDECODE_ENTRY( region_grom, 0x09fc, ti99_c_charlayout, 0, 8 ) // (c) |
| 507 | | GFXDECODE_END |
| 446 | static PERIBOX_CONFIG( peribox_conf ) |
| 447 | { |
| 448 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, extint), // INTA |
| 449 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, notconnected), // INTB |
| 450 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, console_ready), // READY |
| 451 | 0x70000 // Address bus prefix (AMA/AMB/AMC) |
| 452 | }; |
| 508 | 453 | |
| 454 | READ8_MEMBER( ti99_8::cruread ) |
| 455 | { |
| 456 | // if (VERBOSE>6) LOG("read access to CRU address %04x\n", offset << 4); |
| 457 | UINT8 value = 0; |
| 509 | 458 | |
| 510 | | static WRITE_LINE_DEVICE_HANDLER(set_int2) |
| 459 | // Similar to the bus8z_devices, just let the mapper, the gromport, and the p-box |
| 460 | // decide whether they want to change the value at the CRU address |
| 461 | // Also, we translate the bit addresses to base addresses |
| 462 | m_mapper->crureadz(offset<<4, &value); |
| 463 | m_gromport->crureadz(offset<<4, &value); |
| 464 | m_peribox->crureadz(offset<<4, &value); |
| 465 | |
| 466 | if (VERBOSE>8) LOG("ti99_8: CRU %04x -> %02x\n", offset<<4, value); |
| 467 | return value; |
| 468 | } |
| 469 | |
| 470 | WRITE8_MEMBER( ti99_8::cruwrite ) |
| 511 | 471 | { |
| 512 | | tms9901_set_int2(device->machine().device("ti_board"), state ); |
| 472 | if (VERBOSE>8) LOG("ti99_8: CRU %04x <- %x\n", offset<<1, data); |
| 473 | m_mapper->cruwrite(offset<<1, data); |
| 474 | m_gromport->cruwrite(offset<<1, data); |
| 475 | m_peribox->cruwrite(offset<<1, data); |
| 513 | 476 | } |
| 514 | 477 | |
| 515 | | static TMS9928A_INTERFACE(ti99_8_tms9928a_interface) |
| 478 | /*************************************************************************** |
| 479 | TI99/8-specific tms9901 I/O handlers |
| 480 | These methods are callbacks from the TMS9901 system interface. That is, |
| 481 | they deliver the values queried via the TMS9901, and they represent |
| 482 | console functions which are under control of the TMS9901 (like the |
| 483 | keyboard column selection.) |
| 484 | ***************************************************************************/ |
| 485 | |
| 486 | static const char *const keynames8[] = { |
| 487 | "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", |
| 488 | "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" |
| 489 | }; |
| 490 | |
| 491 | READ8_MEMBER( ti99_8::read_by_9901 ) |
| 516 | 492 | { |
| 493 | int answer=0; |
| 494 | |
| 495 | switch (offset & 0x03) |
| 496 | { |
| 497 | case TMS9901_CB_INT7: |
| 498 | // Read pins INT3*-INT7* of TI99's 9901. |
| 499 | // |
| 500 | // (bit 1: INT1 status) |
| 501 | // (bit 2: INT2 status) |
| 502 | // bits 3-4: unused? |
| 503 | // bit 5: ??? |
| 504 | // bit 6-7: keyboard status bits 0 through 1 |
| 505 | if (m_mecmouse != NULL && (m_keyboard_column == 15)) |
| 506 | { |
| 507 | answer = m_mecmouse->get_values8(0); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | answer = (input_port_read(machine(), keynames8[m_keyboard_column]) << 6) & 0xC0; |
| 512 | } |
| 513 | break; |
| 514 | |
| 515 | case TMS9901_INT8_INT15: |
| 516 | // Read pins INT8*-INT15* of TI99's 9901. |
| 517 | // |
| 518 | // bit 0-2: keyboard status bits 2 to 4 |
| 519 | // bit 3: tape input mirror |
| 520 | // (bit 4: IR remote handset interrupt) |
| 521 | // bit 5-7: weird, not emulated |
| 522 | if (m_mecmouse != NULL && (m_keyboard_column == 15)) |
| 523 | { |
| 524 | answer = m_mecmouse->get_values8(1); |
| 525 | } |
| 526 | else |
| 527 | { |
| 528 | answer = (input_port_read(machine(), keynames8[m_keyboard_column]) >> 2) & 0x07; |
| 529 | } |
| 530 | break; |
| 531 | |
| 532 | case TMS9901_P0_P7: |
| 533 | // Read pins P0-P7 of TI99's 9901. None here. |
| 534 | break; |
| 535 | |
| 536 | case TMS9901_P8_P15: |
| 537 | // Read pins P8-P15 of TI99's 9901. (TI-99/8) |
| 538 | // |
| 539 | // bit 26: high |
| 540 | // bit 27: tape input |
| 541 | int answer = 4; |
| 542 | if ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0) |
| 543 | answer |= 8; |
| 544 | break; |
| 545 | } |
| 546 | return answer; |
| 547 | } |
| 548 | |
| 549 | /* |
| 550 | WRITE key column select (P2-P4), TI-99/8 |
| 551 | */ |
| 552 | void ti99_8::set_key(int number, int data) |
| 553 | { |
| 554 | if (data!=0) m_keyboard_column |= 1 << number; |
| 555 | else m_keyboard_column &= ~(1 << number); |
| 556 | |
| 557 | if (m_mecmouse != NULL) |
| 558 | m_mecmouse->select(m_keyboard_column, 14, 15); |
| 559 | } |
| 560 | |
| 561 | WRITE_LINE_MEMBER( ti99_8::keyC0 ) |
| 562 | { |
| 563 | set_key(0, state); |
| 564 | } |
| 565 | |
| 566 | WRITE_LINE_MEMBER( ti99_8::keyC1 ) |
| 567 | { |
| 568 | set_key(1, state); |
| 569 | } |
| 570 | |
| 571 | WRITE_LINE_MEMBER( ti99_8::keyC2 ) |
| 572 | { |
| 573 | set_key(2, state); |
| 574 | } |
| 575 | |
| 576 | WRITE_LINE_MEMBER( ti99_8::keyC3 ) |
| 577 | { |
| 578 | set_key(3, state); |
| 579 | } |
| 580 | |
| 581 | /* |
| 582 | Set 99/4A compatibility mode (CRUS=1) |
| 583 | */ |
| 584 | WRITE_LINE_MEMBER( ti99_8::CRUS ) |
| 585 | { |
| 586 | m_mapper->CRUS_set(state==ASSERT_LINE); |
| 587 | } |
| 588 | |
| 589 | /* |
| 590 | Set mapper /PTGEN. This is negative logic; we use PTGE as the positive logic signal. |
| 591 | */ |
| 592 | WRITE_LINE_MEMBER( ti99_8::PTGEN ) |
| 593 | { |
| 594 | m_mapper->PTGE_set(state==CLEAR_LINE); |
| 595 | } |
| 596 | |
| 597 | /* |
| 598 | Control cassette tape unit motor (P6) |
| 599 | */ |
| 600 | WRITE_LINE_MEMBER( ti99_8::cassette_motor ) |
| 601 | { |
| 602 | cassette_image_device *img = machine().device<cassette_image_device>(CASSETTE_TAG); |
| 603 | img->change_state(state==ASSERT_LINE? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 604 | } |
| 605 | |
| 606 | /* |
| 607 | Audio gate (P8) |
| 608 | Set to 1 before using tape: this enables the mixing of tape input sound |
| 609 | with computer sound. |
| 610 | We do not really need to emulate this as the tape recorder generates sound |
| 611 | on its own. |
| 612 | */ |
| 613 | WRITE_LINE_MEMBER( ti99_8::audio_gate ) |
| 614 | { |
| 615 | } |
| 616 | |
| 617 | /* |
| 618 | Tape output (P9) |
| 619 | I think polarity is correct, but don't take my word for it. |
| 620 | */ |
| 621 | WRITE_LINE_MEMBER( ti99_8::cassette_output ) |
| 622 | { |
| 623 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(state==ASSERT_LINE? +1 : -1); |
| 624 | } |
| 625 | |
| 626 | WRITE8_MEMBER( ti99_8::tms9901_interrupt ) |
| 627 | { |
| 628 | // offset contains the interrupt level (0-15) |
| 629 | if (data==ASSERT_LINE) |
| 630 | { |
| 631 | // The TMS9901 should normally be connected with the CPU by 5 wires: |
| 632 | // INTREQ* and IC0-IC3. The last four lines deliver the interrupt level. |
| 633 | // On the TI-99 systems these IC lines are not used; the input lines |
| 634 | // at the CPU are hardwired to level 1. |
| 635 | if (VERBOSE>8) LOG("mapper8: tms9901 asserts interrupt\n"); |
| 636 | device_execute(m_cpu)->set_input_line_and_vector(0, ASSERT_LINE, 1); |
| 637 | } |
| 638 | else |
| 639 | { |
| 640 | if (VERBOSE>8) LOG("mapper8: tms9901 clears interrupt\n"); |
| 641 | device_execute(m_cpu)->set_input_line(0, CLEAR_LINE); |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | const tms9901_interface tms9901_wiring_ti99_8 = |
| 646 | { |
| 647 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, |
| 648 | |
| 649 | // read handler |
| 650 | DEVCB_DRIVER_MEMBER(ti99_8, read_by_9901), |
| 651 | |
| 652 | // write handlers |
| 653 | { |
| 654 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, keyC0), |
| 655 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, keyC1), |
| 656 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, keyC2), |
| 657 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, keyC3), |
| 658 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, CRUS), |
| 659 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, PTGEN), |
| 660 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, cassette_motor), |
| 661 | DEVCB_NULL, |
| 662 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, audio_gate), |
| 663 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, cassette_output), |
| 664 | DEVCB_NULL, |
| 665 | DEVCB_NULL, |
| 666 | DEVCB_NULL, |
| 667 | DEVCB_NULL, |
| 668 | DEVCB_NULL, |
| 669 | DEVCB_NULL |
| 670 | }, |
| 671 | |
| 672 | DEVCB_DRIVER_MEMBER(ti99_8, tms9901_interrupt) |
| 673 | }; |
| 674 | |
| 675 | /*****************************************************************************/ |
| 676 | |
| 677 | /* |
| 678 | set the state of TMS9901's INT2 (called by the tms9928 core) |
| 679 | */ |
| 680 | WRITE_LINE_MEMBER( ti99_8::set_tms9901_INT2 ) |
| 681 | { |
| 682 | if (VERBOSE>6) LOG("ti99_8: VDP int 2 on tms9901, level=%02x\n", state); |
| 683 | m_tms9901->set_single_int(2, state); |
| 684 | } |
| 685 | |
| 686 | /*********************************************************** |
| 687 | Links to external devices |
| 688 | ***********************************************************/ |
| 689 | |
| 690 | |
| 691 | WRITE_LINE_MEMBER( ti99_8::console_ready ) |
| 692 | { |
| 693 | if (VERBOSE>6) LOG("ti99_8: READY line set ... not yet connected, level=%02x\n", state); |
| 694 | } |
| 695 | |
| 696 | WRITE_LINE_MEMBER( ti99_8::extint ) |
| 697 | { |
| 698 | if (VERBOSE>6) LOG("ti99_8: EXTINT level = %02x\n", state); |
| 699 | if (m_tms9901 != NULL) |
| 700 | m_tms9901->set_single_int(1, state); |
| 701 | } |
| 702 | |
| 703 | WRITE_LINE_MEMBER( ti99_8::notconnected ) |
| 704 | { |
| 705 | if (VERBOSE>6) LOG("ti99_8: Setting a not connected line ... ignored\n"); |
| 706 | } |
| 707 | |
| 708 | static TMS9928A_INTERFACE(ti99_8_tms9118a_interface) |
| 709 | { |
| 517 | 710 | SCREEN_TAG, |
| 518 | 711 | 0x4000, |
| 519 | | DEVCB_LINE(set_int2) |
| 712 | DEVCB_DRIVER_LINE_MEMBER(ti99_8, set_tms9901_INT2) |
| 520 | 713 | }; |
| 521 | 714 | |
| 715 | /*****************************************************************************/ |
| 716 | |
| 522 | 717 | static const struct tms9995reset_param ti99_8_processor_config = |
| 523 | 718 | { |
| 524 | 719 | 1, /* enable automatic wait state generation */ |
| r14513 | r14514 | |
| 537 | 732 | care must be taken that only one device actually responds. In the case of |
| 538 | 733 | GROMs, each chip has an internal address counter and an ID, and the chip |
| 539 | 734 | only responds when the ID and the most significant 3 bits match. |
| 735 | |
| 736 | NATIVE <-> CRUS=0 |
| 737 | TI99EM <-> CRUS=1 |
| 738 | |
| 739 | PATGEN <-> PTGEN=1 |
| 740 | |
| 741 | CONT: Mapper continues iterating through devices |
| 742 | STOP: Mapper stops iterating when found |
| 743 | |
| 744 | Access to the mapper registers is done directly in the mapper, not via |
| 745 | this list. |
| 540 | 746 | */ |
| 541 | | static const mapper8_dev_config mapper_devices[] = |
| 747 | static const mapper8_list_entry mapper_devices[] = |
| 542 | 748 | { |
| 543 | 749 | // TI-99/8 mode |
| 544 | | { SRAMNAME, 0, 1, 0xf800, 0xf000, 0x0000, NULL, NULL }, |
| 545 | | { "soundgen", 0, 1, 0xfff0, 0xf800, 0x0000, NULL, sn76496_w }, |
| 546 | | { "video", 0, 1, 0xfffd, 0xf810, 0x0000, ti8_tms991x_rz, ti8_tms991x_w }, |
| 547 | | { "speech", 0, 1, 0xfff0, 0xf820, 0x0000, ti998spch_rz, ti998spch_w }, |
| 548 | | { "grom_0", 0, 0, 0xfff1, 0xf830, 0x0000, ti99grom_rz, ti99grom_w }, |
| 549 | | { "grom_1", 0, 0, 0xfff1, 0xf830, 0x0000, ti99grom_rz, ti99grom_w }, |
| 550 | | { "grom_2", 0, 0, 0xfff1, 0xf830, 0x0000, ti99grom_rz, ti99grom_w }, |
| 551 | | { "gromport", 0, 0, 0xfff1, 0xf830, 0x0400, gromportg_rz, gromportg_w, }, |
| 552 | | // { "grom_tts_0", 2, 0, 0xfff1, 0xf840, 0x0000, 0, 0, ti99grom_rz, ti99grom_w }, // up to 6 GROMs; no good dumps known |
| 553 | | // { "grom_pcode1_0", 2, 0, 0xfff1, 0xf850, 0x0000, 0, 0, ti99grom_rz, ti99grom_w }, // up to 6 GROMs; no good dumps known |
| 554 | | // { "grom_pcode2_0", 2, 0, 0xfff1, 0xf860, 0x0000, 0, 0, ti99grom_rz, ti99grom_w }, // up to 6 GROMs; no good dumps known |
| 555 | | { "mapper", 0, 1, 0xfff0, 0xf870, 0x0000, NULL, ti99_mapreg_w }, |
| 750 | { SRAMNAME, NATIVE, STOP, 0xf000, 0xf800, 0x0000 }, // f000-f7ff |
| 751 | { TISOUND_TAG, NATIVE, STOP, 0xf800, 0xfff0, 0x0000 }, // f800-f80f |
| 752 | { VIDEO_SYSTEM_TAG, NATIVE, STOP, 0xf810, 0xfffd, 0x0000 }, // f810,2 (unlike 99/4A, no different read/write ports) |
| 753 | { SPEECH_TAG, NATIVE, STOP, 0xf820, 0xfff0, 0x0000 }, // f820-f82f |
| 556 | 754 | |
| 557 | | // TI-99/4A mode |
| 558 | | // GROM: 1001 1000 0000 xxa0 |
| 559 | | { ROM0NAME, 1, 1, 0xe000, 0x0000, 0x0000, NULL, NULL }, |
| 560 | | { "grom_0", 1, 0, 0xfff1, 0x9800, 0x0400, ti99grom_rz, ti99grom_w }, |
| 561 | | { "grom_1", 1, 0, 0xfff1, 0x9800, 0x0400, ti99grom_rz, ti99grom_w }, |
| 562 | | { "grom_2", 1, 0, 0xfff1, 0x9800, 0x0400, ti99grom_rz, ti99grom_w }, |
| 563 | | { "gromport", 1, 0, 0xfff1, 0x9800, 0x0400, gromportg_rz, gromportg_w, }, |
| 755 | { GROM0_TAG, NATIVE, CONT, 0xf830, 0xfff1, 0x0000 }, // f830-f83e (4 banks), no different read/write ports |
| 756 | { GROM1_TAG, NATIVE, CONT, 0xf830, 0xfff1, 0x0000 }, |
| 757 | { GROM2_TAG, NATIVE, CONT, 0xf830, 0xfff1, 0x0000 }, |
| 758 | { GROMPORT_TAG, NATIVE, CONT, 0xf830, 0xfff1, 0x0000 }, |
| 564 | 759 | |
| 565 | | { "mapper", 1, 1, 0xfff0, 0x8810, 0x0000, NULL, ti99_mapreg_w }, |
| 566 | | { "soundgen", 1, 1, 0xfff0, 0x8400, 0x0000, NULL, sn76496_w }, |
| 567 | | { "video", 1, 1, 0xfffd, 0x8800, 0x0400, ti8_tms991x_rz, ti8_tms991x_w }, |
| 568 | | { "speech", 1, 1, 0xfff0, 0x9000, 0x0400, ti998spch_rz, ti998spch_w }, |
| 569 | | { SRAMNAME, 1, 1, 0xf800, 0x8000, 0x0000, NULL, NULL }, // write at the end; soundgen must be found earlier |
| 760 | // { GROMTTS0_TAG, PATGEN, CONT, 0xf840, 0xfff1, 0x0000 }, // up to 6 GROMs; no good dumps known |
| 761 | // { GROMPC10_TAG, PATGEN, CONT, 0xf850, 0xfff1, 0x0000 }, // up to 6 GROMs; no good dumps known |
| 762 | // { GROMPC20_TAG, PATGEN, CONT, 0xf860, 0xfff1, 0x0000 }, // up to 6 GROMs; no good dumps known |
| 763 | { MAPPER_TAG, NATIVE, STOP, 0xf870, 0xfff0, 0x0000 }, |
| 570 | 764 | |
| 571 | | // Physical (need to pack this into here as well) |
| 572 | | { DRAMNAME, 3, 1, 0xff0000, 0x000000, 0x000000, NULL, NULL }, |
| 573 | | { "mapper", 3, 0, 0xffe000, 0xff4000, 0x000000, ti998dsr_rz, NULL }, // DSR |
| 574 | | { "gromport", 3, 1, 0xffe000, 0xff6000, 0x000000, gromportr_rz, gromportr_w }, |
| 575 | | { "gromport", 3, 1, 0xffe000, 0xff8000, 0x000000, gromportr_rz, gromportr_w }, |
| 576 | | { ROM1NAME, 3, 1, 0xffe000, 0xffa000, 0x000000, NULL, NULL }, |
| 577 | | { ROM1ANAME, 3, 1, 0xffe000, 0xffc000, 0x000000, NULL, NULL }, |
| 578 | | { INTSNAME, 3, 1, 0xfffff0, 0xffe000, 0x000000, NULL, NULL }, |
| 579 | | { "peribox", 3, 1, 0x000000, 0x000000, 0x000000, ti99_peb_data_rz, ti99_peb_data_w }, |
| 765 | // TI-99/4A mode (CRUS=1) |
| 766 | // GROMs: According to the spec, the 99/8 supports up to 4 GROM libraries |
| 767 | // (99/4A supports 256 libraries) |
| 768 | // at 9800, 9804, 9808, 980c. Address counter access is at 9802,6,a,e. Write access +0400. |
| 769 | { ROM0NAME, TI99EM, STOP, 0x0000, 0xe000, 0x0000 }, // 0000-1fff |
| 580 | 770 | |
| 581 | | { NULL, 0, 0, 0, 0, 0, NULL, NULL } |
| 771 | { GROM0_TAG, TI99EM, CONT, 0x9800, 0xfff1, 0x0400 }, // 9800,2,4,...e/9c00,2,4,...e |
| 772 | { GROM1_TAG, TI99EM, CONT, 0x9800, 0xfff1, 0x0400 }, // dto. |
| 773 | { GROM2_TAG, TI99EM, CONT, 0x9800, 0xfff1, 0x0400 }, // dto. (GROMs are connected in parallel, |
| 774 | { GROMPORT_TAG, TI99EM, CONT, 0x9800, 0xfff1, 0x0400 }, // dto. use internal address counter and id) |
| 775 | |
| 776 | { TISOUND_TAG, TI99EM, STOP, 0x8400, 0xfff0, 0x0000 }, // 8400-840f |
| 777 | { VIDEO_SYSTEM_TAG, TI99EM, STOP, 0x8800, 0xfffd, 0x0400 }, // 8800,8802 / 8c00,8c02 |
| 778 | { SPEECH_TAG, TI99EM, STOP, 0x9000, 0xfff0, 0x0400 }, // 9000-900f / 9400-940f |
| 779 | { SRAMNAME, TI99EM, STOP, 0x8000, 0xf800, 0x0000 }, // 8000-87ff; must follow the sound generator |
| 780 | { MAPPER_TAG, TI99EM, STOP, 0x8810, 0xfff0, 0x0000 }, |
| 781 | |
| 782 | // Physical (need to pack this in here as well to keep config simple) |
| 783 | { DRAMNAME, PHYSIC, STOP, 0x000000, 0xff0000, 0x000000 }, // 000000-00ffff 64 KiB DRAM |
| 784 | { MAPPER_TAG, PHYSIC, CONT, 0xff4000, 0xffe000, 0x000000 }, // ff4000-ff5fff Internal DSR |
| 785 | { GROMPORT_TAG, PHYSIC, STOP, 0xff6000, 0xffe000, 0x000000 }, // ff6000-ff7fff Cartridge ROM space |
| 786 | { GROMPORT_TAG, PHYSIC, STOP, 0xff8000, 0xffe000, 0x000000 }, // ff8000-ff9fff Cartridge ROM space |
| 787 | { ROM1NAME, PHYSIC, STOP, 0xffa000, 0xffe000, 0x000000 }, // ffa000-ffbfff ROM1 |
| 788 | { ROM1ANAME, PHYSIC, STOP, 0xffc000, 0xffe000, 0x000000 }, // ffc000-ffdfff ROM1 |
| 789 | { INTSNAME, PHYSIC, STOP, 0xffe000, 0xfffff0, 0x000000 }, // ffe000-ffe00f Interrupt level sense |
| 790 | { PERIBOX_TAG, PHYSIC, STOP, 0x000000, 0x000000, 0x000000 }, // Peripheral Expansion Box |
| 791 | |
| 792 | { NULL, 0, 0, 0, 0, 0 } |
| 582 | 793 | }; |
| 583 | 794 | |
| 584 | | static const cruconf_device cru_devices[] = |
| 795 | MACHINE_START( ti99_8 ) |
| 585 | 796 | { |
| 586 | | { "mapper", 0xfff0, 0x2700, NULL, mapper8c_w }, |
| 587 | | { "gromport", 0xf800, 0x0800, gromportc_rz, gromportc_w }, // Check: Is this really limited? |
| 588 | | { "peribox", 0x0000, 0x0000, ti99_peb_cru_rz, ti99_peb_cru_w }, // Peribox needs all addresses |
| 589 | | { NULL, 0, 0, NULL, NULL } |
| 590 | | }; |
| 797 | ti99_8 *driver = machine.driver_data<ti99_8>(); |
| 798 | driver->m_cpu = machine.device("maincpu"); |
| 799 | driver->m_tms9901 = static_cast<tms9901_device*>(machine.device(TMS9901_TAG)); |
| 800 | driver->m_gromport = static_cast<gromport_device*>(machine.device(GROMPORT_TAG)); |
| 801 | driver->m_peribox = static_cast<peribox_device*>(machine.device(PERIBOX_TAG)); |
| 802 | driver->m_mapper = static_cast<ti998_mapper_device*>(machine.device(MAPPER_TAG)); |
| 803 | driver->m_peribox->senila(CLEAR_LINE); |
| 804 | driver->m_peribox->senilb(CLEAR_LINE); |
| 805 | } |
| 591 | 806 | |
| 592 | 807 | MACHINE_RESET( ti99_8 ) |
| 593 | 808 | { |
| 809 | ti99_8 *driver = machine.driver_data<ti99_8>(); |
| 810 | |
| 811 | if (input_port_read(machine, "MECMOUSE")==0x01) |
| 812 | driver->m_mecmouse = static_cast<mecmouse_device*>(machine.device(MECMOUSE_TAG)); |
| 813 | else |
| 814 | driver->m_mecmouse = NULL; |
| 594 | 815 | } |
| 595 | 816 | |
| 596 | | static MACHINE_CONFIG_START( ti99_8_60hz, ti99_8_state ) |
| 817 | static MACHINE_CONFIG_START( ti99_8_60hz, ti99_8 ) |
| 597 | 818 | /* basic machine hardware */ |
| 598 | 819 | /* TMS9995-MP9537 CPU @ 10.7 MHz */ |
| 599 | 820 | MCFG_CPU_ADD("maincpu", TMS9995, 10738635) |
| 600 | 821 | MCFG_CPU_CONFIG(ti99_8_processor_config) |
| 601 | | MCFG_CPU_PROGRAM_MAP(ti99_8_memmap) |
| 602 | | MCFG_CPU_IO_MAP(ti99_8_cru_map) |
| 603 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 604 | | |
| 822 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 823 | MCFG_CPU_IO_MAP(crumap) |
| 824 | MCFG_MACHINE_START( ti99_8 ) |
| 605 | 825 | MCFG_MACHINE_RESET( ti99_8 ) |
| 606 | 826 | |
| 607 | | /* video hardware */ |
| 608 | | MCFG_TI_TMS991x_ADD_NTSC("video", TMS9118, ti99_8_tms9928a_interface) |
| 827 | /* Video hardware */ |
| 828 | MCFG_TI998_ADD_NTSC(VIDEO_SYSTEM_TAG, TMS9118, ti99_8_tms9118a_interface) |
| 609 | 829 | |
| 610 | | MCFG_GFXDECODE(ti99_8) |
| 830 | /* Main board */ |
| 831 | MCFG_TMS9901_ADD( TMS9901_TAG, tms9901_wiring_ti99_8, 2684658.75 ) |
| 832 | MCFG_MAPPER8_ADD( MAPPER_TAG, mapper_devices ) |
| 833 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 611 | 834 | |
| 612 | | /* sound hardware */ |
| 835 | /* Peripheral expansion box */ |
| 836 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 837 | |
| 838 | /* Sound hardware */ |
| 613 | 839 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 840 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN76496, 3579545) /* 3.579545 MHz */ |
| 841 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 842 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 843 | |
| 844 | /* Cassette drives */ |
| 845 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 614 | 846 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 615 | 847 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 616 | | MCFG_SOUND_ADD("soundgen", SN76496, 3579545) /* 3.579545 MHz */ |
| 617 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 618 | 848 | |
| 619 | | MCFG_TISPEECH_ADD("speech") |
| 849 | /* Console GROMs */ |
| 850 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 851 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 852 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 620 | 853 | |
| 621 | | MCFG_TI998_BOARD_ADD( "ti_board" ) |
| 622 | | MCFG_MAPPER8_ADD( "mapper", mapper_devices ) |
| 854 | /* Devices */ |
| 855 | MCFG_TISPEECH8_ADD(SPEECH_TAG) |
| 623 | 856 | |
| 624 | | /* tms9901 */ |
| 625 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_8) |
| 626 | | |
| 627 | | MCFG_CRUBUS_ADD( "crubus", cru_devices) |
| 628 | | |
| 629 | | MCFG_GROM_ADD( "grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 630 | | MCFG_GROM_ADD( "grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 631 | | MCFG_GROM_ADD( "grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 632 | | |
| 633 | | MCFG_PBOX8_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 634 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 635 | | |
| 636 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 637 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 857 | /* Optional user controller */ |
| 858 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 60 ) |
| 638 | 859 | MACHINE_CONFIG_END |
| 639 | 860 | |
| 640 | 861 | |
| 641 | | static MACHINE_CONFIG_START( ti99_8_50hz, ti99_8_state ) |
| 862 | static MACHINE_CONFIG_START( ti99_8_50hz, ti99_8 ) |
| 642 | 863 | /* basic machine hardware */ |
| 643 | 864 | /* TMS9995-MP9537 CPU @ 10.7 MHz */ |
| 644 | 865 | MCFG_CPU_ADD("maincpu", TMS9995, 10738635) |
| 645 | 866 | MCFG_CPU_CONFIG(ti99_8_processor_config) |
| 646 | | MCFG_CPU_PROGRAM_MAP(ti99_8_memmap) |
| 647 | | MCFG_CPU_IO_MAP(ti99_8_cru_map) |
| 648 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 649 | | |
| 867 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 868 | MCFG_CPU_IO_MAP(crumap) |
| 869 | MCFG_MACHINE_START( ti99_8 ) |
| 650 | 870 | MCFG_MACHINE_RESET( ti99_8 ) |
| 651 | 871 | |
| 652 | | /* video hardware */ |
| 653 | | MCFG_TI_TMS991x_ADD_PAL("video", TMS9129, ti99_8, ti99_8_tms9928a_interface) |
| 872 | /* Video hardware */ |
| 873 | MCFG_TI998_ADD_PAL(VIDEO_SYSTEM_TAG, TMS9129, ti99_8_tms9118a_interface) |
| 654 | 874 | |
| 655 | | MCFG_GFXDECODE(ti99_8) |
| 875 | /* Main board */ |
| 876 | MCFG_TMS9901_ADD( TMS9901_TAG, tms9901_wiring_ti99_8, 2684658.75 ) |
| 877 | MCFG_MAPPER8_ADD( MAPPER_TAG, mapper_devices ) |
| 878 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 656 | 879 | |
| 657 | | /* sound hardware */ |
| 880 | /* Peripheral expansion box */ |
| 881 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 882 | |
| 883 | /* Sound hardware */ |
| 658 | 884 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 885 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN76496, 3579545) /* 3.579545 MHz */ |
| 886 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 887 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 888 | |
| 889 | /* Cassette drives */ |
| 890 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 659 | 891 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 660 | 892 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 661 | | MCFG_SOUND_ADD("soundgen", SN76496, 3579545) /* 3.579545 MHz */ |
| 662 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 663 | 893 | |
| 664 | | MCFG_TISPEECH_ADD("speech") |
| 894 | /* Console GROMs */ |
| 895 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 896 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 897 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 665 | 898 | |
| 666 | | MCFG_TI998_BOARD_ADD( "ti_board" ) |
| 667 | | MCFG_MAPPER8_ADD( "mapper", mapper_devices ) |
| 899 | /* Devices */ |
| 900 | MCFG_TISPEECH8_ADD(SPEECH_TAG) |
| 668 | 901 | |
| 669 | | /* tms9901 */ |
| 670 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_8) |
| 671 | | |
| 672 | | MCFG_CRUBUS_ADD( "crubus", cru_devices) |
| 673 | | |
| 674 | | MCFG_GROM_ADD( "grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 675 | | MCFG_GROM_ADD( "grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 676 | | MCFG_GROM_ADD( "grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 677 | | |
| 678 | | MCFG_PBOX8_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 679 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 680 | | |
| 681 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 682 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 902 | /* Optional user controller */ |
| 903 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 50 ) |
| 683 | 904 | MACHINE_CONFIG_END |
| 684 | 905 | |
| 685 | 906 | /* |
| r14513 | r14514 | |
| 694 | 915 | ROM_REGION(0x10000, region_grom, 0) |
| 695 | 916 | ROM_LOAD("998grom.bin", 0x0000, 0x6000, CRC(c63806bc) SHA1(cbfa8b04b4aefbbd9a713c54267ad4dd179c13a3)) /* system GROMs */ |
| 696 | 917 | |
| 918 | /* Built-in RAM */ |
| 919 | ROM_REGION(SRAM_SIZE, SRAM_TAG, 0) |
| 920 | ROM_FILL(0x0000, SRAM_SIZE, 0x00) |
| 921 | |
| 922 | ROM_REGION(DRAM_SIZE, DRAM_TAG, 0) |
| 923 | ROM_FILL(0x0000, DRAM_SIZE, 0x00) |
| 697 | 924 | ROM_END |
| 698 | 925 | |
| 699 | 926 | #define rom_ti99_8e rom_ti99_8 |
src/mess/drivers/geneve.c
| r14513 | r14514 | |
| 197 | 197 | keyboard will be cleared as soon as it is buffered by the gate array. |
| 198 | 198 | */ |
| 199 | 199 | |
| 200 | #define ADDRESS_MAP_MODERN |
| 201 | |
| 200 | 202 | #include "emu.h" |
| 201 | 203 | #include "cpu/tms9900/tms9900.h" |
| 202 | | #include "machine/ti99/genboard.h" |
| 203 | 204 | #include "machine/tms9901.h" |
| 204 | | #include "machine/ti99/videowrp.h" |
| 205 | #include "machine/mm58274c.h" |
| 205 | 206 | #include "sound/sn76496.h" |
| 207 | |
| 208 | #include "machine/ti99/genboard.h" |
| 206 | 209 | #include "machine/ti99/peribox.h" |
| 210 | #include "machine/ti99/videowrp.h" |
| 207 | 211 | |
| 212 | #define VERBOSE 1 |
| 213 | #define LOG logerror |
| 208 | 214 | |
| 209 | | class geneve_state : public driver_device |
| 215 | #define SRAM_SIZE 384*1024 // maximum SRAM expansion on-board |
| 216 | #define DRAM_SIZE 512*1024 |
| 217 | |
| 218 | class geneve : public driver_device |
| 210 | 219 | { |
| 211 | 220 | public: |
| 212 | | geneve_state(const machine_config &mconfig, device_type type, const char *tag) |
| 221 | geneve(const machine_config &mconfig, device_type type, const char *tag) |
| 213 | 222 | : driver_device(mconfig, type, tag) { } |
| 214 | 223 | |
| 224 | // CRU (Communication Register Unit) handling |
| 225 | DECLARE_READ8_MEMBER(cruread); |
| 226 | DECLARE_WRITE8_MEMBER(cruwrite); |
| 227 | |
| 228 | // Connections with the system interface TMS9901 |
| 229 | DECLARE_READ8_MEMBER(read_by_9901); |
| 230 | DECLARE_WRITE_LINE_MEMBER(peripheral_bus_reset); |
| 231 | DECLARE_WRITE_LINE_MEMBER(VDP_reset); |
| 232 | DECLARE_WRITE_LINE_MEMBER(joystick_select); |
| 233 | DECLARE_WRITE_LINE_MEMBER(extbus_wait_states); |
| 234 | DECLARE_WRITE_LINE_MEMBER(video_wait_states); |
| 235 | DECLARE_WRITE8_MEMBER(tms9901_interrupt); |
| 236 | |
| 237 | WRITE_LINE_MEMBER( keyboard_interrupt ); |
| 238 | |
| 239 | geneve_keyboard_device* m_keyboard; |
| 240 | geneve_mouse_device* m_mouse; |
| 241 | tms9901_device* m_tms9901; |
| 242 | geneve_mapper_device* m_mapper; |
| 243 | peribox_device* m_peribox; |
| 244 | device_t* m_cpu; |
| 245 | |
| 246 | WRITE_LINE_MEMBER( inta ); |
| 247 | WRITE_LINE_MEMBER( intb ); |
| 248 | WRITE_LINE_MEMBER( ready ); |
| 249 | |
| 250 | void set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state); |
| 251 | |
| 252 | line_state m_inta; |
| 253 | line_state m_intb; |
| 254 | line_state m_int2; |
| 255 | line_state m_keyint; |
| 256 | line_state m_video_wait; // reflects the line to the mapper for CRU query |
| 257 | private: |
| 258 | int m_joystick_select; |
| 259 | // Some values to keep. Rest is on the geneve_mapper. |
| 215 | 260 | }; |
| 216 | 261 | |
| 217 | 262 | |
| 218 | 263 | /* |
| 219 | | memory map |
| 264 | Memory map |
| 220 | 265 | */ |
| 221 | 266 | |
| 222 | | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 8) |
| 223 | | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE("geneve_board", geneve_r, geneve_w) |
| 267 | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 8, geneve) |
| 268 | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE(GMAPPER_TAG, geneve_mapper_device, readm, writem) |
| 224 | 269 | ADDRESS_MAP_END |
| 225 | 270 | |
| 226 | 271 | /* |
| r14513 | r14514 | |
| 231 | 276 | TODO: Check whether A0-A2 are available for CRU addressing since those |
| 232 | 277 | bits are usually routed through the mapper first. |
| 233 | 278 | */ |
| 234 | | static ADDRESS_MAP_START(cru_map, AS_IO, 8) |
| 235 | | AM_RANGE(0x0000, 0x0003) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 236 | | AM_RANGE(0x0000, 0x0fff) AM_DEVREAD("geneve_board", geneve_cru_r) |
| 279 | static ADDRESS_MAP_START(crumap, AS_IO, 8, geneve) |
| 280 | AM_RANGE(0x0000, 0x0003) AM_DEVREAD(TMS9901_TAG, tms9901_device, read) |
| 281 | AM_RANGE(0x0000, 0x0fff) AM_READ( cruread ) |
| 237 | 282 | |
| 238 | | AM_RANGE(0x0000, 0x001f) AM_DEVWRITE("tms9901", tms9901_cru_w) |
| 239 | | AM_RANGE(0x0000, 0x7fff) AM_DEVWRITE("geneve_board", geneve_cru_w) |
| 283 | AM_RANGE(0x0000, 0x001f) AM_DEVWRITE(TMS9901_TAG, tms9901_device, write) |
| 284 | AM_RANGE(0x0000, 0x7fff) AM_WRITE( cruwrite ) |
| 240 | 285 | ADDRESS_MAP_END |
| 241 | 286 | |
| 242 | | static INPUT_CHANGED( gm_changed ) |
| 243 | | { |
| 244 | | device_t *board = field.machine().device("geneve_board"); |
| 245 | | set_gm_switches(board, (UINT8)((UINT64)param&0x03), newval); |
| 246 | | } |
| 247 | | |
| 248 | 287 | /* |
| 249 | 288 | Input ports, used by machine code for keyboard and joystick emulation. |
| 250 | 289 | */ |
| r14513 | r14514 | |
| 253 | 292 | static INPUT_PORTS_START(geneve) |
| 254 | 293 | |
| 255 | 294 | PORT_START( "MODE" ) |
| 256 | | PORT_CONFNAME( 0x01, 0x00, "Operating mode" ) |
| 295 | PORT_CONFNAME( 0x01, 0x00, "Operating mode" ) PORT_CHANGED_MEMBER(PERIBOX_TAG, peribox_device, genmod_changed, 0) |
| 257 | 296 | PORT_CONFSETTING( 0x00, "Standard" ) |
| 258 | 297 | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 259 | 298 | |
| 260 | 299 | PORT_START( "BOOTROM" ) |
| 261 | | PORT_CONFNAME( 0x01, 0x00, "Boot ROM" ) PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 262 | | PORT_CONFSETTING( 0x00, "Version 0.98" ) |
| 263 | | PORT_CONFSETTING( 0x01, "Version 1.00" ) |
| 300 | PORT_CONFNAME( 0x01, GENEVE_098, "Boot ROM" ) PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 301 | PORT_CONFSETTING( GENEVE_098, "Version 0.98" ) |
| 302 | PORT_CONFSETTING( GENEVE_100, "Version 1.00" ) |
| 264 | 303 | |
| 265 | | PORT_START( "SPEECH" ) |
| 266 | | PORT_CONFNAME( 0x01, 0x00, "Speech synthesizer" ) |
| 267 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 268 | | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 269 | | |
| 270 | 304 | PORT_START( "SRAM" ) |
| 271 | 305 | PORT_CONFNAME( 0x03, 0x01, "Onboard SRAM" ) PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 272 | 306 | PORT_CONFSETTING( 0x00, "32 KiB" ) |
| 273 | 307 | PORT_CONFSETTING( 0x01, "64 KiB" ) |
| 274 | 308 | PORT_CONFSETTING( 0x02, "384 KiB" ) |
| 275 | 309 | |
| 276 | | PORT_START( "EXTRAM" ) |
| 277 | | PORT_CONFNAME( 0x01, 0x01, "Memory expansion" ) |
| 278 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 279 | | PORT_CONFSETTING( 0x01, "Memex 2 MiB" ) |
| 280 | | |
| 281 | | // The BwG controller fails to boot on the Geneve. To be checked. |
| 282 | | PORT_START( "DISKCTRL" ) |
| 283 | | PORT_CONFNAME( 0x07, 0x03, "Disk controller" ) |
| 284 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 285 | | PORT_CONFSETTING( 0x01, "TI SD Floppy Controller" ) |
| 286 | | // PORT_CONFSETTING( 0x02, "SNUG BwG Controller" ) |
| 287 | | PORT_CONFSETTING( 0x03, "Myarc HFDC" ) |
| 288 | | // PORT_CONFSETTING( 0x04, "Corcomp" ) |
| 289 | | |
| 290 | | PORT_START( "BWGDIP1" ) |
| 291 | | PORT_DIPNAME( 0x01, 0x00, "BwG step rate" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 292 | | PORT_DIPSETTING( 0x00, "6 ms") |
| 293 | | PORT_DIPSETTING( 0x01, "20 ms") |
| 294 | | |
| 295 | | PORT_START( "BWGDIP2" ) |
| 296 | | PORT_DIPNAME( 0x01, 0x00, "BwG date/time display" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 297 | | PORT_DIPSETTING( 0x00, "Hide") |
| 298 | | PORT_DIPSETTING( 0x01, "Show") |
| 299 | | |
| 300 | | PORT_START( "BWGDIP34" ) |
| 301 | | PORT_DIPNAME( 0x03, 0x00, "BwG drives" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 302 | | PORT_DIPSETTING( 0x00, "DSK1 only") |
| 303 | | PORT_DIPSETTING( 0x01, "DSK1-DSK2") |
| 304 | | PORT_DIPSETTING( 0x02, "DSK1-DSK3") |
| 305 | | PORT_DIPSETTING( 0x03, "DSK1-DSK4") |
| 306 | | |
| 307 | | PORT_START( "HDCTRL" ) |
| 308 | | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 309 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 310 | | // PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 311 | | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 312 | | PORT_CONFNAME( 0x08, 0x00, "USB-SM card" ) |
| 313 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 314 | | PORT_CONFSETTING( 0x08, DEF_STR( On ) ) |
| 315 | | |
| 316 | | PORT_START( "SERIAL" ) |
| 317 | | PORT_CONFNAME( 0x03, 0x00, "Serial/Parallel interface" ) |
| 318 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 319 | | PORT_CONFSETTING( 0x01, "TI RS-232 card" ) |
| 320 | | |
| 321 | | PORT_START( "SERIALMAP" ) |
| 322 | | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) PORT_CONDITION( "SERIAL", 0x03, PORTCOND_NOTEQUALS, 0x00 ) |
| 323 | | PORT_CONFSETTING( 0x00, "6-20" ) |
| 324 | | PORT_CONFSETTING( 0x01, "8-20" ) |
| 325 | | PORT_CONFSETTING( 0x02, "5-20" ) |
| 326 | | |
| 327 | | PORT_START( "MEMEXDIPS" ) |
| 328 | | PORT_DIPNAME( MDIP1, MDIP1, "MEMEX SW1" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 329 | | PORT_DIPSETTING( 0x00, "LED half-bright for 0 WS") |
| 330 | | PORT_DIPSETTING( MDIP1, "LED full-bright") |
| 331 | | PORT_DIPNAME( MDIP2, 0x00, "MEMEX SW2" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 332 | | PORT_DIPSETTING( 0x00, "Lock out all BA mirrors") |
| 333 | | PORT_DIPSETTING( MDIP2, "Lock out page BA only") |
| 334 | | PORT_DIPNAME( MDIP3, 0x00, "MEMEX SW3" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 335 | | PORT_DIPSETTING( 0x00, "Enable pages E8-EB") |
| 336 | | PORT_DIPSETTING( MDIP3, "Lock out pages E8-EB") |
| 337 | | PORT_DIPNAME( MDIP4, 0x00, "MEMEX SW4" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 338 | | PORT_DIPSETTING( 0x00, "Enable pages EC-EF") |
| 339 | | PORT_DIPSETTING( MDIP4, "Lock out pages EC-EF") |
| 340 | | PORT_DIPNAME( MDIP5, 0x00, "MEMEX SW5" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 341 | | PORT_DIPSETTING( 0x00, "Enable pages F0-F3") |
| 342 | | PORT_DIPSETTING( MDIP5, "Lock out pages F0-F3") |
| 343 | | PORT_DIPNAME( MDIP6, 0x00, "MEMEX SW6" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 344 | | PORT_DIPSETTING( 0x00, "Enable pages F4-F7") |
| 345 | | PORT_DIPSETTING( MDIP6, "Lock out pages F4-F7") |
| 346 | | PORT_DIPNAME( MDIP7, 0x00, "MEMEX SW7" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 347 | | PORT_DIPSETTING( 0x00, "Enable pages F8-FB") |
| 348 | | PORT_DIPSETTING( MDIP7, "Lock out pages F8-FB") |
| 349 | | PORT_DIPNAME( MDIP8, 0x00, "MEMEX SW8" ) PORT_CONDITION( "EXTRAM", 0x01, PORTCOND_EQUALS, 0x01 ) |
| 350 | | PORT_DIPSETTING( 0x00, "Enable pages FC-FF") |
| 351 | | PORT_DIPSETTING( MDIP8, "Lock out pages FC-FF") |
| 352 | | |
| 353 | | PORT_START( "HFDCDIP" ) |
| 354 | | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 355 | | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 356 | | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 357 | | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 358 | | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 359 | | |
| 360 | | PORT_START( "V9938-MEM" ) |
| 361 | | PORT_CONFNAME( 0x01, 0x00, "V9938 RAM size" ) |
| 362 | | PORT_CONFSETTING( 0x00, "128 KiB" ) |
| 363 | | PORT_CONFSETTING( 0x01, "192 KiB" ) |
| 364 | | |
| 365 | 310 | PORT_START( "GENMODDIPS" ) |
| 366 | | PORT_DIPNAME( GM_TURBO, 0x00, "Genmod Turbo mode") PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, GENMOD ) PORT_CHANGED( gm_changed, (void *)1) |
| 311 | PORT_DIPNAME( GM_TURBO, 0x00, "Genmod Turbo mode") PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, GENMOD ) PORT_CHANGED_MEMBER(GMAPPER_TAG, geneve_mapper_device, gm_changed, 1) |
| 367 | 312 | PORT_CONFSETTING( 0x00, DEF_STR( Off )) |
| 368 | 313 | PORT_CONFSETTING( GM_TURBO, DEF_STR( On )) |
| 369 | | PORT_DIPNAME( GM_TIM, GM_TIM, "Genmod TI mode") PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, GENMOD ) PORT_CHANGED( gm_changed, (void *)2) |
| 314 | PORT_DIPNAME( GM_TIM, GM_TIM, "Genmod TI mode") PORT_CONDITION( "MODE", 0x01, PORTCOND_EQUALS, GENMOD ) PORT_CHANGED_MEMBER(GMAPPER_TAG, geneve_mapper_device, gm_changed, 2) |
| 370 | 315 | PORT_CONFSETTING( 0x00, DEF_STR( Off )) |
| 371 | 316 | PORT_CONFSETTING( GM_TIM, DEF_STR( On )) |
| 372 | 317 | |
| 373 | | PORT_START( "DRVSPD" ) |
| 374 | | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 375 | | PORT_CONFSETTING( 0x00, "No delay") |
| 376 | | PORT_CONFSETTING( 0x01, "Realistic") |
| 377 | | |
| 378 | 318 | PORT_START("JOY") /* col 1: "wired handset 1" (= joystick 1) */ |
| 379 | 319 | PORT_BIT(0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP/*, "(1UP)", CODE_NONE, OSD_JOY_UP*/) PORT_PLAYER(1) |
| 380 | 320 | PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN/*, "(1DOWN)", CODE_NONE, OSD_JOY_DOWN, 0*/) PORT_PLAYER(1) |
| r14513 | r14514 | |
| 389 | 329 | PORT_BIT(0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT/*, "(2LEFT)", CODE_NONE, OSD_JOY2_LEFT, 0*/) PORT_PLAYER(2) |
| 390 | 330 | PORT_BIT(0x0800, IP_ACTIVE_LOW, IPT_BUTTON1/*, "(2FIRE)", CODE_NONE, OSD_JOY2_FIRE, 0*/) PORT_PLAYER(2) |
| 391 | 331 | PORT_BIT(0x0700, IP_ACTIVE_HIGH, IPT_UNUSED) |
| 332 | INPUT_PORTS_END |
| 392 | 333 | |
| 393 | | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 394 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 334 | /**************************************************************************** |
| 335 | CRU handling |
| 336 | *****************************************************************************/ |
| 395 | 337 | |
| 396 | | PORT_START("MOUSEY") /* Mouse - Y AXIS */ |
| 397 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 338 | #define CRU_CONTROL_BASE 0x1ee0 |
| 339 | #define CRU_SSTEP_BASE 0x13c0 |
| 398 | 340 | |
| 399 | | PORT_START("MOUSE0") /* mouse buttons */ |
| 400 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("mouse button 1") |
| 401 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("mouse button 2") |
| 402 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("mouse button 3") |
| 341 | WRITE8_MEMBER ( geneve::cruwrite ) |
| 342 | { |
| 343 | int addroff = offset << 1; |
| 403 | 344 | |
| 404 | | PORT_START("KEY0") /* IN3 */ |
| 405 | | PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */ |
| 406 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) /* Esc 01 81 */ |
| 407 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) /* 1 02 82 */ |
| 408 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2 @") PORT_CODE(KEYCODE_2) /* 2 03 83 */ |
| 409 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) /* 3 04 84 */ |
| 410 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) /* 4 05 85 */ |
| 411 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) /* 5 06 86 */ |
| 412 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6 ^") PORT_CODE(KEYCODE_6) /* 6 07 87 */ |
| 413 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7 &") PORT_CODE(KEYCODE_7) /* 7 08 88 */ |
| 414 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8 *") PORT_CODE(KEYCODE_8) /* 8 09 89 */ |
| 415 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9 (") PORT_CODE(KEYCODE_9) /* 9 0A 8A */ |
| 416 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0 )") PORT_CODE(KEYCODE_0) /* 0 0B 8B */ |
| 417 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("- _") PORT_CODE(KEYCODE_MINUS) /* - 0C 8C */ |
| 418 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("= +") PORT_CODE(KEYCODE_EQUALS) /* = 0D 8D */ |
| 419 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) /* Backspace 0E 8E */ |
| 420 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) /* Tab 0F 8F */ |
| 345 | // Single step |
| 346 | // 13c0 - 13fe: 0001 0011 11xx xxx0 |
| 347 | if ((addroff & 0xffc0) == CRU_SSTEP_BASE) |
| 348 | { |
| 349 | int bit = (addroff & 0x003e)>>1; |
| 350 | if (VERBOSE>0) LOG("geneve: Single step not implemented; bit %d set to %d\n", bit, data); |
| 351 | return; |
| 352 | } |
| 421 | 353 | |
| 422 | | PORT_START("KEY1") /* IN4 */ |
| 423 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) /* Q 10 90 */ |
| 424 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) /* W 11 91 */ |
| 425 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) /* E 12 92 */ |
| 426 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) /* R 13 93 */ |
| 427 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) /* T 14 94 */ |
| 428 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) /* Y 15 95 */ |
| 429 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) /* U 16 96 */ |
| 430 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) /* I 17 97 */ |
| 431 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) /* O 18 98 */ |
| 432 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) /* P 19 99 */ |
| 433 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) /* [ 1A 9A */ |
| 434 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) /* ] 1B 9B */ |
| 435 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER) /* Enter 1C 9C */ |
| 436 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Ctrl") PORT_CODE(KEYCODE_LCONTROL) /* Left Ctrl 1D 9D */ |
| 437 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) /* A 1E 9E */ |
| 438 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) /* S 1F 9F */ |
| 354 | if ((addroff & 0xffe0) == CRU_CONTROL_BASE) |
| 355 | { |
| 356 | int bit = (addroff & 0x001e)>>1; |
| 357 | switch (bit) |
| 358 | { |
| 359 | case 5: |
| 360 | // No one really cares... |
| 361 | // m_palvideo = (data!=0); |
| 362 | break; |
| 363 | case 7: |
| 364 | // m_capslock = (data!=0); |
| 365 | break; |
| 366 | case 8: |
| 367 | m_keyboard->clock_control((data!=0)? ASSERT_LINE : CLEAR_LINE); |
| 368 | break; |
| 369 | case 9: |
| 370 | m_keyboard->send_scancodes((data!=0)? ASSERT_LINE : CLEAR_LINE); |
| 371 | break; |
| 372 | case 10: |
| 373 | m_mapper->set_geneve_mode(data!=0); |
| 374 | break; |
| 375 | case 11: |
| 376 | m_mapper->set_direct_mode(data!=0); |
| 377 | break; |
| 378 | case 12: |
| 379 | m_mapper->set_cartridge_size((data!=0)? 0x2000 : 0x4000); |
| 380 | break; |
| 381 | case 13: |
| 382 | m_mapper->set_cartridge_writable(0x6000, (data!=0)); |
| 383 | break; |
| 384 | case 14: |
| 385 | m_mapper->set_cartridge_writable(0x7000, (data!=0)); |
| 386 | break; |
| 387 | case 15: |
| 388 | m_mapper->set_extra_waitstates(data==0); // let's use the inverse semantics |
| 389 | break; |
| 390 | default: |
| 391 | if (VERBOSE>0) LOG("geneve: set CRU address %04x=%02x ignored\n", addroff, data); |
| 392 | break; |
| 393 | } |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | m_peribox->cruwrite(addroff, data); |
| 398 | } |
| 399 | } |
| 439 | 400 | |
| 440 | | PORT_START("KEY2") /* IN5 */ |
| 441 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) /* D 20 A0 */ |
| 442 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) /* F 21 A1 */ |
| 443 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) /* G 22 A2 */ |
| 444 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) /* H 23 A3 */ |
| 445 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) /* J 24 A4 */ |
| 446 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) /* K 25 A5 */ |
| 447 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) /* L 26 A6 */ |
| 448 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("; :") PORT_CODE(KEYCODE_COLON) /* ; 27 A7 */ |
| 449 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("' \"") PORT_CODE(KEYCODE_QUOTE) /* ' 28 A8 */ |
| 450 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("` ~") PORT_CODE(KEYCODE_TILDE) /* ` 29 A9 */ |
| 451 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L-Shift") PORT_CODE(KEYCODE_LSHIFT) /* Left Shift 2A AA */ |
| 452 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) /* \ 2B AB */ |
| 453 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) /* Z 2C AC */ |
| 454 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) /* X 2D AD */ |
| 455 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) /* C 2E AE */ |
| 456 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) /* V 2F AF */ |
| 401 | READ8_MEMBER( geneve::cruread ) |
| 402 | { |
| 403 | UINT8 value = 0; |
| 404 | int addroff = offset << 4; |
| 457 | 405 | |
| 458 | | PORT_START("KEY3") /* IN6 */ |
| 459 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) /* B 30 B0 */ |
| 460 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) /* N 31 B1 */ |
| 461 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) /* M 32 B2 */ |
| 462 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) /* , 33 B3 */ |
| 463 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) /* . 34 B4 */ |
| 464 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) /* / 35 B5 */ |
| 465 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R-Shift") PORT_CODE(KEYCODE_RSHIFT) /* Right Shift 36 B6 */ |
| 466 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP * (PrtScr)") PORT_CODE(KEYCODE_ASTERISK ) /* Keypad * (PrtSc) 37 B7 */ |
| 467 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Alt") PORT_CODE(KEYCODE_LALT) /* Left Alt 38 B8 */ |
| 468 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) /* Space 39 B9 */ |
| 469 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps") PORT_CODE(KEYCODE_CAPSLOCK) /* Caps Lock 3A BA */ |
| 470 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) /* F1 3B BB */ |
| 471 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) /* F2 3C BC */ |
| 472 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) /* F3 3D BD */ |
| 473 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) /* F4 3E BE */ |
| 474 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) /* F5 3F BF */ |
| 406 | // Single step |
| 407 | // 13c0 - 13fe: 0001 0011 11xx xxx0 |
| 408 | if ((addroff & 0xffc0) == CRU_SSTEP_BASE) |
| 409 | { |
| 410 | int bit = (addroff & 0x003e)>>1; |
| 411 | if (VERBOSE>0) LOG("geneve: Single step not implemented; attempting to read bit %d\n", bit); |
| 412 | return value; |
| 413 | } |
| 475 | 414 | |
| 476 | | PORT_START("KEY4") /* IN7 */ |
| 477 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) /* F6 40 C0 */ |
| 478 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) /* F7 41 C1 */ |
| 479 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) /* F8 42 C2 */ |
| 480 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) /* F9 43 C3 */ |
| 481 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) /* F10 44 C4 */ |
| 482 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NumLock") PORT_CODE(KEYCODE_NUMLOCK) /* Num Lock 45 C5 */ |
| 483 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ScrLock (F14)") PORT_CODE(KEYCODE_SCRLOCK) /* Scroll Lock 46 C6 */ |
| 484 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 7 (Home)") PORT_CODE(KEYCODE_7_PAD ) /* Keypad 7 (Home) 47 C7 */ |
| 485 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 8 (Up)") PORT_CODE(KEYCODE_8_PAD ) /* Keypad 8 (Up arrow) 48 C8 */ |
| 486 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 9 (PgUp)") PORT_CODE(KEYCODE_9_PAD ) /* Keypad 9 (PgUp) 49 C9 */ |
| 487 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) /* Keypad - 4A CA */ |
| 488 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 4 (Left)") PORT_CODE(KEYCODE_4_PAD ) /* Keypad 4 (Left arrow) 4B CB */ |
| 489 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) /* Keypad 5 4C CC */ |
| 490 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 6 (Right)") PORT_CODE(KEYCODE_6_PAD ) /* Keypad 6 (Right arrow) 4D CD */ |
| 491 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) /* Keypad + 4E CE */ |
| 492 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 1 (End)") PORT_CODE(KEYCODE_1_PAD ) /* Keypad 1 (End) 4F CF */ |
| 415 | // TMS9995-internal CRU locations (1ee0-1efe) are handled within the 99xxcore |
| 416 | // implementation (read_single_cru), so we don't arrive here |
| 493 | 417 | |
| 494 | | PORT_START("KEY5") /* IN8 */ |
| 495 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 2 (Down)") PORT_CODE(KEYCODE_2_PAD ) /* Keypad 2 (Down arrow) 50 D0 */ |
| 496 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 3 (PgDn)") PORT_CODE(KEYCODE_3_PAD ) /* Keypad 3 (PgDn) 51 D1 */ |
| 497 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 0 (Ins)") PORT_CODE(KEYCODE_0_PAD ) /* Keypad 0 (Ins) 52 D2 */ |
| 498 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP . (Del)") PORT_CODE(KEYCODE_DEL_PAD ) /* Keypad . (Del) 53 D3 */ |
| 499 | | PORT_BIT ( 0x0030, 0x0000, IPT_UNUSED ) |
| 500 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(84/102)\\") PORT_CODE(KEYCODE_BACKSLASH2) /* Backslash 2 56 D6 */ |
| 501 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)F11") PORT_CODE(KEYCODE_F11) /* F11 57 D7 */ |
| 502 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)F12") PORT_CODE(KEYCODE_F12) /* F12 58 D8 */ |
| 503 | | PORT_BIT ( 0xfe00, 0x0000, IPT_UNUSED ) |
| 418 | // Propagate the CRU access to external devices |
| 419 | m_peribox->crureadz(addroff, &value); |
| 420 | return value; |
| 421 | } |
| 504 | 422 | |
| 505 | | PORT_START("KEY6") /* IN9 */ |
| 506 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)KP Enter") PORT_CODE(KEYCODE_ENTER_PAD) /* PAD Enter 60 e0 */ |
| 507 | | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)R-Control") PORT_CODE(KEYCODE_RCONTROL) /* Right Control 61 e1 */ |
| 508 | | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)ALTGR") PORT_CODE(KEYCODE_RALT) /* ALTGR 64 e4 */ |
| 423 | /*********************************************************************** |
| 424 | CRU callbacks |
| 425 | ***********************************************************************/ |
| 509 | 426 | |
| 510 | | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)KP /") PORT_CODE(KEYCODE_SLASH_PAD) /* PAD Slash 62 e2 */ |
| 427 | READ8_MEMBER( geneve::read_by_9901 ) |
| 428 | { |
| 429 | int answer = 0; |
| 430 | int joy = 0; |
| 431 | switch (offset & 0x03) |
| 432 | { |
| 433 | case TMS9901_CB_INT7: |
| 434 | // Read pins INT3*-INT7* of Geneve 9901. |
| 435 | // |
| 436 | // bit 1: INTA status |
| 437 | // bit 2: INT2 status |
| 438 | // bit 3-7: joystick status |
| 511 | 439 | |
| 512 | | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Home") PORT_CODE(KEYCODE_HOME) /* Home 66 e6 */ |
| 513 | | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Up") PORT_CODE(KEYCODE_UP) /* Up 67 e7 */ |
| 514 | | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Page Up") PORT_CODE(KEYCODE_PGUP) /* Page Up 68 e8 */ |
| 515 | | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Left") PORT_CODE(KEYCODE_LEFT) /* Left 69 e9 */ |
| 516 | | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Right") PORT_CODE(KEYCODE_RIGHT) /* Right 6a ea */ |
| 517 | | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)End") PORT_CODE(KEYCODE_END) /* End 6b eb */ |
| 518 | | PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Cursor Down") PORT_CODE(KEYCODE_DOWN) /* Down 6c ec */ |
| 519 | | PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Page Down") PORT_CODE(KEYCODE_PGDN) /* Page Down 6d ed */ |
| 520 | | PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Insert") PORT_CODE(KEYCODE_INSERT) /* Insert 6e ee */ |
| 521 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Delete") PORT_CODE(KEYCODE_DEL) /* Delete 6f ef */ |
| 440 | // negative logic |
| 441 | if (m_inta==CLEAR_LINE) answer |= 0x02; |
| 442 | if (m_int2==CLEAR_LINE) answer |= 0x04; |
| 522 | 443 | |
| 523 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)PrtScr (F13)") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen 63 e3 */ |
| 524 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(101)Pause (F15)") PORT_CODE(KEYCODE_PAUSE) /* Pause 65 e5 */ |
| 444 | joy = input_port_read(machine(), "JOY"); |
| 445 | if (m_joystick_select==0) joy = joy & 0xff; |
| 446 | else joy = (joy>>8) & 0xff; |
| 447 | answer |= joy; |
| 525 | 448 | |
| 526 | | PORT_START("KEY7") /* IN10 */ |
| 527 | | PORT_BIT ( 0xffff, 0x0000, IPT_UNUSED ) |
| 528 | | #if 0 |
| 529 | | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Print Screen") PORT_CODE(KEYCODE_PRTSCR) /* Print Screen alternate 77 f7 */ |
| 530 | | PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left Win") /* Left Win 7d fd */ |
| 531 | | PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right Win") /* Right Win 7e fe */ |
| 532 | | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Menu") /* Menu 7f ff */ |
| 533 | | #endif |
| 449 | break; |
| 534 | 450 | |
| 535 | | INPUT_PORTS_END |
| 451 | case TMS9901_INT8_INT15: |
| 452 | // Read pins INT8*-INT15* of Geneve 9901. |
| 453 | // |
| 454 | // bit 0: keyboard interrupt |
| 455 | // bit 1: unused |
| 456 | // bit 2: mouse left button |
| 457 | // (bit 3: clock interrupt) |
| 458 | // bit 4: INTB from PE-bus |
| 459 | // bit 5 & 7: used as output |
| 460 | // bit 6: unused |
| 461 | if (m_keyint==CLEAR_LINE) answer |= 0x01; |
| 462 | if (m_mouse->left_button()==CLEAR_LINE) answer |= 0x04; |
| 463 | // TODO: add clock interrupt |
| 464 | if (m_intb==CLEAR_LINE) answer |= 0x10; |
| 465 | if (m_video_wait==ASSERT_LINE) answer |= 0x20; |
| 466 | // TODO: PAL pin 5 |
| 467 | if (VERBOSE>8) LOG("geneve: INT15-8 = %02x\n", answer); |
| 468 | break; |
| 536 | 469 | |
| 470 | case TMS9901_P0_P7: |
| 471 | // Read pins P0-P7 of TMS9901. All pins are configured as outputs, so nothing here. |
| 472 | break; |
| 473 | |
| 474 | case TMS9901_P8_P15: |
| 475 | // Read pins P8-P15 of TMS 9901. |
| 476 | // bit 4: mouse left button |
| 477 | // video wait is an output; no input possible here |
| 478 | if (m_intb==CLEAR_LINE) answer |= 0x04; // mirror from above |
| 479 | // TODO: 0x08 = real-time clock int |
| 480 | if (m_mouse->left_button()==CLEAR_LINE) answer |= 0x10; // mirror from above |
| 481 | if (m_keyint==CLEAR_LINE) answer |= 0x40; |
| 482 | |
| 483 | // Joystick up (mirror of bit 7) |
| 484 | joy = input_port_read(machine(), "JOY"); |
| 485 | if (m_joystick_select==0) joy = joy & 0xff; |
| 486 | else joy = (joy>>8) & 0xff; |
| 487 | if ((joy & 0x80)==0x00) answer |= 0x80; |
| 488 | |
| 489 | break; |
| 490 | } |
| 491 | return answer; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | Write PE bus reset line |
| 496 | */ |
| 497 | WRITE_LINE_MEMBER( geneve::peripheral_bus_reset ) |
| 498 | { |
| 499 | if (VERBOSE>0) LOG("geneve: peripheral bus reset request; not implemented yet.\n"); |
| 500 | } |
| 501 | |
| 502 | /* |
| 503 | Write VDP reset line |
| 504 | */ |
| 505 | WRITE_LINE_MEMBER( geneve::VDP_reset ) |
| 506 | { |
| 507 | if (VERBOSE>0) LOG("geneve: Video reset request; not implemented yet.\n"); |
| 508 | } |
| 509 | |
| 510 | /* |
| 511 | Write joystick select line |
| 512 | */ |
| 513 | WRITE_LINE_MEMBER( geneve::joystick_select ) |
| 514 | { |
| 515 | m_joystick_select = (state==ASSERT_LINE)? 1:0; |
| 516 | } |
| 517 | |
| 518 | /* |
| 519 | Write external mem cycles (0=long, 1=short) |
| 520 | */ |
| 521 | WRITE_LINE_MEMBER( geneve::extbus_wait_states ) |
| 522 | { |
| 523 | if (VERBOSE>0) LOG("geneve: external bus wait states set to %d, not implemented yet.\n", state); |
| 524 | } |
| 525 | |
| 526 | /* |
| 527 | Write vdp wait cycles (1=add 14 cycles, 0=add none) |
| 528 | see above for waitstate handling |
| 529 | */ |
| 530 | WRITE_LINE_MEMBER( geneve::video_wait_states ) |
| 531 | { |
| 532 | if (VERBOSE>1) LOG("geneve: vdp wait states set to %d\n", state); |
| 533 | m_mapper->set_video_waitstates(state==ASSERT_LINE); |
| 534 | m_video_wait = (state!=0)? ASSERT_LINE : CLEAR_LINE; |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes. |
| 539 | As with the TI-99/4A, the interrupt level is delivered as the offset, |
| 540 | but again it is ignored. |
| 541 | */ |
| 542 | WRITE8_MEMBER( geneve::tms9901_interrupt ) |
| 543 | { |
| 544 | /* INTREQ is connected to INT1 (IC0-3 are not connected) */ |
| 545 | device_execute(m_cpu)->set_input_line(0, data); |
| 546 | } |
| 547 | |
| 548 | /* tms9901 setup */ |
| 549 | const tms9901_interface tms9901_wiring_geneve = |
| 550 | { |
| 551 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT8 | TMS9901_INTB | TMS9901_INTC, /* only input pins whose state is always known */ |
| 552 | |
| 553 | // read handler |
| 554 | DEVCB_DRIVER_MEMBER(geneve, read_by_9901), |
| 555 | |
| 556 | { /* write handlers */ |
| 557 | DEVCB_DRIVER_LINE_MEMBER(geneve, peripheral_bus_reset), |
| 558 | DEVCB_DRIVER_LINE_MEMBER(geneve, VDP_reset), |
| 559 | DEVCB_DRIVER_LINE_MEMBER(geneve, joystick_select), |
| 560 | DEVCB_NULL, |
| 561 | DEVCB_NULL, |
| 562 | DEVCB_NULL, |
| 563 | DEVCB_DEVICE_LINE_MEMBER(GKEYBOARD_TAG, geneve_keyboard_device, reset_line), |
| 564 | DEVCB_DRIVER_LINE_MEMBER(geneve, extbus_wait_states), |
| 565 | DEVCB_NULL, |
| 566 | DEVCB_DRIVER_LINE_MEMBER(geneve, video_wait_states), |
| 567 | DEVCB_NULL, |
| 568 | DEVCB_NULL, |
| 569 | DEVCB_NULL, |
| 570 | DEVCB_NULL, |
| 571 | DEVCB_NULL, |
| 572 | DEVCB_NULL |
| 573 | }, |
| 574 | |
| 575 | /* interrupt handler */ |
| 576 | DEVCB_DRIVER_MEMBER(geneve, tms9901_interrupt) |
| 577 | }; |
| 578 | |
| 579 | /******************************************************************* |
| 580 | Signal lines |
| 581 | *******************************************************************/ |
| 582 | /* |
| 583 | inta is connected to both tms9901 IRQ1 line and to tms9995 INT4/EC line. |
| 584 | */ |
| 585 | WRITE_LINE_MEMBER( geneve::inta ) |
| 586 | { |
| 587 | m_inta = (state!=0)? ASSERT_LINE : CLEAR_LINE; |
| 588 | m_tms9901->set_single_int(1, state); |
| 589 | device_execute(m_cpu)->set_input_line(1, state); |
| 590 | } |
| 591 | |
| 592 | /* |
| 593 | intb is connected to tms9901 IRQ12 line. |
| 594 | */ |
| 595 | WRITE_LINE_MEMBER( geneve::intb ) |
| 596 | { |
| 597 | m_intb = (state!=0)? ASSERT_LINE : CLEAR_LINE; |
| 598 | m_tms9901->set_single_int(12, state); |
| 599 | } |
| 600 | |
| 601 | WRITE_LINE_MEMBER( geneve::ready ) |
| 602 | { |
| 603 | if (VERBOSE>0) LOG("geneve: READY line set ... not yet connected, level=%02x\n", state); |
| 604 | } |
| 605 | |
| 606 | /* |
| 607 | set the state of int2 (called by the v9938 core) |
| 608 | */ |
| 609 | void geneve::set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state) |
| 610 | { |
| 611 | m_int2 = (state!=0)? ASSERT_LINE : CLEAR_LINE; |
| 612 | m_tms9901->set_single_int(2, state); |
| 613 | } |
| 614 | |
| 615 | /* |
| 616 | Interrupt from the keyboard. |
| 617 | */ |
| 618 | WRITE_LINE_MEMBER( geneve::keyboard_interrupt ) |
| 619 | { |
| 620 | m_keyint = (state!=0)? ASSERT_LINE : CLEAR_LINE; |
| 621 | m_tms9901->set_single_int(8, state); |
| 622 | } |
| 623 | |
| 624 | /* |
| 625 | scanline interrupt |
| 626 | */ |
| 627 | TIMER_DEVICE_CALLBACK( geneve_hblank_interrupt ) |
| 628 | { |
| 629 | int scanline = param; |
| 630 | geneve *driver = timer.machine().driver_data<geneve>(); |
| 631 | |
| 632 | timer.machine().device<v9938_device>(V9938_TAG)->interrupt(); |
| 633 | |
| 634 | if (scanline == 0) // was 262 |
| 635 | { |
| 636 | // TODO |
| 637 | // The technical docs do not say anything about the way the mouse |
| 638 | // is queried. It sounds plausible that the mouse is sampled once |
| 639 | // per vertical interrupt; however, the mouse sometimes shows jerky |
| 640 | // behaviour. Maybe we should use an autonomous timer with a higher |
| 641 | // rate? -> to be checked |
| 642 | driver->m_mouse->poll(); |
| 643 | } |
| 644 | } |
| 645 | |
| 537 | 646 | static const struct tms9995reset_param geneve_processor_config = |
| 538 | 647 | { |
| 539 | 648 | 0, /* disable automatic wait state generation */ |
| r14513 | r14514 | |
| 541 | 650 | 0 /* no MP9537 mask */ |
| 542 | 651 | }; |
| 543 | 652 | |
| 653 | static const mm58274c_interface geneve_mm58274c_interface = |
| 654 | { |
| 655 | 1, /* mode 24*/ |
| 656 | 0 /* first day of week */ |
| 657 | }; |
| 544 | 658 | |
| 659 | static GENEVE_KEYBOARD_CONFIG( geneve_keyb_conf ) |
| 660 | { |
| 661 | DEVCB_DRIVER_LINE_MEMBER(geneve, keyboard_interrupt) |
| 662 | }; |
| 663 | |
| 664 | static PERIBOX_CONFIG( peribox_conf ) |
| 665 | { |
| 666 | DEVCB_DRIVER_LINE_MEMBER(geneve, inta), // INTA |
| 667 | DEVCB_DRIVER_LINE_MEMBER(geneve, intb), // INTB |
| 668 | DEVCB_DRIVER_LINE_MEMBER(geneve, ready), // READY |
| 669 | 0x00000 // Address bus prefix (Mapper will produce prefixes) |
| 670 | }; |
| 671 | |
| 545 | 672 | static DRIVER_INIT( geneve ) |
| 546 | 673 | { |
| 547 | 674 | } |
| 548 | 675 | |
| 549 | 676 | static MACHINE_START( geneve ) |
| 550 | 677 | { |
| 678 | geneve *driver = machine.driver_data<geneve>(); |
| 679 | driver->m_tms9901 = static_cast<tms9901_device*>(machine.device(TMS9901_TAG)); |
| 680 | driver->m_mapper = static_cast<geneve_mapper_device*>(machine.device(GMAPPER_TAG)); |
| 681 | driver->m_keyboard = static_cast<geneve_keyboard_device*>(machine.device(GKEYBOARD_TAG)); |
| 682 | driver->m_peribox = static_cast<peribox_device*>(machine.device(PERIBOX_TAG)); |
| 683 | driver->m_mouse = static_cast<geneve_mouse_device*>(machine.device(GMOUSE_TAG)); |
| 684 | driver->m_cpu = machine.device("maincpu"); |
| 551 | 685 | } |
| 552 | 686 | |
| 553 | 687 | /* |
| r14513 | r14514 | |
| 555 | 689 | */ |
| 556 | 690 | static MACHINE_RESET( geneve ) |
| 557 | 691 | { |
| 692 | geneve *driver = machine.driver_data<geneve>(); |
| 693 | driver->m_inta = CLEAR_LINE; // flag reflecting the INTA line |
| 694 | driver->m_intb = CLEAR_LINE; // flag reflecting the INTB line |
| 695 | driver->m_int2 = CLEAR_LINE; // flag reflecting the INT2 line |
| 696 | driver->m_keyint = CLEAR_LINE; |
| 697 | |
| 698 | driver->m_peribox->set_genmod(input_port_read(machine, "MODE")==GENMOD); |
| 558 | 699 | } |
| 559 | 700 | |
| 560 | | static MACHINE_CONFIG_START( geneve_60hz, geneve_state ) |
| 701 | static MACHINE_CONFIG_START( geneve_60hz, geneve ) |
| 561 | 702 | /* basic machine hardware */ |
| 562 | 703 | /* TMS9995 CPU @ 12.0 MHz */ |
| 563 | 704 | MCFG_CPU_ADD("maincpu", TMS9995, 12000000) |
| 564 | 705 | MCFG_CPU_CONFIG(geneve_processor_config) |
| 565 | 706 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 566 | | MCFG_CPU_IO_MAP(cru_map) |
| 567 | | MCFG_TIMER_ADD_SCANLINE("scantimer", geneve_hblank_interrupt, "screen", 0, 1) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 707 | MCFG_CPU_IO_MAP(crumap) |
| 568 | 708 | |
| 569 | 709 | MCFG_MACHINE_START( geneve ) |
| 570 | 710 | MCFG_MACHINE_RESET( geneve ) |
| r14513 | r14514 | |
| 573 | 713 | /* FIXME: (MZ) Lowered the screen rate to 30 Hz. This is a quick hack to |
| 574 | 714 | restore normal video speed for V9938-based systems until the V9938 implementation |
| 575 | 715 | is properly fixed. */ |
| 576 | | MCFG_TI_V9938_ADD("video", 30, "screen", 2500, 512+32, (212+28)*2, tms9901_gen_set_int2) |
| 716 | MCFG_TI_V9938_ADD(VIDEO_SYSTEM_TAG, 30, SCREEN_TAG, 2500, 512+32, (212+28)*2, DEVICE_SELF, geneve, set_tms9901_INT2_from_v9938) |
| 717 | MCFG_TIMER_ADD_SCANLINE("scantimer", geneve_hblank_interrupt, SCREEN_TAG, 0, 1) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 577 | 718 | |
| 719 | /* Main board components */ |
| 720 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_geneve, 3000000) |
| 721 | MCFG_GENEVE_MAPPER_ADD( GMAPPER_TAG ) |
| 722 | MCFG_MM58274C_ADD(GCLOCK_TAG, geneve_mm58274c_interface) |
| 723 | |
| 724 | /* Peripheral expansion box (Geneve composition) */ |
| 725 | MCFG_PERIBOX_GEN_ADD( PERIBOX_TAG, peribox_conf ) |
| 726 | |
| 578 | 727 | /* sound hardware */ |
| 579 | 728 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 580 | | MCFG_SOUND_ADD("soundgen", SN76496, 3579545) /* 3.579545 MHz */ |
| 729 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN76496, 3579545) /* 3.579545 MHz */ |
| 581 | 730 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 731 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 582 | 732 | |
| 583 | | /* Peripheral Box. Take the Geneve combo. */ |
| 584 | | MCFG_PBOXGEN_ADD( "peribox", board_inta, board_intb, board_ready ) |
| 585 | | |
| 586 | | /* tms9901 */ |
| 587 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_geneve) |
| 588 | | |
| 589 | | /* Main board. Slight mods for the GenMod system. */ |
| 590 | | MCFG_GENEVE_BOARD_ADD("geneve_board") |
| 733 | /* User interface devices */ |
| 734 | MCFG_GENEVE_KEYBOARD_ADD( GKEYBOARD_TAG, geneve_keyb_conf ) |
| 735 | MCFG_GENEVE_MOUSE_ADD( GMOUSE_TAG ) |
| 591 | 736 | MACHINE_CONFIG_END |
| 592 | 737 | |
| 593 | 738 | /* |
| 594 | 739 | ROM loading |
| 595 | | |
| 596 | | Note that we use the same ROMset for 50Hz and 60Hz versions. |
| 597 | 740 | */ |
| 598 | 741 | |
| 599 | 742 | ROM_START(geneve) |
| 600 | 743 | /*CPU memory space*/ |
| 601 | 744 | ROM_REGION(0xc000, "maincpu", 0) |
| 602 | | ROM_LOAD("genbt100.bin", 0x0000, 0x4000, CRC(8001e386) SHA1(b44618b54dabac3882543e18555d482b299e0109)) /* CPU ROMs */ |
| 603 | | ROM_LOAD_OPTIONAL("genbt098.bin", 0x4000, 0x4000, CRC(b2e20df9) SHA1(2d5d09177afe97d63ceb3ad59b498b1c9e2153f7)) /* CPU ROMs */ |
| 604 | | ROM_LOAD_OPTIONAL("gnmbt100.bin", 0x8000, 0x4000, CRC(19b89479) SHA1(6ef297eda78dc705946f6494e9d7e95e5216ec47)) /* CPU ROMs */ |
| 745 | ROM_LOAD("genbt100.bin", 0x0000, 0x4000, CRC(8001e386) SHA1(b44618b54dabac3882543e18555d482b299e0109)) /* CPU ROMs v1.0 */ |
| 746 | ROM_LOAD_OPTIONAL("genbt098.bin", 0x4000, 0x4000, CRC(b2e20df9) SHA1(2d5d09177afe97d63ceb3ad59b498b1c9e2153f7)) /* CPU ROMs v0.98 */ |
| 747 | ROM_LOAD_OPTIONAL("gnmbt100.bin", 0x8000, 0x4000, CRC(19b89479) SHA1(6ef297eda78dc705946f6494e9d7e95e5216ec47)) /* CPU ROMs GenMod */ |
| 748 | |
| 749 | ROM_REGION(SRAM_SIZE, SRAM_TAG, 0) |
| 750 | ROM_FILL(0x0000, SRAM_SIZE, 0) |
| 751 | |
| 752 | ROM_REGION(DRAM_SIZE, DRAM_TAG, 0) |
| 753 | ROM_FILL(0x0000, DRAM_SIZE, 0) |
| 605 | 754 | ROM_END |
| 606 | 755 | |
| 607 | | /*ROM_START(genmod) |
| 608 | | ROM_REGION(0x8000, "maincpu", 0) |
| 609 | | ROM_LOAD("gnmbt100.bin", 0x0000, 0x4000, CRC(19b89479) SHA1(6ef297eda78dc705946f6494e9d7e95e5216ec47)) |
| 610 | | ROM_LOAD_OPTIONAL("genbt090.bin", 0x4000, 0x4000, CRC(b2e20df9) SHA1(2d5d09177afe97d63ceb3ad59b498b1c9e2153f7)) |
| 611 | | ROM_END |
| 612 | | */ |
| 613 | 756 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 614 | 757 | COMP( 1987,geneve, 0, 0, geneve_60hz, geneve, geneve, "Myarc", "Geneve 9640" , 0) |
| 615 | | //COMP( 1990,genmod, geneve, 0, genmod_60hz, geneve, geneve, "Myarc", "Geneve 9640 (with Genmod modification)" , 0) |
| 616 | | |
src/mess/drivers/ti99_4p.c
| r14513 | r14514 | |
| 1 | | /* |
| 2 | | SNUG SGCPU (a.k.a. 99/4p) system (preliminary) |
| 1 | /**************************************************************************** |
| 3 | 2 | |
| 3 | SNUG SGCPU (a.k.a. 99/4p) system |
| 4 | |
| 4 | 5 | This system is a reimplementation of the old ti99/4a console. It is known |
| 5 | 6 | both as the 99/4p ("peripheral box", since the system is a card to be |
| 6 | 7 | inserted in the peripheral box, instead of a self contained console), and |
| r14513 | r14514 | |
| 21 | 22 | GROMs, video or sound: instead, it relies on the HSGPL and EVPC cards to |
| 22 | 23 | do the job. |
| 23 | 24 | |
| 24 | | TODO: |
| 25 | | * Test the system? Call Debug, Call XB16. |
| 26 | | * Implement MEM8 timings. |
| 27 | | |
| 28 | | 2009-11-15 |
| 29 | | This driver found to be hopelessly broken. |
| 30 | | 1. Fixed crash in DRIVER_INIT - was trying to set up GROM when this model doesn't have any. |
| 31 | | 2. Fixed crash in MACHINE_RESET - new cart system depends on GROM. |
| 32 | | 3. Fixed crash when drawing the lower border - screen size changed to the same as ti99_4ev. |
| 33 | | Now, it produces a black screen. |
| 34 | | If you use memory view in the debugger, it crashes at 6000 and some higher addresses. This is |
| 35 | | because the memory map has references to GROM handlers. |
| 36 | | |
| 37 | | 2010-06-19 |
| 38 | | MZ: Driver fixed |
| 39 | | Important: The SGCPU card relies on a properly set up HSGPL flash memory |
| 25 | IMPORTANT: The SGCPU card relies on a properly set up HSGPL flash memory |
| 40 | 26 | card; without, it will immediately lock up. It is impossible to set it up |
| 41 | 27 | from here (a bootstrap problem; you cannot start without the HSGPL). |
| 42 | | The best chance is to start a ti99_4ev, activate the |
| 43 | | HSGPL, and go through the setup process there. Copy the hsgpl.nv into this |
| 28 | The best chance is to start a ti99_4ev with a plugged-in HSGPL |
| 29 | and go through the setup process there. Copy the nvram files of the hsgpl into this |
| 44 | 30 | driver's nvram subdirectory. The contents will be directly usable for the SGCPU. |
| 45 | | */ |
| 46 | 31 | |
| 32 | Michael Zapf |
| 33 | |
| 34 | February 2012: Rewritten as class |
| 35 | |
| 36 | *****************************************************************************/ |
| 37 | |
| 38 | #define ADDRESS_MAP_MODERN |
| 39 | |
| 47 | 40 | #include "emu.h" |
| 48 | 41 | #include "cpu/tms9900/tms9900.h" |
| 49 | 42 | #include "sound/wave.h" |
| r14513 | r14514 | |
| 55 | 48 | |
| 56 | 49 | #include "imagedev/cassette.h" |
| 57 | 50 | #include "machine/ti99/videowrp.h" |
| 58 | | #include "machine/ti99/sgcpu.h" |
| 59 | 51 | #include "machine/ti99/peribox.h" |
| 60 | 52 | |
| 53 | #define TMS9901_TAG "tms9901" |
| 54 | #define SGCPU_TAG "sgcpu" |
| 61 | 55 | |
| 62 | | class ti99_4p_state : public driver_device |
| 56 | #define SAMSMEM_TAG "samsmem" |
| 57 | #define PADMEM_TAG "padmem" |
| 58 | |
| 59 | #define VERBOSE 1 |
| 60 | #define LOG logerror |
| 61 | |
| 62 | class ti99_4p : public driver_device |
| 63 | 63 | { |
| 64 | 64 | public: |
| 65 | | ti99_4p_state(const machine_config &mconfig, device_type type, const char *tag) |
| 65 | ti99_4p(const machine_config &mconfig, device_type type, const char *tag) |
| 66 | 66 | : driver_device(mconfig, type, tag) { } |
| 67 | 67 | |
| 68 | | }; |
| 68 | DECLARE_WRITE_LINE_MEMBER( console_ready ); |
| 69 | DECLARE_WRITE_LINE_MEMBER( extint ); |
| 70 | DECLARE_WRITE_LINE_MEMBER( notconnected ); |
| 69 | 71 | |
| 72 | DECLARE_READ16_MEMBER( memread ); |
| 73 | DECLARE_WRITE16_MEMBER( memwrite ); |
| 70 | 74 | |
| 71 | | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 16) |
| 72 | | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE("sgcpu_board", sgcpu_r, sgcpu_w ) |
| 73 | | ADDRESS_MAP_END |
| 75 | DECLARE_READ16_MEMBER( samsmem_read ); |
| 76 | DECLARE_WRITE16_MEMBER( samsmem_write ); |
| 74 | 77 | |
| 75 | | static ADDRESS_MAP_START(cru_map, AS_IO, 8) |
| 76 | | AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 77 | | AM_RANGE(0x0080, 0x01ff) AM_DEVREAD("sgcpu_board", sgcpu_cru_r ) |
| 78 | // CRU (Communication Register Unit) handling |
| 79 | DECLARE_READ8_MEMBER( cruread ); |
| 80 | DECLARE_WRITE8_MEMBER( cruwrite ); |
| 81 | DECLARE_READ8_MEMBER( read_by_9901 ); |
| 82 | DECLARE_WRITE_LINE_MEMBER(keyC0); |
| 83 | DECLARE_WRITE_LINE_MEMBER(keyC1); |
| 84 | DECLARE_WRITE_LINE_MEMBER(keyC2); |
| 85 | DECLARE_WRITE_LINE_MEMBER(cs_motor); |
| 86 | DECLARE_WRITE_LINE_MEMBER(audio_gate); |
| 87 | DECLARE_WRITE_LINE_MEMBER(cassette_output); |
| 88 | DECLARE_WRITE8_MEMBER(tms9901_interrupt); |
| 89 | DECLARE_WRITE_LINE_MEMBER(handset_ack); |
| 90 | DECLARE_WRITE_LINE_MEMBER(alphaW); |
| 78 | 91 | |
| 79 | | AM_RANGE(0x0000, 0x03ff) AM_DEVWRITE("tms9901", tms9901_cru_w) |
| 80 | | AM_RANGE(0x0400, 0x0fff) AM_DEVWRITE("sgcpu_board", sgcpu_cru_w ) |
| 81 | | ADDRESS_MAP_END |
| 92 | void set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state); |
| 82 | 93 | |
| 83 | | /* |
| 84 | | Input ports, used by machine code for TI keyboard and joystick emulation. |
| 94 | device_t* m_cpu; |
| 95 | ti_sound_system_device* m_sound; |
| 96 | ti_exp_video_device* m_video; |
| 97 | cassette_image_device* m_cassette; |
| 98 | peribox_device* m_peribox; |
| 99 | tms9901_device* m_tms9901; |
| 85 | 100 | |
| 86 | | Since the keyboard microcontroller is not emulated, we use the TI99/4a 48-key keyboard, |
| 87 | | plus two optional joysticks. |
| 88 | | */ |
| 101 | // Pointer to ROM0 |
| 102 | UINT16 *m_rom0; |
| 89 | 103 | |
| 90 | | static INPUT_PORTS_START(ti99_4p) |
| 104 | // Pointer to DSR ROM |
| 105 | UINT16 *m_dsr; |
| 91 | 106 | |
| 92 | | PORT_START( "SPEECH" ) |
| 93 | | PORT_CONFNAME( 0x01, 0x01, "Speech synthesizer" ) |
| 94 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 95 | | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 107 | // Pointer to ROM6, first bank |
| 108 | UINT16 *m_rom6a; |
| 96 | 109 | |
| 97 | | PORT_START( "DISKCTRL" ) |
| 98 | | PORT_CONFNAME( 0x07, 0x03, "Disk controller" ) |
| 99 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 100 | | PORT_CONFSETTING( 0x01, "TI SD Floppy Controller" ) |
| 101 | | PORT_CONFSETTING( 0x02, "SNUG BwG Controller" ) |
| 102 | | PORT_CONFSETTING( 0x03, "Myarc HFDC" ) |
| 103 | | // PORT_CONFSETTING( 0x04, "Corcomp" ) |
| 110 | // Pointer to ROM6, second bank |
| 111 | UINT16 *m_rom6b; |
| 104 | 112 | |
| 105 | | PORT_START( "HDCTRL" ) |
| 106 | | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 107 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 108 | | // PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 109 | | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 110 | | PORT_CONFNAME( 0x08, 0x00, "USB-SM card" ) |
| 111 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 112 | | PORT_CONFSETTING( 0x08, DEF_STR( On ) ) |
| 113 | // AMS RAM (1 Mib) |
| 114 | UINT16 *m_ram; |
| 113 | 115 | |
| 114 | | PORT_START( "SERIAL" ) |
| 115 | | PORT_CONFNAME( 0x03, 0x00, "Serial/Parallel interface" ) |
| 116 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 117 | | PORT_CONFSETTING( 0x01, "TI RS-232 card" ) |
| 116 | // Scratch pad ram (1 KiB) |
| 117 | UINT16 *m_scratchpad; |
| 118 | 118 | |
| 119 | | PORT_START( "SERIALMAP" ) |
| 120 | | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) PORT_CONDITION( "SERIAL", 0x03, PORTCOND_NOTEQUALS, 0x00 ) |
| 121 | | PORT_CONFSETTING( 0x00, "6-20" ) |
| 122 | | PORT_CONFSETTING( 0x01, "8-20" ) |
| 123 | | PORT_CONFSETTING( 0x02, "5-20" ) |
| 119 | private: |
| 120 | DECLARE_READ16_MEMBER( datamux_read ); |
| 121 | DECLARE_WRITE16_MEMBER( datamux_write ); |
| 122 | void set_key(int number, int data); |
| 123 | int m_keyboard_column; |
| 124 | int m_alphalock_line; |
| 124 | 125 | |
| 125 | | PORT_START( "EXTCARD" ) |
| 126 | | PORT_CONFNAME( 0x03, 0x02, "HSGPL extension" ) |
| 127 | | PORT_CONFSETTING( 0x02, DEF_STR( On ) ) |
| 126 | // True if SGCPU DSR is enabled |
| 127 | bool m_internal_dsr; |
| 128 | 128 | |
| 129 | | // We do not want to show this setting; makes only sense for Geneve |
| 130 | | PORT_START( "MODE" ) |
| 131 | | PORT_CONFNAME( 0x01, 0x00, "Ext. cards modification" ) PORT_CONDITION( "HFDCDIP", 0xff, PORTCOND_EQUALS, GM_NEVER ) |
| 132 | | PORT_CONFSETTING( 0x00, "Standard" ) |
| 133 | | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 129 | // True if SGCPU rom6 is enabled |
| 130 | bool m_internal_rom6; |
| 134 | 131 | |
| 135 | | PORT_START( "BWGDIP1" ) |
| 136 | | PORT_DIPNAME( 0x01, 0x00, "BwG step rate" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 137 | | PORT_DIPSETTING( 0x00, "6 ms") |
| 138 | | PORT_DIPSETTING( 0x01, "20 ms") |
| 132 | // Offset to the ROM6 bank. |
| 133 | int m_rom6_bank; |
| 139 | 134 | |
| 140 | | PORT_START( "BWGDIP2" ) |
| 141 | | PORT_DIPNAME( 0x01, 0x00, "BwG date/time display" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 142 | | PORT_DIPSETTING( 0x00, "Hide") |
| 143 | | PORT_DIPSETTING( 0x01, "Show") |
| 135 | // TRUE when mapper is active |
| 136 | bool m_map_mode; |
| 144 | 137 | |
| 145 | | PORT_START( "BWGDIP34" ) |
| 146 | | PORT_DIPNAME( 0x03, 0x00, "BwG drives" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 147 | | PORT_DIPSETTING( 0x00, "DSK1 only") |
| 148 | | PORT_DIPSETTING( 0x01, "DSK1-DSK2") |
| 149 | | PORT_DIPSETTING( 0x02, "DSK1-DSK3") |
| 150 | | PORT_DIPSETTING( 0x03, "DSK1-DSK4") |
| 138 | // TRUE when mapper registers are accessible |
| 139 | bool m_access_mapper; |
| 151 | 140 | |
| 152 | | PORT_START( "HFDCDIP" ) |
| 153 | | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 154 | | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 155 | | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 156 | | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 157 | | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 141 | UINT8 m_lowbyte; |
| 142 | UINT8 m_highbyte; |
| 143 | UINT8 m_latch; |
| 158 | 144 | |
| 159 | | PORT_START( "V9938-MEM" ) |
| 160 | | PORT_CONFNAME( 0x01, 0x00, "V9938 RAM size" ) |
| 161 | | PORT_CONFSETTING( 0x00, "128 KiB" ) |
| 162 | | PORT_CONFSETTING( 0x01, "192 KiB" ) |
| 145 | /* Mapper registers */ |
| 146 | UINT8 m_mapper[16]; |
| 147 | }; |
| 163 | 148 | |
| 164 | | PORT_START( "DRVSPD" ) |
| 165 | | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 166 | | PORT_CONFSETTING( 0x00, "No delay") |
| 167 | | PORT_CONFSETTING( 0x01, "Realistic") |
| 149 | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 16, ti99_4p) |
| 150 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( memread, memwrite ) |
| 151 | ADDRESS_MAP_END |
| 168 | 152 | |
| 169 | | PORT_START( "EVPC-SW1" ) |
| 170 | | PORT_DIPNAME( 0x01, 0x00, "EVPC video mode" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 171 | | PORT_DIPSETTING( 0x00, "PAL" ) |
| 172 | | PORT_DIPSETTING( 0x01, "NTSC" ) |
| 153 | static ADDRESS_MAP_START(cru_map, AS_IO, 8, ti99_4p) |
| 154 | AM_RANGE(0x0000, 0x003f) AM_DEVREAD(TMS9901_TAG, tms9901_device, read) |
| 155 | AM_RANGE(0x0000, 0x01ff) AM_READ( cruread ) |
| 173 | 156 | |
| 174 | | PORT_START( "EVPC-SW3" ) |
| 175 | | PORT_DIPNAME( 0x01, 0x00, "EVPC charset" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 176 | | PORT_DIPSETTING( 0x00, DEF_STR( International )) |
| 177 | | PORT_DIPSETTING( 0x01, DEF_STR( German )) |
| 157 | AM_RANGE(0x0000, 0x01ff) AM_DEVWRITE(TMS9901_TAG, tms9901_device, write) |
| 158 | AM_RANGE(0x0000, 0x0fff) AM_WRITE( cruwrite ) |
| 159 | ADDRESS_MAP_END |
| 178 | 160 | |
| 179 | | PORT_START( "EVPC-SW4" ) |
| 180 | | PORT_DIPNAME( 0x01, 0x00, "EVPC VDP RAM" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 181 | | PORT_DIPSETTING( 0x00, "shifted" ) |
| 182 | | PORT_DIPSETTING( 0x01, "not shifted" ) |
| 161 | /* |
| 162 | Input ports, used by machine code for TI keyboard and joystick emulation. |
| 183 | 163 | |
| 184 | | PORT_START( "EVPC-SW8" ) |
| 185 | | PORT_DIPNAME( 0x01, 0x00, "EVPC Configuration" ) |
| 186 | | PORT_DIPSETTING( 0x00, "DIP" ) |
| 187 | | PORT_DIPSETTING( 0x01, "NOVRAM" ) |
| 164 | Since the keyboard microcontroller is not emulated, we use the TI99/4a 48-key keyboard, |
| 165 | plus two optional joysticks. |
| 166 | */ |
| 188 | 167 | |
| 168 | static INPUT_PORTS_START(ti99_4p) |
| 189 | 169 | /* 3 ports for mouse */ |
| 190 | 170 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 191 | 171 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| r14513 | r14514 | |
| 277 | 257 | |
| 278 | 258 | INPUT_PORTS_END |
| 279 | 259 | |
| 260 | /* |
| 261 | Memory access |
| 262 | */ |
| 263 | READ16_MEMBER( ti99_4p::memread ) |
| 264 | { |
| 265 | int addroff = offset << 1; |
| 266 | if (m_rom0 == NULL) return 0; // premature access |
| 267 | |
| 268 | UINT16 zone = addroff & 0xe000; |
| 269 | UINT16 value = 0; |
| 270 | |
| 271 | if (zone==0x0000) |
| 272 | { |
| 273 | // ROM0 |
| 274 | value = m_rom0[(addroff & 0x1fff)>>1]; |
| 275 | return value; |
| 276 | } |
| 277 | if (zone==0x2000 || zone==0xa000 || zone==0xc000 || zone==0xe000) |
| 278 | { |
| 279 | value = samsmem_read(space, offset, mem_mask); |
| 280 | return value; |
| 281 | } |
| 282 | |
| 283 | if (zone==0x4000) |
| 284 | { |
| 285 | if (m_internal_dsr) |
| 286 | { |
| 287 | value = m_dsr[(addroff & 0x1fff)>>1]; |
| 288 | return value; |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | if (m_access_mapper && ((addroff & 0xffe0)==0x4000)) |
| 293 | { |
| 294 | value = m_mapper[offset & 0x000f]<<8; |
| 295 | return value; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | if (zone==0x6000 && m_internal_rom6) |
| 301 | { |
| 302 | if (m_rom6_bank==0) |
| 303 | value = m_rom6a[(addroff & 0x1fff)>>1]; |
| 304 | else |
| 305 | value = m_rom6b[(addroff & 0x1fff)>>1]; |
| 306 | |
| 307 | return value; |
| 308 | } |
| 309 | |
| 310 | // Scratch pad RAM and sound |
| 311 | // speech is in peribox |
| 312 | // groms are in hsgpl in peribox |
| 313 | if (zone==0x8000) |
| 314 | { |
| 315 | if ((addroff & 0xfff0)==0x8400) // cannot read from sound |
| 316 | { |
| 317 | value = 0; |
| 318 | return value; |
| 319 | } |
| 320 | if ((addroff & 0xfc00)==0x8000) |
| 321 | { |
| 322 | value = m_scratchpad[(addroff & 0x03ff)>>1]; |
| 323 | return value; |
| 324 | } |
| 325 | // Video: 8800, 8802 |
| 326 | if ((addroff & 0xfffd)==0x8800) |
| 327 | { |
| 328 | value = m_video->read16(space, offset, mem_mask); |
| 329 | return value; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | // If we are here, check the peribox via the datamux |
| 334 | // catch-all for unmapped zones |
| 335 | value = datamux_read(space, offset, mem_mask); |
| 336 | return value; |
| 337 | } |
| 338 | |
| 339 | WRITE16_MEMBER( ti99_4p::memwrite ) |
| 340 | { |
| 341 | // device_adjust_icount(m_cpu, -4); |
| 342 | |
| 343 | int addroff = offset << 1; |
| 344 | UINT16 zone = addroff & 0xe000; |
| 345 | |
| 346 | if (zone==0x0000) |
| 347 | { |
| 348 | // ROM0 |
| 349 | if (VERBOSE>4) LOG("sgcpu: ignoring ROM write access at %04x\n", addroff); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | if (zone==0x2000 || zone==0xa000 || zone==0xc000 || zone==0xe000) |
| 354 | { |
| 355 | samsmem_write(space, offset, data, mem_mask); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | if (zone==0x4000) |
| 360 | { |
| 361 | if (m_internal_dsr) |
| 362 | { |
| 363 | if (VERBOSE>4) LOG("sgcpu: ignoring DSR write access at %04x\n", addroff); |
| 364 | return; |
| 365 | } |
| 366 | else |
| 367 | { |
| 368 | if (m_access_mapper && ((addroff & 0xffe0)==0x4000)) |
| 369 | { |
| 370 | COMBINE_DATA(&m_mapper[offset & 0x000f]); |
| 371 | return; |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | if (zone==0x6000 && m_internal_rom6) |
| 377 | { |
| 378 | m_rom6_bank = offset & 0x0001; |
| 379 | return; |
| 380 | } |
| 381 | |
| 382 | // Scratch pad RAM and sound |
| 383 | // speech is in peribox |
| 384 | // groms are in hsgpl in peribox |
| 385 | if (zone==0x8000) |
| 386 | { |
| 387 | if ((addroff & 0xfff0)==0x8400) //sound write |
| 388 | { |
| 389 | m_sound->write(space, 0, (data >> 8) & 0xff); |
| 390 | return; |
| 391 | } |
| 392 | if ((addroff & 0xfc00)==0x8000) |
| 393 | { |
| 394 | COMBINE_DATA(&m_scratchpad[(addroff & 0x03ff)>>1]); |
| 395 | return; |
| 396 | } |
| 397 | // Video: 8C00, 8C02 |
| 398 | if ((addroff & 0xfffd)==0x8c00) |
| 399 | { |
| 400 | m_video->write16(space, offset, data, mem_mask); |
| 401 | return; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | // If we are here, check the peribox via the datamux |
| 406 | // catch-all for unmapped zones |
| 407 | datamux_write(space, offset, data, mem_mask); |
| 408 | } |
| 409 | |
| 410 | /*************************************************************************** |
| 411 | Internal datamux; similar to TI-99/4A. However, here we have just |
| 412 | one device, the peripheral box, so it is much simpler. |
| 413 | ***************************************************************************/ |
| 414 | |
| 415 | READ16_MEMBER( ti99_4p::datamux_read ) |
| 416 | { |
| 417 | UINT8 hbyte = 0; |
| 418 | UINT16 addroff = (offset << 1); |
| 419 | |
| 420 | m_peribox->readz(space, addroff+1, &m_latch, mem_mask); |
| 421 | m_lowbyte = m_latch; |
| 422 | |
| 423 | // Takes three cycles |
| 424 | device_adjust_icount(m_cpu, -3); |
| 425 | |
| 426 | m_peribox->readz(space, addroff, &hbyte, mem_mask); |
| 427 | m_highbyte = hbyte; |
| 428 | |
| 429 | // Takes three cycles |
| 430 | device_adjust_icount(m_cpu, -3); |
| 431 | |
| 432 | // use the latch and the currently read byte and put it on the 16bit bus |
| 433 | // printf("read address = %04x, value = %04x, memmask = %4x\n", addroff, (hbyte<<8) | sgcpu->latch, mem_mask); |
| 434 | return (hbyte<<8) | m_latch ; |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | Write access. |
| 439 | TODO: use the 16-bit expansion in the box for suitable cards |
| 440 | */ |
| 441 | WRITE16_MEMBER( ti99_4p::datamux_write ) |
| 442 | { |
| 443 | UINT16 addroff = (offset << 1); |
| 444 | // printf("write address = %04x, value = %04x, memmask = %4x\n", addroff, data, mem_mask); |
| 445 | |
| 446 | // read more about the datamux in datamux.c |
| 447 | |
| 448 | // byte-only transfer, high byte |
| 449 | // we use the previously read low byte to complete |
| 450 | if (mem_mask == 0xff00) |
| 451 | data = data | m_lowbyte; |
| 452 | |
| 453 | // byte-only transfer, low byte |
| 454 | // we use the previously read high byte to complete |
| 455 | if (mem_mask == 0x00ff) |
| 456 | data = data | (m_highbyte << 8); |
| 457 | |
| 458 | // Write to the PEB |
| 459 | m_peribox->write(space, addroff+1, data & 0xff); |
| 460 | |
| 461 | // Takes three cycles |
| 462 | device_adjust_icount(m_cpu,-3); |
| 463 | |
| 464 | // Write to the PEB |
| 465 | m_peribox->write(space, addroff, (data>>8) & 0xff); |
| 466 | |
| 467 | // Takes three cycles |
| 468 | device_adjust_icount(m_cpu,-3); |
| 469 | } |
| 470 | |
| 471 | /*************************************************************************** |
| 472 | CRU interface |
| 473 | ***************************************************************************/ |
| 474 | |
| 475 | #define MAP_CRU_BASE 0x0f00 |
| 476 | #define SAMS_CRU_BASE 0x1e00 |
| 477 | |
| 478 | /* |
| 479 | CRU write |
| 480 | */ |
| 481 | WRITE8_MEMBER( ti99_4p::cruwrite ) |
| 482 | { |
| 483 | int addroff = offset<<1; |
| 484 | |
| 485 | if ((addroff & 0xff00)==MAP_CRU_BASE) |
| 486 | { |
| 487 | if ((addroff & 0x000e)==0) m_internal_dsr = data; |
| 488 | if ((addroff & 0x000e)==2) m_internal_rom6 = data; |
| 489 | if ((addroff & 0x000e)==4) m_peribox->senila((data!=0)? ASSERT_LINE : CLEAR_LINE); |
| 490 | if ((addroff & 0x000e)==6) m_peribox->senilb((data!=0)? ASSERT_LINE : CLEAR_LINE); |
| 491 | // TODO: more CRU bits? 8=Fast timing / a=KBENA |
| 492 | return; |
| 493 | } |
| 494 | if ((addroff & 0xff00)==SAMS_CRU_BASE) |
| 495 | { |
| 496 | if ((addroff & 0x000e)==0) m_access_mapper = data; |
| 497 | if ((addroff & 0x000e)==2) m_map_mode = data; |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | // No match - pass to peribox |
| 502 | m_peribox->cruwrite(addroff, data); |
| 503 | } |
| 504 | |
| 505 | READ8_MEMBER( ti99_4p::cruread ) |
| 506 | { |
| 507 | UINT8 value = 0; |
| 508 | m_peribox->crureadz(offset<<4, &value); |
| 509 | return value; |
| 510 | } |
| 511 | |
| 512 | /*************************************************************************** |
| 513 | AMS Memory implementation |
| 514 | ***************************************************************************/ |
| 515 | |
| 516 | /* |
| 517 | Memory read. The SAMS card has two address areas: The memory is at locations |
| 518 | 0x2000-0x3fff and 0xa000-0xffff, and the mapper area is at 0x4000-0x401e |
| 519 | (only even addresses). |
| 520 | */ |
| 521 | READ16_MEMBER( ti99_4p::samsmem_read ) |
| 522 | { |
| 523 | UINT32 address = 0; |
| 524 | int addroff = offset << 1; |
| 525 | |
| 526 | // select memory expansion |
| 527 | if (m_map_mode) |
| 528 | address = (m_mapper[(addroff>>12) & 0x000f] << 12) + (addroff & 0x0fff); |
| 529 | else // transparent mode |
| 530 | address = addroff; |
| 531 | |
| 532 | return m_ram[address>>1]; |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | Memory write |
| 537 | */ |
| 538 | WRITE16_MEMBER( ti99_4p::samsmem_write ) |
| 539 | { |
| 540 | UINT32 address = 0; |
| 541 | int addroff = offset << 1; |
| 542 | |
| 543 | // select memory expansion |
| 544 | if (m_map_mode) |
| 545 | address = (m_mapper[(addroff>>12) & 0x000f] << 12) + (addroff & 0x0fff); |
| 546 | else // transparent mode |
| 547 | address = addroff; |
| 548 | |
| 549 | COMBINE_DATA(&m_ram[address>>1]); |
| 550 | } |
| 551 | |
| 552 | /*************************************************************************** |
| 553 | Keyboard/tape control |
| 554 | ****************************************************************************/ |
| 555 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; |
| 556 | |
| 557 | READ8_MEMBER( ti99_4p::read_by_9901 ) |
| 558 | { |
| 559 | int answer=0; |
| 560 | |
| 561 | switch (offset & 0x03) |
| 562 | { |
| 563 | case TMS9901_CB_INT7: |
| 564 | // Read pins INT3*-INT7* of TI99's 9901. |
| 565 | // |
| 566 | // signification: |
| 567 | // (bit 1: INT1 status) |
| 568 | // (bit 2: INT2 status) |
| 569 | // bit 3-7: keyboard status bits 0 to 4 |
| 570 | answer = ((input_port_read(machine(), keynames[m_keyboard_column >> 1]) >> ((m_keyboard_column & 1) * 8)) << 3) & 0xF8; |
| 571 | if (m_alphalock_line==false) |
| 572 | answer &= ~(input_port_read(*this, "ALPHA") << 3); |
| 573 | break; |
| 574 | |
| 575 | case TMS9901_INT8_INT15: |
| 576 | // Read pins INT8*-INT15* of TI99's 9901. |
| 577 | // bit 0-2: keyboard status bits 5 to 7 |
| 578 | // bit 3: tape input mirror |
| 579 | // bit 5-7: weird, not emulated |
| 580 | if (m_keyboard_column == 7) answer = 0x07; |
| 581 | else answer = ((input_port_read(machine(), keynames[m_keyboard_column >> 1]) >> ((m_keyboard_column & 1) * 8)) >> 5) & 0x07; |
| 582 | break; |
| 583 | |
| 584 | case TMS9901_P0_P7: |
| 585 | break; |
| 586 | |
| 587 | case TMS9901_P8_P15: |
| 588 | // Read pins P8-P15 of TI99's 9901. |
| 589 | // bit 26: high |
| 590 | // bit 27: tape input |
| 591 | answer = 4; |
| 592 | if (m_cassette->input() > 0) answer |= 8; |
| 593 | break; |
| 594 | } |
| 595 | return answer; |
| 596 | } |
| 597 | |
| 598 | /* |
| 599 | WRITE key column select (P2-P4) |
| 600 | */ |
| 601 | void ti99_4p::set_key(int number, int data) |
| 602 | { |
| 603 | if (data!=0) m_keyboard_column |= 1 << number; |
| 604 | else m_keyboard_column &= ~(1 << number); |
| 605 | } |
| 606 | |
| 607 | WRITE_LINE_MEMBER( ti99_4p::keyC0 ) |
| 608 | { |
| 609 | set_key(0, state); |
| 610 | } |
| 611 | |
| 612 | WRITE_LINE_MEMBER( ti99_4p::keyC1 ) |
| 613 | { |
| 614 | set_key(1, state); |
| 615 | } |
| 616 | |
| 617 | WRITE_LINE_MEMBER( ti99_4p::keyC2 ) |
| 618 | { |
| 619 | set_key(2, state); |
| 620 | } |
| 621 | |
| 622 | /* |
| 623 | WRITE alpha lock line (P5) |
| 624 | */ |
| 625 | WRITE_LINE_MEMBER( ti99_4p::alphaW ) |
| 626 | { |
| 627 | m_alphalock_line = state; |
| 628 | } |
| 629 | |
| 630 | /* |
| 631 | command CS1 (only) tape unit motor (P6) |
| 632 | */ |
| 633 | WRITE_LINE_MEMBER( ti99_4p::cs_motor ) |
| 634 | { |
| 635 | m_cassette->change_state((state!=0)? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 636 | } |
| 637 | |
| 638 | /* |
| 639 | audio gate (P8) |
| 640 | |
| 641 | Set to 1 before using tape: this enables the mixing of tape input sound |
| 642 | with computer sound. |
| 643 | |
| 644 | We do not really need to emulate this as the tape recorder generates sound |
| 645 | on its own. |
| 646 | */ |
| 647 | WRITE_LINE_MEMBER( ti99_4p::audio_gate ) |
| 648 | { |
| 649 | } |
| 650 | |
| 651 | /* |
| 652 | tape output (P9) |
| 653 | */ |
| 654 | WRITE_LINE_MEMBER( ti99_4p::cassette_output ) |
| 655 | { |
| 656 | m_cassette->output((state!=0)? +1 : -1); |
| 657 | } |
| 658 | |
| 659 | WRITE8_MEMBER( ti99_4p::tms9901_interrupt ) |
| 660 | { |
| 661 | // offset contains the interrupt level (0-15) |
| 662 | if (data==ASSERT_LINE) |
| 663 | { |
| 664 | // The TMS9901 should normally be connected with the CPU by 5 wires: |
| 665 | // INTREQ* and IC0-IC3. The last four lines deliver the interrupt level. |
| 666 | // On the TI-99 systems these IC lines are not used; the input lines |
| 667 | // at the CPU are hardwired to level 1. |
| 668 | device_execute(m_cpu)->set_input_line_and_vector(0, ASSERT_LINE, 1); |
| 669 | } |
| 670 | else |
| 671 | { |
| 672 | device_execute(m_cpu)->set_input_line(0, CLEAR_LINE); |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | /* TMS9901 setup. The callback functions pass a reference to the TMS9901 as device. */ |
| 677 | const tms9901_interface tms9901_wiring_ti99_4p = |
| 678 | { |
| 679 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 680 | |
| 681 | // read handler |
| 682 | DEVCB_DRIVER_MEMBER(ti99_4p, read_by_9901), |
| 683 | |
| 684 | { // write handlers |
| 685 | DEVCB_NULL, |
| 686 | DEVCB_NULL, |
| 687 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, keyC0), |
| 688 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, keyC1), |
| 689 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, keyC2), |
| 690 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, alphaW), |
| 691 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, cs_motor), |
| 692 | DEVCB_NULL, |
| 693 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, audio_gate), |
| 694 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, cassette_output), |
| 695 | DEVCB_NULL, |
| 696 | DEVCB_NULL, |
| 697 | DEVCB_NULL, |
| 698 | DEVCB_NULL, |
| 699 | DEVCB_NULL, |
| 700 | DEVCB_NULL |
| 701 | }, |
| 702 | |
| 703 | /* interrupt handler */ |
| 704 | DEVCB_DRIVER_MEMBER(ti99_4p, tms9901_interrupt) |
| 705 | }; |
| 706 | |
| 707 | /*************************************************************************** |
| 708 | Control lines |
| 709 | ****************************************************************************/ |
| 710 | |
| 711 | WRITE_LINE_MEMBER( ti99_4p::console_ready ) |
| 712 | { |
| 713 | if (VERBOSE>6) LOG("READY line set ... not yet connected, level=%02x\n", state); |
| 714 | } |
| 715 | |
| 716 | WRITE_LINE_MEMBER( ti99_4p::extint ) |
| 717 | { |
| 718 | if (VERBOSE>6) LOG("EXTINT level = %02x\n", state); |
| 719 | if (m_tms9901 != NULL) |
| 720 | m_tms9901->set_single_int(1, state); |
| 721 | } |
| 722 | |
| 723 | WRITE_LINE_MEMBER( ti99_4p::notconnected ) |
| 724 | { |
| 725 | if (VERBOSE>6) LOG("Setting a not connected line ... ignored\n"); |
| 726 | } |
| 727 | |
| 728 | /*****************************************************************************/ |
| 729 | |
| 730 | static PERIBOX_CONFIG( peribox_conf ) |
| 731 | { |
| 732 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, extint), // INTA |
| 733 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, notconnected), // INTB |
| 734 | DEVCB_DRIVER_LINE_MEMBER(ti99_4p, console_ready), // READY |
| 735 | 0x70000 // Address bus prefix (AMA/AMB/AMC) |
| 736 | }; |
| 737 | |
| 280 | 738 | DRIVER_INIT( ti99_4p ) |
| 281 | 739 | { |
| 282 | 740 | } |
| 283 | 741 | |
| 284 | 742 | MACHINE_START( ti99_4p ) |
| 285 | 743 | { |
| 744 | ti99_4p *driver = machine.driver_data<ti99_4p>(); |
| 745 | |
| 746 | driver->m_cpu = machine.device("maincpu"); |
| 747 | driver->m_peribox = static_cast<peribox_device*>(machine.device(PERIBOX_TAG)); |
| 748 | driver->m_sound = static_cast<ti_sound_system_device*>(machine.device(TISOUND_TAG)); |
| 749 | driver->m_video = static_cast<ti_exp_video_device*>(machine.device(VIDEO_SYSTEM_TAG)); |
| 750 | driver->m_cassette = static_cast<cassette_image_device*>(machine.device(CASSETTE_TAG)); |
| 751 | driver->m_tms9901 = static_cast<tms9901_device*>(machine.device(TMS9901_TAG)); |
| 752 | |
| 753 | driver->m_ram = (UINT16*)machine.region(SAMSMEM_TAG)->base(); |
| 754 | driver->m_scratchpad = (UINT16*)machine.region(PADMEM_TAG)->base(); |
| 755 | |
| 756 | driver->m_peribox->senila(CLEAR_LINE); |
| 757 | driver->m_peribox->senilb(CLEAR_LINE); |
| 758 | |
| 759 | UINT16 *rom = (UINT16*)machine.region("maincpu")->base(); |
| 760 | driver->m_rom0 = rom + 0x2000; |
| 761 | driver->m_dsr = rom + 0x6000; |
| 762 | driver->m_rom6a = rom + 0x3000; |
| 763 | driver->m_rom6b = rom + 0x7000; |
| 286 | 764 | } |
| 287 | 765 | |
| 288 | 766 | /* |
| 767 | set the state of int2 (called by the v9938) |
| 768 | */ |
| 769 | void ti99_4p::set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state) |
| 770 | { |
| 771 | m_tms9901->set_single_int(2, state); |
| 772 | } |
| 773 | |
| 774 | /* |
| 289 | 775 | Reset the machine. |
| 290 | 776 | */ |
| 291 | 777 | MACHINE_RESET( ti99_4p ) |
| 292 | 778 | { |
| 293 | | tms9901_set_single_int(machine.device("tms9901"), 12, 0); |
| 779 | ti99_4p *driver = machine.driver_data<ti99_4p>(); |
| 780 | driver->m_tms9901->set_single_int(12, 0); |
| 294 | 781 | } |
| 295 | 782 | |
| 296 | 783 | TIMER_DEVICE_CALLBACK( ti99_4p_hblank_interrupt ) |
| 297 | 784 | { |
| 298 | | timer.machine().device<v9938_device>("video_v9938")->interrupt(); |
| 785 | timer.machine().device<v9938_device>(V9938_TAG)->interrupt(); |
| 299 | 786 | } |
| 300 | 787 | |
| 301 | 788 | /* |
| 302 | 789 | Machine description. |
| 303 | 790 | */ |
| 304 | | static MACHINE_CONFIG_START( ti99_4p_60hz, ti99_4p_state ) |
| 791 | static MACHINE_CONFIG_START( ti99_4p_60hz, ti99_4p ) |
| 305 | 792 | /* basic machine hardware */ |
| 306 | 793 | /* TMS9900 CPU @ 3.0 MHz */ |
| 307 | 794 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 308 | 795 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 309 | 796 | MCFG_CPU_IO_MAP(cru_map) |
| 310 | | MCFG_TIMER_ADD_SCANLINE("scantimer", ti99_4p_hblank_interrupt, "screen", 0, 1) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 797 | MCFG_MACHINE_START( ti99_4p ) |
| 311 | 798 | |
| 312 | 799 | /* video hardware */ |
| 313 | 800 | /* FIXME: (MZ) Lowered the screen rate to 30 Hz. This is a quick hack to |
| 314 | 801 | restore normal video speed for V9938-based systems until the V9938 implementation |
| 315 | 802 | is properly fixed. */ |
| 316 | | MCFG_TI_V9938_ADD("video", 30, "screen", 2500, 512+32, (212+28)*2, tms9901_sg_set_int2) |
| 803 | MCFG_TI_V9938_ADD(VIDEO_SYSTEM_TAG, 30, SCREEN_TAG, 2500, 512+32, (212+28)*2, DEVICE_SELF, ti99_4p, set_tms9901_INT2_from_v9938) |
| 804 | MCFG_TIMER_ADD_SCANLINE("scantimer", ti99_4p_hblank_interrupt, SCREEN_TAG, 0, 1) |
| 317 | 805 | |
| 318 | | MCFG_MACHINE_START( ti99_4p ) |
| 319 | | MCFG_MACHINE_RESET( ti99_4p ) |
| 806 | /* tms9901 */ |
| 807 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4p, 3000000) |
| 320 | 808 | |
| 809 | /* Peripheral expansion box (SGCPU composition) */ |
| 810 | MCFG_PERIBOX_SG_ADD( PERIBOX_TAG, peribox_conf ) |
| 811 | |
| 321 | 812 | /* sound hardware */ |
| 322 | 813 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 323 | | MCFG_SOUND_ADD("dac", DAC, 0) |
| 324 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) |
| 325 | | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 326 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 327 | | MCFG_SOUND_ADD("soundgen", SN76496, 3579545) /* 3.579545 MHz */ |
| 814 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 328 | 815 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 816 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 329 | 817 | |
| 330 | | /* tms9901 */ |
| 331 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4p) |
| 818 | /* Cassette drives */ |
| 819 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 332 | 820 | |
| 333 | | /* devices */ |
| 334 | | MCFG_PBOXSG_ADD( "peribox", card_extint, card_notconnected, card_ready ) |
| 335 | | MCFG_SGCPUB_ADD( "sgcpu_board" ) |
| 336 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 821 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 822 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 337 | 823 | MACHINE_CONFIG_END |
| 338 | 824 | |
| 339 | 825 | |
| r14513 | r14514 | |
| 342 | 828 | ROM_REGION16_BE(0x10000, "maincpu", 0) |
| 343 | 829 | ROM_LOAD16_BYTE("sgcpu_hb.bin", 0x0000, 0x8000, CRC(aa100730) SHA1(35e585b2dcd3f2a0005bebb15ede6c5b8c787366) ) /* system ROMs */ |
| 344 | 830 | ROM_LOAD16_BYTE("sgcpu_lb.bin", 0x0001, 0x8000, CRC(2a5dc818) SHA1(dec141fe2eea0b930859cbe1ebd715ac29fa8ecb) ) /* system ROMs */ |
| 831 | ROM_REGION16_BE(0x080000, SAMSMEM_TAG, 0) |
| 832 | ROM_FILL(0x000000, 0x080000, 0x0000) |
| 833 | ROM_REGION16_BE(0x0400, PADMEM_TAG, 0) |
| 834 | ROM_FILL(0x000000, 0x0400, 0x0000) |
| 345 | 835 | ROM_END |
| 346 | 836 | |
| 347 | 837 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
src/mess/drivers/ti99_4x.c
| r14513 | r14514 | |
| 1 | | /* |
| 1 | /**************************************************************************** |
| 2 | |
| 2 | 3 | MESS Driver for TI-99/4 and TI-99/4A Home Computers. |
| 3 | 4 | Raphael Nabet, 1999-2003. |
| 4 | 5 | |
| 5 | | see machine/ti99_4x.c for some details and references |
| 6 | | */ |
| 7 | | |
| 8 | | /* |
| 9 | 6 | TI99/4 info: |
| 10 | 7 | |
| 11 | 8 | Similar to TI99/4a, except for the following: |
| r14513 | r14514 | |
| 16 | 13 | Historical notes: TI made several last minute design changes. |
| 17 | 14 | * TI99/4 prototypes had an extra port for an I/R joystick and keypad interface. |
| 18 | 15 | * early TI99/4 prototypes were designed for a tms9985, not a tms9900. |
| 19 | | */ |
| 20 | 16 | |
| 17 | Emulation architecture: |
| 18 | (also see datamux.c, peribox.c) |
| 19 | |
| 20 | +---- video (upper 8 bits of databus) |
| 21 | | |
| 22 | CPU | |
| 23 | TMS9900 ==##== datamux --------+------ peribox ----------- [8] slots with peripheral devices |
| 24 | | || (16->8) | |
| 25 | | || +------ Console GROMs (0, 1, 2) |
| 26 | | ##=== Console ROM | |
| 27 | TMS9901 || +------ gromport (cartridge port) |
| 28 | (I/O) ##=== 256 byte RAM | |
| 29 | || +------ sound |
| 30 | ##=== 32KiB RAM |
| 31 | unofficial mod |
| 32 | (16 bit) |
| 33 | |
| 34 | Michael Zapf |
| 35 | |
| 36 | February 2012: Rewritten as class |
| 37 | |
| 38 | *****************************************************************************/ |
| 39 | |
| 40 | #define ADDRESS_MAP_MODERN |
| 41 | |
| 21 | 42 | #include "emu.h" |
| 22 | 43 | #include "cpu/tms9900/tms9900.h" |
| 23 | 44 | #include "sound/sn76496.h" |
| r14513 | r14514 | |
| 27 | 48 | #include "machine/tms9901.h" |
| 28 | 49 | #include "imagedev/cassette.h" |
| 29 | 50 | |
| 30 | | #include "machine/ti99/tiboard.h" |
| 31 | | |
| 32 | 51 | #include "machine/ti99/videowrp.h" |
| 33 | | |
| 34 | | #include "machine/ti99/peribox.h" |
| 35 | | #include "machine/ti99/crubus.h" |
| 36 | 52 | #include "machine/ti99/datamux.h" |
| 37 | 53 | #include "machine/ti99/grom.h" |
| 38 | 54 | #include "machine/ti99/gromport.h" |
| 39 | 55 | #include "machine/ti99/mecmouse.h" |
| 40 | 56 | #include "machine/ti99/handset.h" |
| 57 | #include "machine/ti99/peribox.h" |
| 41 | 58 | |
| 59 | #define LOG logerror |
| 60 | #define VERBOSE 1 |
| 42 | 61 | |
| 43 | | class ti99_4x_state : public driver_device |
| 62 | /* |
| 63 | The console. |
| 64 | */ |
| 65 | class ti99_4x : public driver_device |
| 44 | 66 | { |
| 45 | 67 | public: |
| 46 | | ti99_4x_state(const machine_config &mconfig, device_type type, const char *tag) |
| 68 | ti99_4x(const machine_config &mconfig, device_type type, const char *tag) |
| 47 | 69 | : driver_device(mconfig, type, tag) { } |
| 48 | 70 | |
| 71 | // CRU (Communication Register Unit) handling |
| 72 | DECLARE_READ8_MEMBER(cruread); |
| 73 | DECLARE_WRITE8_MEMBER(cruwrite); |
| 74 | |
| 75 | // Forwarding interrupts to the CPU or CRU |
| 76 | DECLARE_WRITE_LINE_MEMBER( console_ready ); |
| 77 | DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT2 ); |
| 78 | DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT12 ); |
| 79 | void set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state); |
| 80 | DECLARE_WRITE_LINE_MEMBER( extint ); |
| 81 | DECLARE_WRITE_LINE_MEMBER( notconnected ); |
| 82 | |
| 83 | // Some values to keep |
| 84 | int m_mode; |
| 85 | device_t *m_cpu; |
| 86 | tms9901_device *m_tms9901; |
| 87 | gromport_device *m_gromport; |
| 88 | peribox_device *m_peribox; |
| 89 | mecmouse_device *m_mecmouse; |
| 90 | ti99_handset_device *m_handset; |
| 91 | |
| 92 | // Connections with the system interface TMS9901 |
| 93 | DECLARE_READ8_MEMBER(read_by_9901); |
| 94 | DECLARE_WRITE_LINE_MEMBER(keyC0); |
| 95 | DECLARE_WRITE_LINE_MEMBER(keyC1); |
| 96 | DECLARE_WRITE_LINE_MEMBER(keyC2); |
| 97 | DECLARE_WRITE_LINE_MEMBER(cs1_motor); |
| 98 | DECLARE_WRITE_LINE_MEMBER(audio_gate); |
| 99 | DECLARE_WRITE_LINE_MEMBER(cassette_output); |
| 100 | DECLARE_WRITE8_MEMBER(tms9901_interrupt); |
| 101 | DECLARE_WRITE_LINE_MEMBER(handset_ack); |
| 102 | DECLARE_WRITE_LINE_MEMBER(cs2_motor); |
| 103 | DECLARE_WRITE_LINE_MEMBER(alphaW); |
| 104 | |
| 105 | private: |
| 106 | void set_key(int number, int data); |
| 107 | int m_keyboard_column; |
| 108 | int m_alphalock_line; |
| 49 | 109 | }; |
| 50 | 110 | |
| 51 | | |
| 52 | 111 | /* |
| 53 | 112 | Memory map |
| 54 | 113 | */ |
| 55 | | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 16) |
| 114 | static ADDRESS_MAP_START(memmap, AS_PROGRAM, 16, ti99_4x) |
| 56 | 115 | ADDRESS_MAP_GLOBAL_MASK(0xffff) |
| 57 | 116 | AM_RANGE(0x0000, 0x1fff) AM_ROM /*system ROM*/ |
| 58 | 117 | AM_RANGE(0x8000, 0x80ff) AM_MIRROR(0x0300) AM_RAM /*RAM PAD, mirrored 4 times*/ |
| 59 | | AM_RANGE(0x8800, 0x8bff) AM_DEVREADWRITE("video", ti_tms991x_r16, ti_video_wnop) /*vdp read*/ |
| 60 | | AM_RANGE(0x8C00, 0x8fff) AM_DEVREADWRITE("video", ti_video_rnop, ti_tms991x_w16) /*vdp write*/ |
| 61 | | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE("datamux_16_8", ti99_dmux_r, ti99_dmux_w) |
| 118 | AM_RANGE(0x8800, 0x8bff) AM_DEVREADWRITE(VIDEO_SYSTEM_TAG, ti_std_video_device, read16, nowrite) /*vdp read*/ |
| 119 | AM_RANGE(0x8C00, 0x8fff) AM_DEVREADWRITE(VIDEO_SYSTEM_TAG, ti_std_video_device, noread, write16) /*vdp write*/ |
| 120 | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE(DATAMUX_TAG, ti99_datamux_device, read, write) |
| 62 | 121 | ADDRESS_MAP_END |
| 63 | 122 | |
| 64 | | static ADDRESS_MAP_START(memmap_4ev, AS_PROGRAM, 16) |
| 123 | static ADDRESS_MAP_START(memmap_4ev, AS_PROGRAM, 16, ti99_4x) |
| 65 | 124 | ADDRESS_MAP_GLOBAL_MASK(0xffff) |
| 66 | 125 | AM_RANGE(0x0000, 0x1fff) AM_ROM /*system ROM*/ |
| 67 | 126 | AM_RANGE(0x8000, 0x80ff) AM_MIRROR(0x0300) AM_RAM /*RAM PAD, mirrored 4 times*/ |
| 68 | | AM_RANGE(0x8800, 0x8bff) AM_DEVREADWRITE("video", ti_v9938_r16, ti_video_wnop) /*vdp read*/ |
| 69 | | AM_RANGE(0x8C00, 0x8fff) AM_DEVREADWRITE("video", ti_video_rnop, ti_v9938_w16) /*vdp write*/ |
| 70 | | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE("datamux_16_8", ti99_dmux_r, ti99_dmux_w) |
| 127 | AM_RANGE(0x8800, 0x8bff) AM_DEVREADWRITE(VIDEO_SYSTEM_TAG, ti_exp_video_device, read16, nowrite) /*vdp read*/ |
| 128 | AM_RANGE(0x8C00, 0x8fff) AM_DEVREADWRITE(VIDEO_SYSTEM_TAG, ti_exp_video_device, noread, write16) /*vdp write*/ |
| 129 | AM_RANGE(0x0000, 0xffff) AM_DEVREADWRITE(DATAMUX_TAG, ti99_datamux_device, read, write) |
| 71 | 130 | ADDRESS_MAP_END |
| 72 | 131 | |
| 73 | 132 | /* |
| r14513 | r14514 | |
| 78 | 137 | The TMS9901 is incompletely decoded |
| 79 | 138 | ---0 00xx xxcc ccc0 |
| 80 | 139 | causing 16 mirrors (0000, 0040, 0080, 00c0, ... , 03c0) |
| 81 | | Note that the CRU write address here is shifted 1 right (counting bit positions) |
| 82 | | while the CRU reads address 8 bits in one go |
| 140 | |
| 141 | Reading is done by transfering 8 successive bits, so addresses refer to |
| 142 | 8 bit groups; writing, however, is done using output lines. The CRU base |
| 143 | address in the ti99 systems is twice the bit address: |
| 144 | |
| 145 | (base=0, bit=0x10) == (base=0x20,bit=0) |
| 146 | |
| 147 | Read: 0000 - 003f translates to base addresses 0000 - 03fe |
| 148 | 0000 - 01ff is the complete CRU address space 0000 - 1ffe (for TMS9900) |
| 149 | |
| 150 | Write:0000 - 01ff corresponds to bit 0 of base address 0000 - 03fe |
| 83 | 151 | */ |
| 84 | | static ADDRESS_MAP_START(cru_map, AS_IO, 8) |
| 85 | | AM_RANGE(0x0000, 0x003f) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 86 | | AM_RANGE(0x0000, 0x01ff) AM_DEVREAD("crubus", ti99_crubus_r ) |
| 152 | static ADDRESS_MAP_START(cru_map, AS_IO, 8, ti99_4x) |
| 153 | AM_RANGE(0x0000, 0x003f) AM_DEVREAD(TMS9901_TAG, tms9901_device, read) |
| 154 | AM_RANGE(0x0000, 0x01ff) AM_READ(cruread) |
| 87 | 155 | |
| 88 | | AM_RANGE(0x0000, 0x01ff) AM_DEVWRITE("tms9901", tms9901_cru_w) |
| 89 | | AM_RANGE(0x0000, 0x0fff) AM_DEVWRITE("crubus", ti99_crubus_w ) |
| 156 | AM_RANGE(0x0000, 0x01ff) AM_DEVWRITE(TMS9901_TAG, tms9901_device, write) |
| 157 | AM_RANGE(0x0000, 0x0fff) AM_WRITE(cruwrite) |
| 90 | 158 | ADDRESS_MAP_END |
| 91 | 159 | |
| 92 | | /* |
| 93 | | Input ports, used by machine code for TI keyboard and joystick emulation. |
| 94 | | */ |
| 95 | 160 | |
| 96 | | static INPUT_CHANGED( gk_changed ) |
| 97 | | { |
| 98 | | device_t *cartsys = field.machine().device("gromport"); |
| 99 | | set_gk_switches(cartsys, (UINT8)((UINT64)param&0x07), newval); |
| 100 | | } |
| 101 | | |
| 161 | /***************************************************************************** |
| 162 | Input ports |
| 163 | ****************************************************************************/ |
| 102 | 164 | /* TI99/4a: 48-key keyboard, plus two optional joysticks (2 shift keys) */ |
| 103 | 165 | static INPUT_PORTS_START(ti99_4a) |
| 104 | 166 | |
| 105 | 167 | PORT_START( "RAM" ) /* config */ |
| 106 | | PORT_CONFNAME( 0x07, 0x01, "RAM extension" ) |
| 107 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 108 | | PORT_CONFSETTING( 0x01, "Console 32 KiB (16 bit)" ) |
| 109 | | PORT_CONFSETTING( 0x02, "TI 32 KiB card" ) |
| 110 | | PORT_CONFSETTING( 0x03, "Super AMS 1MiB" ) |
| 111 | | PORT_CONFSETTING( 0x07, "Myarc 512 KiB" ) |
| 112 | | |
| 113 | | PORT_START( "SPEECH" ) |
| 114 | | PORT_CONFNAME( 0x01, 0x01, "Speech synthesizer" ) |
| 115 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 116 | | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 117 | | |
| 118 | | PORT_START( "DISKCTRL" ) |
| 119 | | PORT_CONFNAME( 0x07, 0x03, "Disk controller" ) |
| 120 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 121 | | PORT_CONFSETTING( 0x01, "TI SD Floppy Controller" ) |
| 122 | | PORT_CONFSETTING( 0x02, "SNUG BwG Controller" ) |
| 123 | | PORT_CONFSETTING( 0x03, "Myarc HFDC" ) |
| 124 | | |
| 125 | | PORT_START( "HDCTRL" ) |
| 126 | | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 127 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 128 | | PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 129 | | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 130 | | PORT_CONFNAME( 0x04, 0x00, "USB-SM card" ) |
| 168 | PORT_CONFNAME( 0x01, 0x09, "Console 32 KiB RAM upgrade (16 bit)" ) |
| 131 | 169 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 132 | | PORT_CONFSETTING( 0x04, DEF_STR( On ) ) |
| 170 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 133 | 171 | |
| 134 | | PORT_START( "SERIAL" ) |
| 135 | | PORT_CONFNAME( 0x03, 0x00, "Serial/Parallel interface" ) |
| 136 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 137 | | PORT_CONFSETTING( 0x01, "TI RS-232 card" ) |
| 138 | | |
| 139 | | PORT_START( "SERIALMAP" ) |
| 140 | | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) PORT_CONDITION( "SERIAL", 0x03, PORTCOND_NOTEQUALS, 0x00 ) |
| 141 | | PORT_CONFSETTING( 0x00, "6-20" ) |
| 142 | | PORT_CONFSETTING( 0x01, "8-20" ) |
| 143 | | PORT_CONFSETTING( 0x02, "5-20" ) |
| 144 | | |
| 145 | | /* Flash setting is used to flash an empty HSGPL DSR ROM */ |
| 146 | | PORT_START( "EXTCARD" ) |
| 147 | | PORT_CONFNAME( 0x03, 0x00, "HSGPL extension" ) |
| 172 | PORT_START( "GROMENA" ) |
| 173 | PORT_CONFNAME( 0x01, 0x01, "Console GROMs" ) |
| 148 | 174 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 149 | | PORT_CONFSETTING( 0x01, "Flash" ) |
| 150 | | PORT_CONFSETTING( 0x02, DEF_STR( On ) ) |
| 151 | | PORT_CONFNAME( 0x04, 0x00, "P-Code card" ) |
| 152 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 153 | | PORT_CONFSETTING( 0x04, DEF_STR( On ) ) |
| 175 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 154 | 176 | |
| 155 | | PORT_START( "HCI" ) |
| 156 | | PORT_CONFNAME( 0x01, 0x00, "Mouse support" ) |
| 177 | PORT_START( "MECMOUSE" ) |
| 178 | PORT_CONFNAME( 0x01, 0x00, "Mechatronics Mouse" ) |
| 157 | 179 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 158 | | PORT_CONFSETTING( 0x01, "Mechatronics Mouse" ) |
| 180 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 181 | /* |
| 182 | // We do not want to show this setting; makes only sense for Geneve |
| 183 | PORT_START( "MODE" ) |
| 184 | PORT_CONFNAME( 0x01, 0x00, "Ext. cards modification" ) PORT_CONDITION( "HFDCDIP", 0x0f, PORTCOND_EQUALS, GM_NEVER ) |
| 185 | PORT_CONFSETTING( 0x00, "Standard" ) |
| 186 | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 187 | */ |
| 159 | 188 | |
| 160 | | // We do not want to show this setting; makes only sense for Geneve |
| 161 | | PORT_START( "MODE" ) |
| 162 | | PORT_CONFNAME( 0x01, 0x00, "Ext. cards modification" ) PORT_CONDITION( "HFDCDIP", 0x0f, PORTCOND_EQUALS, GM_NEVER ) |
| 163 | | PORT_CONFSETTING( 0x00, "Standard" ) |
| 164 | | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 165 | | |
| 166 | | PORT_START( "CARTSLOT" ) |
| 167 | | PORT_DIPNAME( 0x0f, CART_AUTO, "Cartridge slot" ) |
| 168 | | PORT_DIPSETTING( CART_AUTO, "Auto" ) |
| 169 | | PORT_DIPSETTING( CART_1, "Slot 1" ) |
| 170 | | PORT_DIPSETTING( CART_2, "Slot 2" ) |
| 171 | | PORT_DIPSETTING( CART_3, "Slot 3" ) |
| 172 | | PORT_DIPSETTING( CART_4, "Slot 4" ) |
| 173 | | PORT_DIPSETTING( CART_GK, "GRAM Kracker" ) |
| 174 | | |
| 175 | | /* GRAM Kracker Support */ |
| 176 | | PORT_START( "GKSWITCH1" ) |
| 177 | | PORT_DIPNAME( 0x01, GK_NORMAL, "GK switch 1" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)1) |
| 178 | | PORT_DIPSETTING( GK_OFF, "GK Off" ) |
| 179 | | PORT_DIPSETTING( GK_NORMAL, DEF_STR( Normal ) ) |
| 180 | | |
| 181 | | PORT_START( "GKSWITCH2" ) |
| 182 | | PORT_DIPNAME( 0x01, GK_OPSYS, "GK switch 2" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)2) |
| 183 | | PORT_DIPSETTING( GK_GRAM0, "GRAM 0" ) |
| 184 | | PORT_DIPSETTING( GK_OPSYS, "Op Sys" ) |
| 185 | | |
| 186 | | PORT_START( "GKSWITCH3" ) |
| 187 | | PORT_DIPNAME( 0x01, GK_TIBASIC, "GK switch 3" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)3) |
| 188 | | PORT_DIPSETTING( GK_GRAM12, "GRAM 1-2" ) |
| 189 | | PORT_DIPSETTING( GK_TIBASIC, "TI BASIC" ) |
| 190 | | |
| 191 | | PORT_START( "GKSWITCH4" ) |
| 192 | | PORT_DIPNAME( 0x03, GK_WP, "GK switch 4" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)4) |
| 193 | | PORT_DIPSETTING( GK_BANK1, "Bank 1" ) |
| 194 | | PORT_DIPSETTING( GK_WP, "W/P" ) |
| 195 | | PORT_DIPSETTING( GK_BANK2, "Bank 2" ) |
| 196 | | |
| 197 | | PORT_START( "GKSWITCH5" ) |
| 198 | | PORT_DIPNAME( 0x01, GK_LDON, "GK switch 5" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)5) |
| 199 | | PORT_DIPSETTING( GK_LDON, "Loader On" ) |
| 200 | | PORT_DIPSETTING( GK_LDOFF, "Loader Off" ) |
| 201 | | |
| 202 | | PORT_START( "BWGDIP1" ) |
| 203 | | PORT_DIPNAME( 0x01, 0x00, "BwG step rate" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 204 | | PORT_DIPSETTING( 0x00, "6 ms") |
| 205 | | PORT_DIPSETTING( 0x01, "20 ms") |
| 206 | | |
| 207 | | PORT_START( "BWGDIP2" ) |
| 208 | | PORT_DIPNAME( 0x01, 0x00, "BwG date/time display" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 209 | | PORT_DIPSETTING( 0x00, "Hide") |
| 210 | | PORT_DIPSETTING( 0x01, "Show") |
| 211 | | |
| 212 | | PORT_START( "BWGDIP34" ) |
| 213 | | PORT_DIPNAME( 0x03, 0x00, "BwG drives" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 214 | | PORT_DIPSETTING( 0x00, "DSK1 only") |
| 215 | | PORT_DIPSETTING( 0x01, "DSK1-DSK2") |
| 216 | | PORT_DIPSETTING( 0x02, "DSK1-DSK3") |
| 217 | | PORT_DIPSETTING( 0x03, "DSK1-DSK4") |
| 218 | | |
| 219 | | PORT_START( "HFDCDIP" ) |
| 220 | | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 221 | | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 222 | | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 223 | | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 224 | | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 225 | | |
| 226 | | PORT_START( "DRVSPD" ) |
| 227 | | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 228 | | PORT_CONFSETTING( 0x00, "No delay") |
| 229 | | PORT_CONFSETTING( 0x01, "Realistic") |
| 230 | | |
| 231 | 189 | /* 3 ports for mouse */ |
| 232 | 190 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 233 | 191 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| r14513 | r14514 | |
| 321 | 279 | |
| 322 | 280 | INPUT_PORTS_END |
| 323 | 281 | |
| 324 | | /* |
| 325 | | Input ports for the TI-99/4A with EPVC |
| 326 | | Same as above, but with some additional dip switches |
| 327 | | */ |
| 328 | | static INPUT_PORTS_START(ti99_4ev) |
| 329 | | PORT_INCLUDE(ti99_4a) |
| 330 | | PORT_START( "EVPC-SW1" ) |
| 331 | | PORT_DIPNAME( 0x01, 0x00, "EVPC video mode" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 332 | | PORT_DIPSETTING( 0x00, "PAL" ) |
| 333 | | PORT_DIPSETTING( 0x01, "NTSC" ) |
| 334 | | |
| 335 | | PORT_START( "EVPC-SW3" ) |
| 336 | | PORT_DIPNAME( 0x01, 0x00, "EVPC charset" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 337 | | PORT_DIPSETTING( 0x00, DEF_STR( International )) |
| 338 | | PORT_DIPSETTING( 0x01, DEF_STR( German )) |
| 339 | | |
| 340 | | PORT_START( "EVPC-SW4" ) |
| 341 | | PORT_DIPNAME( 0x01, 0x00, "EVPC VDP RAM" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) |
| 342 | | PORT_DIPSETTING( 0x00, "shifted" ) |
| 343 | | PORT_DIPSETTING( 0x01, "not shifted" ) |
| 344 | | |
| 345 | | PORT_START( "EVPC-SW8" ) |
| 346 | | PORT_DIPNAME( 0x01, 0x00, "EVPC Configuration" ) |
| 347 | | PORT_DIPSETTING( 0x00, "DIP" ) |
| 348 | | PORT_DIPSETTING( 0x01, "NOVRAM" ) |
| 349 | | |
| 350 | | PORT_START( "V9938-MEM" ) |
| 351 | | PORT_CONFNAME( 0x01, 0x00, "V9938 RAM size" ) |
| 352 | | PORT_CONFSETTING( 0x00, "128 KiB" ) |
| 353 | | PORT_CONFSETTING( 0x01, "192 KiB" ) |
| 354 | | |
| 355 | | INPUT_PORTS_END |
| 356 | | |
| 282 | /* TI99/4: 41-key keyboard, plus two optional joysticks (2 space keys) */ |
| 357 | 283 | #define JOYSTICK_DELTA 10 |
| 358 | 284 | #define JOYSTICK_SENSITIVITY 100 |
| 359 | 285 | |
| 360 | | /* TI99/4: 41-key keyboard, plus two optional joysticks (2 space keys) */ |
| 361 | 286 | static INPUT_PORTS_START(ti99_4) |
| 362 | 287 | |
| 363 | 288 | PORT_START( "RAM" ) /* config */ |
| 364 | | PORT_CONFNAME( 0x07, 0x01, "RAM extension" ) |
| 365 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 366 | | PORT_CONFSETTING( 0x01, "Console 32 KiB (16 bit)" ) |
| 367 | | PORT_CONFSETTING( 0x02, "TI 32 KiB card" ) |
| 368 | | PORT_CONFSETTING( 0x03, "Super AMS 1MiB" ) |
| 369 | | PORT_CONFSETTING( 0x07, "Myarc 512 KiB" ) |
| 289 | PORT_CONFNAME( 0x01, 0x09, "Console 32 KiB RAM upgrade (16 bit)" ) |
| 290 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 291 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 370 | 292 | |
| 371 | | PORT_START( "SPEECH" ) |
| 372 | | PORT_CONFNAME( 0x01, 0x01, "Speech synthesizer" ) |
| 373 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 374 | | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 375 | | |
| 376 | | PORT_START( "DISKCTRL" ) |
| 377 | | PORT_CONFNAME( 0x07, 0x03, "Disk controller" ) |
| 378 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 379 | | PORT_CONFSETTING( 0x01, "TI SD Floppy Controller" ) |
| 380 | | PORT_CONFSETTING( 0x02, "SNUG BwG Controller" ) |
| 381 | | PORT_CONFSETTING( 0x03, "Myarc HFDC" ) |
| 382 | | // PORT_CONFSETTING( 0x04, "Corcomp" ) |
| 383 | | |
| 384 | | PORT_START( "HDCTRL" ) |
| 385 | | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 386 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 387 | | PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 388 | | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 389 | | PORT_CONFNAME( 0x08, 0x00, "USB-SM card" ) |
| 293 | PORT_START( "GROMENA" ) |
| 294 | PORT_CONFNAME( 0x01, 0x01, "Console GROMs" ) |
| 390 | 295 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 391 | | PORT_CONFSETTING( 0x08, DEF_STR( On ) ) |
| 296 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 392 | 297 | |
| 393 | | PORT_START( "SERIAL" ) |
| 394 | | PORT_CONFNAME( 0x03, 0x00, "Serial/Parallel interface" ) |
| 395 | | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 396 | | PORT_CONFSETTING( 0x01, "TI RS-232 card" ) |
| 397 | | |
| 398 | | PORT_START( "SERIALMAP" ) |
| 399 | | PORT_CONFNAME( 0x03, 0x00, "Serial cable pin mapping" ) PORT_CONDITION( "SERIAL", 0x03, PORTCOND_NOTEQUALS, 0x00 ) |
| 400 | | PORT_CONFSETTING( 0x00, "6-20" ) |
| 401 | | PORT_CONFSETTING( 0x01, "8-20" ) |
| 402 | | PORT_CONFSETTING( 0x02, "5-20" ) |
| 403 | | |
| 404 | | PORT_START( "EXTCARD" ) |
| 405 | | PORT_CONFNAME( 0x03, 0x00, "HSGPL extension" ) |
| 298 | PORT_START( "MECMOUSE" ) |
| 299 | PORT_CONFNAME( 0x01, 0x00, "Mechatronics Mouse" ) |
| 406 | 300 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 407 | | PORT_CONFSETTING( 0x01, "Flash" ) |
| 408 | | PORT_CONFSETTING( 0x02, DEF_STR( On ) ) |
| 301 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 409 | 302 | |
| 410 | | PORT_START( "HCI" ) |
| 411 | | PORT_CONFNAME( 0x01, 0x00, "Mouse support" ) |
| 303 | PORT_START( "HANDSET" ) |
| 304 | PORT_CONFNAME( 0x01, 0x00, "IR Handset" ) |
| 412 | 305 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 413 | | PORT_CONFSETTING( 0x01, "Mechatronics Mouse" ) |
| 414 | | PORT_CONFNAME( 0x04, 0x00, "IR Handset" ) |
| 415 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 416 | | PORT_CONFSETTING( 0x04, DEF_STR( On ) ) |
| 306 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 417 | 307 | |
| 418 | | PORT_START( "CARTSLOT" ) |
| 419 | | PORT_DIPNAME( 0x0f, 0x00, "Cartridge slot" ) |
| 420 | | PORT_DIPSETTING( 0x00, "Auto" ) |
| 421 | | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 422 | | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 423 | | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 424 | | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 425 | | PORT_DIPSETTING( 0x0f, "GRAM Kracker" ) |
| 426 | | |
| 427 | | /* GRAM Kracker Support */ |
| 428 | | PORT_START( "GKSWITCH1" ) |
| 429 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 1" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)1) |
| 430 | | PORT_DIPSETTING( 0x00, "GK Off" ) |
| 431 | | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 432 | | |
| 433 | | PORT_START( "GKSWITCH2" ) |
| 434 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 2" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)2) |
| 435 | | PORT_DIPSETTING( 0x00, "GRAM 0" ) |
| 436 | | PORT_DIPSETTING( 0x01, "Op Sys" ) |
| 437 | | |
| 438 | | PORT_START( "GKSWITCH3" ) |
| 439 | | PORT_DIPNAME( 0x01, 0x01, "GK switch 3" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)3) |
| 440 | | PORT_DIPSETTING( 0x00, "GRAM 1-2" ) |
| 441 | | PORT_DIPSETTING( 0x01, "TI BASIC" ) |
| 442 | | |
| 443 | | PORT_START( "GKSWITCH4" ) |
| 444 | | PORT_DIPNAME( 0x03, 0x01, "GK switch 4" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)4) |
| 445 | | PORT_DIPSETTING( 0x00, "Bank 1" ) |
| 446 | | PORT_DIPSETTING( 0x01, "W/P" ) |
| 447 | | PORT_DIPSETTING( 0x02, "Bank 2" ) |
| 448 | | |
| 449 | | PORT_START( "GKSWITCH5" ) |
| 450 | | PORT_DIPNAME( 0x01, 0x00, "GK switch 5" ) PORT_CONDITION( "CARTSLOT", 0x0f, PORTCOND_EQUALS, 0x0f ) PORT_CHANGED( gk_changed, (void *)5) |
| 451 | | PORT_DIPSETTING( 0x00, "Loader On" ) |
| 452 | | PORT_DIPSETTING( 0x01, "Loader Off" ) |
| 453 | | |
| 454 | | PORT_START( "BWGDIP1" ) |
| 455 | | PORT_DIPNAME( 0x01, 0x00, "BwG step rate" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 456 | | PORT_DIPSETTING( 0x00, "6 ms") |
| 457 | | PORT_DIPSETTING( 0x01, "20 ms") |
| 458 | | |
| 459 | | PORT_START( "BWGDIP2" ) |
| 460 | | PORT_DIPNAME( 0x01, 0x00, "BwG date/time display" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 461 | | PORT_DIPSETTING( 0x00, "Hide") |
| 462 | | PORT_DIPSETTING( 0x01, "Show") |
| 463 | | |
| 464 | | PORT_START( "BWGDIP34" ) |
| 465 | | PORT_DIPNAME( 0x03, 0x00, "BwG drives" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x02 ) |
| 466 | | PORT_DIPSETTING( 0x00, "DSK1 only") |
| 467 | | PORT_DIPSETTING( 0x01, "DSK1-DSK2") |
| 468 | | PORT_DIPSETTING( 0x02, "DSK1-DSK3") |
| 469 | | PORT_DIPSETTING( 0x03, "DSK1-DSK4") |
| 470 | | |
| 471 | | PORT_START( "HFDCDIP" ) |
| 472 | | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 473 | | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| 474 | | PORT_DIPSETTING( 0xaa, "40 track, 8 ms") |
| 475 | | PORT_DIPSETTING( 0x55, "80 track, 2 ms") |
| 476 | | PORT_DIPSETTING( 0xff, "80 track HD, 2 ms") |
| 477 | | |
| 478 | | // We do not want to show this setting; makes only sense for Geneve |
| 479 | | PORT_START( "MODE" ) |
| 480 | | PORT_CONFNAME( 0x01, 0x00, "Ext. cards modification" ) PORT_CONDITION( "HFDCDIP", 0x0f, PORTCOND_EQUALS, GM_NEVER ) |
| 481 | | PORT_CONFSETTING( 0x00, "Standard" ) |
| 482 | | PORT_CONFSETTING( GENMOD, "GenMod" ) |
| 483 | | |
| 484 | | PORT_START( "DRVSPD" ) |
| 485 | | PORT_CONFNAME( 0x01, 0x01, "Floppy and HD speed" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 486 | | PORT_CONFSETTING( 0x00, "No delay") |
| 487 | | PORT_CONFSETTING( 0x01, "Realistic") |
| 488 | | |
| 489 | 308 | /* 3 ports for mouse */ |
| 490 | 309 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 491 | 310 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| r14513 | r14514 | |
| 688 | 507 | |
| 689 | 508 | INPUT_PORTS_END |
| 690 | 509 | |
| 691 | | /* F4 Character Displayer */ |
| 692 | | static const gfx_layout ti99_6_charlayout = |
| 510 | /***************************************************************************** |
| 511 | Components |
| 512 | ******************************************************************************/ |
| 513 | |
| 514 | static GROM_CONFIG(grom0_config) |
| 693 | 515 | { |
| 694 | | 8, 6, /* 8 x 6 characters */ |
| 695 | | 64, /* 64 characters */ |
| 696 | | 1, /* 1 bits per pixel */ |
| 697 | | { 0 }, /* no bitplanes */ |
| 698 | | /* x offsets */ |
| 699 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 700 | | /* y offsets */ |
| 701 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8 }, |
| 702 | | 8*6 /* every char takes 6 bytes */ |
| 516 | false, 0, region_grom, 0x0000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_4x, console_ready) |
| 703 | 517 | }; |
| 704 | 518 | |
| 705 | | static const gfx_layout ti99_7_charlayout = |
| 519 | static GROM_CONFIG(grom1_config) |
| 706 | 520 | { |
| 707 | | 8, 7, /* 8 x 7 characters */ |
| 708 | | 95, /* 95 characters */ |
| 709 | | 1, /* 1 bits per pixel */ |
| 710 | | { 0 }, /* no bitplanes */ |
| 711 | | /* x offsets */ |
| 712 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 713 | | /* y offsets */ |
| 714 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8 }, |
| 715 | | 8*7 /* every char takes 7 bytes */ |
| 521 | false, 1, region_grom, 0x2000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_4x, console_ready) |
| 716 | 522 | }; |
| 717 | 523 | |
| 718 | | static const gfx_layout ti99_8_charlayout = |
| 524 | static GROM_CONFIG(grom2_config) |
| 719 | 525 | { |
| 720 | | 8, 8, /* 8 x 8 characters */ |
| 721 | | 64, /* 64 characters */ |
| 722 | | 1, /* 1 bits per pixel */ |
| 723 | | { 0 }, /* no bitplanes */ |
| 724 | | /* x offsets */ |
| 725 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 726 | | /* y offsets */ |
| 727 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 728 | | 8*8 /* every char takes 8 bytes */ |
| 526 | false, 2, region_grom, 0x4000, 0x1800, false, DEVCB_DRIVER_LINE_MEMBER(ti99_4x, console_ready) |
| 729 | 527 | }; |
| 730 | 528 | |
| 731 | | static const gfx_layout ti99_c_charlayout = |
| 529 | static GROMPORT_CONFIG(console_cartslot) |
| 732 | 530 | { |
| 733 | | 8, 8, /* 8 x 8 characters */ |
| 734 | | 1, /* 1 characters */ |
| 735 | | 1, /* 1 bits per pixel */ |
| 736 | | { 0 }, /* no bitplanes */ |
| 737 | | /* x offsets */ |
| 738 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 739 | | /* y offsets */ |
| 740 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 741 | | 8*8 /* every char takes 8 bytes */ |
| 531 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, console_ready) |
| 742 | 532 | }; |
| 743 | 533 | |
| 744 | | static const gfx_layout ti99_24_charlayout = |
| 534 | static PERIBOX_CONFIG( peribox_conf ) |
| 745 | 535 | { |
| 746 | | 24, 24, /* 24 x 24 characters */ |
| 747 | | 1, /* 1 characters */ |
| 748 | | 1, /* 1 bits per pixel */ |
| 749 | | { 0 }, /* no bitplanes */ |
| 750 | | /* x offsets */ |
| 751 | | { 0, 1, 2, 3, 4, 5, 6, 7, 64, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 }, |
| 752 | | /* y offsets */ |
| 753 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8, 48*8, 49*8, 50*8, 51*8, 52*8, 53*8, 54*8, 55*8 }, |
| 754 | | 24*24 /* every char takes 72 bytes */ |
| 536 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, extint), // INTA |
| 537 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, notconnected), // INTB |
| 538 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, console_ready), // READY |
| 539 | 0x70000 // Address bus prefix (AMA/AMB/AMC) |
| 755 | 540 | }; |
| 756 | 541 | |
| 757 | | static GFXDECODE_START( ti99 ) |
| 758 | | GFXDECODE_ENTRY( region_grom, 0x0466, ti99_8_charlayout, 0, 8 ) |
| 759 | | GFXDECODE_ENTRY( region_grom, 0x0666, ti99_6_charlayout, 0, 8 ) |
| 760 | | GFXDECODE_END |
| 542 | READ8_MEMBER( ti99_4x::cruread ) |
| 543 | { |
| 544 | // if (VERBOSE>6) LOG("read access to CRU address %04x\n", offset << 4); |
| 545 | UINT8 value = 0; |
| 761 | 546 | |
| 762 | | static GFXDECODE_START( ti99a ) |
| 763 | | GFXDECODE_ENTRY( region_grom, 0x04b4, ti99_8_charlayout, 0, 8 ) // large |
| 764 | | GFXDECODE_ENTRY( region_grom, 0x06b4, ti99_7_charlayout, 0, 8 ) // small |
| 765 | | GFXDECODE_ENTRY( region_grom, 0x0950, ti99_24_charlayout, 0, 8 )// TI logo |
| 766 | | GFXDECODE_ENTRY( region_grom, 0x0998, ti99_c_charlayout, 0, 8 ) // (c) |
| 767 | | GFXDECODE_END |
| 547 | // Similar to the bus8z_devices, just let the gromport and the p-box |
| 548 | // decide whether they want to change the value at the CRU address |
| 549 | // Also, we translate the bit addresses to base addresses |
| 550 | m_gromport->crureadz(offset<<4, &value); |
| 551 | m_peribox->crureadz(offset<<4, &value); |
| 768 | 552 | |
| 769 | | static GFXDECODE_START( ti99b ) |
| 770 | | GFXDECODE_ENTRY( region_grom, 0x04b4, ti99_8_charlayout, 2, 2 ) |
| 771 | | GFXDECODE_ENTRY( region_grom, 0x06b4, ti99_7_charlayout, 2, 2 ) |
| 772 | | GFXDECODE_ENTRY( region_grom, 0x0950, ti99_24_charlayout, 2, 2 ) |
| 773 | | GFXDECODE_ENTRY( region_grom, 0x0998, ti99_c_charlayout, 2, 2 ) |
| 774 | | GFXDECODE_END |
| 553 | return value; |
| 554 | } |
| 775 | 555 | |
| 776 | | static WRITE_LINE_DEVICE_HANDLER(set_int2) |
| 556 | WRITE8_MEMBER( ti99_4x::cruwrite ) |
| 777 | 557 | { |
| 778 | | tms9901_set_int2(device->machine().device("ti_board"), state ); |
| 558 | // if (VERBOSE>6) LOG("write access to CRU address %04x\n", offset << 1); |
| 559 | m_gromport->cruwrite(offset<<1, data); |
| 560 | m_peribox->cruwrite(offset<<1, data); |
| 779 | 561 | } |
| 780 | 562 | |
| 563 | /*************************************************************************** |
| 564 | TI99/4x-specific tms9901 I/O handlers |
| 565 | |
| 566 | See mess/machine/tms9901.c for generic tms9901 CRU handlers. |
| 567 | |
| 568 | TMS9901 interrupt handling on a TI99/4(a). |
| 569 | |
| 570 | TI99/4(a) uses the following interrupts: |
| 571 | INT1: external interrupt (used by RS232 controller, for instance) |
| 572 | INT2: VDP interrupt |
| 573 | TMS9901 timer interrupt (overrides INT3) |
| 574 | INT12: handset interrupt (only on a TI-99/4 with the handset prototypes) |
| 575 | |
| 576 | Three (occasionally four) interrupts are used by the system (INT1, INT2, |
| 577 | timer, and INT12 on a TI-99/4 with remote handset prototypes), out of 15/16 |
| 578 | possible interrupts. Keyboard pins can be used as interrupt pins, too, but |
| 579 | this is not emulated (it's a trick, anyway, and I don't know any program |
| 580 | which uses it). |
| 581 | |
| 582 | When an interrupt line is set (and the corresponding bit in the interrupt mask is set), |
| 583 | a level 1 interrupt is requested from the TMS9900. This interrupt request lasts as long as |
| 584 | the interrupt pin and the revelant bit in the interrupt mask are set. |
| 585 | |
| 586 | ***************************************************************************/ |
| 587 | |
| 588 | |
| 589 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; |
| 590 | static const char *const keynames8[] = { "KEY0", "KEY1", "KEY2", "KEY3", |
| 591 | "KEY4", "KEY5", "KEY6", "KEY7", "KEY8", "KEY9", "KEY10", "KEY11", |
| 592 | "KEY12", "KEY13", "KEY14", "KEY15" |
| 593 | }; |
| 594 | |
| 595 | READ8_MEMBER( ti99_4x::read_by_9901 ) |
| 596 | { |
| 597 | int answer=0; |
| 598 | int col =0; |
| 599 | |
| 600 | switch (offset & 0x03) |
| 601 | { |
| 602 | case TMS9901_CB_INT7: |
| 603 | // |
| 604 | // Read pins INT3*-INT7* of TI99's 9901. |
| 605 | // bit 1: INT1 status (interrupt; not set at this place) |
| 606 | // bit 2: INT2 status (interrupt; not set at this place) |
| 607 | // bit 3-7: keyboard status bits 0 to 4 |
| 608 | // |
| 609 | if (m_mode==TI994) |
| 610 | { |
| 611 | col = 6; |
| 612 | if ((m_handset != NULL) && (m_keyboard_column == 7)) |
| 613 | { |
| 614 | answer = (m_handset->poll_bus() << 3); |
| 615 | answer |= 0x80; |
| 616 | } |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | col = 7; |
| 621 | if (m_alphalock_line==false) |
| 622 | { |
| 623 | answer &= ~(input_port_read(machine(), "ALPHA") << 3); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | if ((m_mecmouse != NULL) && (m_keyboard_column == col)) |
| 628 | { |
| 629 | answer = m_mecmouse->get_values(); |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | answer = ((input_port_read(machine(), keynames[m_keyboard_column >> 1]) >> ((m_keyboard_column & 1) * 8)) << 3) & 0xF8; |
| 634 | } |
| 635 | |
| 636 | break; |
| 637 | |
| 638 | case TMS9901_INT8_INT15: |
| 639 | if (m_keyboard_column == 7) |
| 640 | { |
| 641 | answer = 0x07; |
| 642 | } |
| 643 | else |
| 644 | { |
| 645 | answer = ((input_port_read(machine(), keynames[m_keyboard_column >> 1]) >> ((m_keyboard_column & 1) * 8)) >> 5) & 0x07; |
| 646 | } |
| 647 | break; |
| 648 | |
| 649 | case TMS9901_P0_P7: |
| 650 | if (m_handset != NULL) |
| 651 | { |
| 652 | if (m_handset->get_clock()) answer |= 2; |
| 653 | } |
| 654 | break; |
| 655 | |
| 656 | case TMS9901_P8_P15: |
| 657 | answer = 4; |
| 658 | /* on systems without handset, the pin is pulled up to avoid spurious interrupts */ |
| 659 | if (m_handset != NULL) |
| 660 | { |
| 661 | if (m_handset->get_int()) answer = 0; |
| 662 | } |
| 663 | /* we don't take CS2 into account, as CS2 is a write-only unit */ |
| 664 | if ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0) |
| 665 | { |
| 666 | answer |= 8; |
| 667 | } |
| 668 | break; |
| 669 | } |
| 670 | return answer; |
| 671 | } |
| 672 | |
| 673 | /* |
| 674 | Handler for tms9901 P0 pin (handset data acknowledge) |
| 675 | */ |
| 676 | WRITE_LINE_MEMBER( ti99_4x::handset_ack ) |
| 677 | { |
| 678 | if (m_handset != NULL) |
| 679 | { |
| 680 | if (VERBOSE>7) LOG("ti99_4x: Set handset ack %d\n", state); |
| 681 | m_handset->set_acknowledge(state); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | /* |
| 686 | WRITE key column select (P2-P4), TI-99/4 |
| 687 | */ |
| 688 | void ti99_4x::set_key(int number, int data) |
| 689 | { |
| 690 | int index = (m_mode==TI994A)? 6 : 5; |
| 691 | |
| 692 | if (data != 0) |
| 693 | m_keyboard_column |= 1 << number; |
| 694 | else |
| 695 | m_keyboard_column &= ~ (1 << number); |
| 696 | |
| 697 | if (m_mecmouse != NULL) |
| 698 | m_mecmouse->select(m_keyboard_column, index, index+1); |
| 699 | } |
| 700 | |
| 701 | WRITE_LINE_MEMBER( ti99_4x::keyC0 ) |
| 702 | { |
| 703 | set_key(0, state); |
| 704 | } |
| 705 | |
| 706 | WRITE_LINE_MEMBER( ti99_4x::keyC1 ) |
| 707 | { |
| 708 | set_key(1, state); |
| 709 | } |
| 710 | |
| 711 | WRITE_LINE_MEMBER( ti99_4x::keyC2 ) |
| 712 | { |
| 713 | set_key(2, state); |
| 714 | } |
| 715 | |
| 716 | /* |
| 717 | Select alpha lock line - TI99/4a only (P5) |
| 718 | */ |
| 719 | WRITE_LINE_MEMBER( ti99_4x::alphaW ) |
| 720 | { |
| 721 | m_alphalock_line = state; |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | Control CS1 tape unit motor (P6) |
| 726 | */ |
| 727 | WRITE_LINE_MEMBER( ti99_4x::cs1_motor ) |
| 728 | { |
| 729 | cassette_image_device *img = machine().device<cassette_image_device>(CASSETTE_TAG); |
| 730 | img->change_state(state==ASSERT_LINE? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 731 | } |
| 732 | |
| 733 | /* |
| 734 | Control CS2 tape unit motor (P7) |
| 735 | */ |
| 736 | WRITE_LINE_MEMBER( ti99_4x::cs2_motor ) |
| 737 | { |
| 738 | cassette_image_device *img = machine().device<cassette_image_device>(CASSETTE2_TAG); |
| 739 | img->change_state(state==ASSERT_LINE? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | Audio gate (P8) |
| 744 | Set to 1 before using tape: this enables the mixing of tape input sound |
| 745 | with computer sound. |
| 746 | We do not really need to emulate this as the tape recorder generates sound |
| 747 | on its own. |
| 748 | */ |
| 749 | WRITE_LINE_MEMBER( ti99_4x::audio_gate ) |
| 750 | { |
| 751 | } |
| 752 | |
| 753 | /* |
| 754 | Tape output (P9) |
| 755 | I think polarity is correct, but don't take my word for it. |
| 756 | */ |
| 757 | WRITE_LINE_MEMBER( ti99_4x::cassette_output ) |
| 758 | { |
| 759 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(state==ASSERT_LINE? +1 : -1); |
| 760 | machine().device<cassette_image_device>(CASSETTE2_TAG)->output(state==ASSERT_LINE? +1 : -1); |
| 761 | } |
| 762 | |
| 763 | WRITE8_MEMBER( ti99_4x::tms9901_interrupt ) |
| 764 | { |
| 765 | // offset contains the interrupt level (0-15) |
| 766 | if (data==ASSERT_LINE) |
| 767 | { |
| 768 | // The TMS9901 should normally be connected with the CPU by 5 wires: |
| 769 | // INTREQ* and IC0-IC3. The last four lines deliver the interrupt level. |
| 770 | // On the TI-99 systems these IC lines are not used; the input lines |
| 771 | // at the CPU are hardwired to level 1. |
| 772 | device_execute(m_cpu)->set_input_line_and_vector(0, ASSERT_LINE, 1); |
| 773 | } |
| 774 | else |
| 775 | { |
| 776 | device_execute(m_cpu)->set_input_line(0, CLEAR_LINE); |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | /*****************************************************************************/ |
| 781 | |
| 782 | /* |
| 783 | set the state of TMS9901's INT2 (called by the tms9928 core) |
| 784 | */ |
| 785 | WRITE_LINE_MEMBER( ti99_4x::set_tms9901_INT2 ) |
| 786 | { |
| 787 | if (VERBOSE>6) LOG("ti99_4x: VDP int 2 on tms9901, level=%02x\n", state); |
| 788 | m_tms9901->set_single_int(2, state); |
| 789 | } |
| 790 | |
| 791 | void ti99_4x::set_tms9901_INT2_from_v9938(v99x8_device &vdp, int state) |
| 792 | { |
| 793 | m_tms9901->set_single_int(2, state); |
| 794 | } |
| 795 | |
| 796 | /* |
| 797 | set the state of TMS9901's INT12 (called by the handset prototype of TI-99/4) |
| 798 | */ |
| 799 | WRITE_LINE_MEMBER( ti99_4x::set_tms9901_INT12) |
| 800 | { |
| 801 | if (m_handset!=NULL) m_tms9901->set_single_int(12, state); |
| 802 | } |
| 803 | |
| 804 | /*********************************************************** |
| 805 | Links to external devices |
| 806 | ***********************************************************/ |
| 807 | |
| 808 | |
| 809 | WRITE_LINE_MEMBER( ti99_4x::console_ready ) |
| 810 | { |
| 811 | if (VERBOSE>6) LOG("READY line set ... not yet connected, level=%02x\n", state); |
| 812 | } |
| 813 | |
| 814 | WRITE_LINE_MEMBER( ti99_4x::extint ) |
| 815 | { |
| 816 | if (VERBOSE>6) LOG("EXTINT level = %02x\n", state); |
| 817 | if (m_tms9901 != NULL) |
| 818 | m_tms9901->set_single_int(1, state); |
| 819 | } |
| 820 | |
| 821 | WRITE_LINE_MEMBER( ti99_4x::notconnected ) |
| 822 | { |
| 823 | if (VERBOSE>6) LOG("Setting a not connected line ... ignored\n"); |
| 824 | } |
| 825 | |
| 826 | /*****************************************************************************/ |
| 827 | |
| 781 | 828 | static TMS9928A_INTERFACE(ti99_4_tms9928a_interface) |
| 782 | 829 | { |
| 783 | 830 | SCREEN_TAG, |
| 784 | 831 | 0x4000, |
| 785 | | DEVCB_LINE(set_int2) |
| 832 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, set_tms9901_INT2) |
| 786 | 833 | }; |
| 787 | 834 | |
| 788 | | /* |
| 789 | | Format: |
| 790 | | Name, address bus mask, select pattern, write select bit(s), read8z function, write8 function, Condition name, bits which must be set, bits which must not be set |
| 835 | static TI99_HANDSET_INTERFACE(ti99_4_handset_interface) |
| 836 | { |
| 837 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, set_tms9901_INT12) |
| 838 | }; |
| 791 | 839 | |
| 792 | | Multiple devices may have the same select pattern; as in the real hardware, |
| 793 | | care must be taken that only one device actually responds. In the case of |
| 794 | | GROMs, each chip has an internal address counter and an ID, and the chip |
| 795 | | only responds when the ID and the most significant 3 bits match. |
| 796 | | If the HSGPL extension is active, the console GROMs should be removed. In |
| 797 | | reality, the chips should be pulled out of their sockets. Here we simulate |
| 798 | | this by a condition. |
| 799 | | */ |
| 800 | | static const bus_device dmux_devices[] = |
| 840 | /* TMS9901 setup. */ |
| 841 | const tms9901_interface tms9901_wiring_ti99_4 = |
| 801 | 842 | { |
| 802 | | { "console_grom_0", 0xfc01, 0x9800, 0x0400, ti99grom_rz, ti99grom_w, "EXTCARD", 0x00, 0x02 }, |
| 803 | | { "console_grom_1", 0xfc01, 0x9800, 0x0400, ti99grom_rz, ti99grom_w, "EXTCARD", 0x00, 0x02 }, |
| 804 | | { "console_grom_2", 0xfc01, 0x9800, 0x0400, ti99grom_rz, ti99grom_w, "EXTCARD", 0x00, 0x02 }, |
| 805 | | { "soundgen", 0xfc01, 0x8400, 0x0000, NULL, sn76496_w, NULL, 0, 0 }, |
| 806 | | { "gromport", 0xfc01, 0x9800, 0x0400, gromportg_rz, gromportg_w, NULL, 0, 0 }, |
| 807 | | { "gromport", 0xe000, 0x6000, 0x0000, gromportr_rz, gromportr_w, NULL, 0, 0 }, |
| 808 | | { "peribox", 0x0000, 0x0000, 0x0000, ti99_peb_data_rz, ti99_peb_data_w, 0, 0 }, // Peribox needs all addresses |
| 809 | | { NULL, 0, 0, 0, NULL, NULL, 0, 0 } |
| 843 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 844 | |
| 845 | // read handler |
| 846 | DEVCB_DRIVER_MEMBER(ti99_4x, read_by_9901), |
| 847 | |
| 848 | // write handlers |
| 849 | { |
| 850 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, handset_ack), |
| 851 | DEVCB_NULL, |
| 852 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC0), |
| 853 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC1), |
| 854 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC2), |
| 855 | DEVCB_NULL, |
| 856 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cs1_motor), |
| 857 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cs2_motor), |
| 858 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, audio_gate), |
| 859 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cassette_output), |
| 860 | DEVCB_NULL, |
| 861 | DEVCB_NULL, |
| 862 | DEVCB_NULL, |
| 863 | DEVCB_NULL, |
| 864 | DEVCB_NULL, |
| 865 | DEVCB_NULL |
| 866 | }, |
| 867 | |
| 868 | // interrupt handler |
| 869 | DEVCB_DRIVER_MEMBER(ti99_4x, tms9901_interrupt) |
| 810 | 870 | }; |
| 811 | 871 | |
| 812 | | static const cruconf_device cru_devices[] = |
| 872 | const tms9901_interface tms9901_wiring_ti99_4a = |
| 813 | 873 | { |
| 814 | | { "gromport", 0xf800, 0x0800, gromportc_rz, gromportc_w }, // Check: Is this really limited? |
| 815 | | { "peribox", 0x0000, 0x0000, ti99_peb_cru_rz, ti99_peb_cru_w }, // Peribox needs all addresses |
| 816 | | { NULL, 0, 0, NULL, NULL } |
| 874 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, |
| 875 | |
| 876 | // read handler |
| 877 | DEVCB_DRIVER_MEMBER(ti99_4x, read_by_9901), |
| 878 | |
| 879 | // write handlers |
| 880 | { |
| 881 | DEVCB_NULL, |
| 882 | DEVCB_NULL, |
| 883 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC0), |
| 884 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC1), |
| 885 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, keyC2), |
| 886 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, alphaW), |
| 887 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cs1_motor), |
| 888 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cs2_motor), |
| 889 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, audio_gate), |
| 890 | DEVCB_DRIVER_LINE_MEMBER(ti99_4x, cassette_output), |
| 891 | DEVCB_NULL, |
| 892 | DEVCB_NULL, |
| 893 | DEVCB_NULL, |
| 894 | DEVCB_NULL, |
| 895 | DEVCB_NULL, |
| 896 | DEVCB_NULL |
| 897 | }, |
| 898 | |
| 899 | DEVCB_DRIVER_MEMBER(ti99_4x, tms9901_interrupt) |
| 817 | 900 | }; |
| 818 | 901 | |
| 819 | | MACHINE_RESET( ti99_4 ) |
| 902 | /* |
| 903 | Devices attached to the databus multiplexer. We cannot solve this with |
| 904 | the common address maps since the multiplexer also inserts wait states |
| 905 | that we want to emulate properly. Also, devices may reside on the same |
| 906 | memory locations (like GROMs) and select themselves according to some |
| 907 | inner state (e.g. GROMs have an own address counter and a given address |
| 908 | area). |
| 909 | */ |
| 910 | static const dmux_device_list_entry dmux_devices[] = |
| 820 | 911 | { |
| 912 | { GROM0_TAG, 0x9800, 0xfc01, 0x0400, "GROMENA", 0x01, 0x00 }, |
| 913 | { GROM1_TAG, 0x9800, 0xfc01, 0x0400, "GROMENA", 0x01, 0x00 }, |
| 914 | { GROM2_TAG, 0x9800, 0xfc01, 0x0400, "GROMENA", 0x01, 0x00 }, |
| 915 | { TISOUND_TAG, 0x8400, 0xfc01, 0x0000, NULL, 0, 0 }, |
| 916 | { GROMPORT_TAG, 0x9800, 0xfc01, 0x0400, NULL, 0, 0 }, |
| 917 | { GROMPORT_TAG, 0x6000, 0xe000, 0x0000, NULL, 0, 0 }, |
| 918 | { PERIBOX_TAG, 0x0000, 0x0000, 0x0000, NULL, 0, 0 }, // Peribox needs all addresses |
| 919 | { NULL, 0, 0, 0, NULL, 0, 0 } |
| 920 | }; |
| 921 | |
| 922 | /****************************************************************************** |
| 923 | Machine definitions |
| 924 | ******************************************************************************/ |
| 925 | |
| 926 | MACHINE_START( ti99_4 ) |
| 927 | { |
| 928 | ti99_4x *driver = machine.driver_data<ti99_4x>(); |
| 929 | driver->m_mode = TI994; |
| 930 | |
| 931 | driver->m_cpu = machine.device("maincpu"); |
| 932 | driver->m_tms9901 = static_cast<tms9901_device*>(machine.device(TMS9901_TAG)); |
| 933 | |
| 934 | driver->m_gromport = static_cast<gromport_device*>(machine.device(GROMPORT_TAG)); |
| 935 | |
| 936 | driver->m_peribox = static_cast<peribox_device*>(machine.device(PERIBOX_TAG)); |
| 937 | |
| 938 | driver->m_peribox->senila(CLEAR_LINE); |
| 939 | driver->m_peribox->senilb(CLEAR_LINE); |
| 821 | 940 | } |
| 822 | 941 | |
| 823 | | MACHINE_RESET( ti99_4a ) |
| 942 | MACHINE_RESET( ti99_4 ) |
| 824 | 943 | { |
| 944 | ti99_4x *driver = machine.driver_data<ti99_4x>(); |
| 945 | if (input_port_read(machine, "HANDSET")==0x01) |
| 946 | driver->m_handset = static_cast<ti99_handset_device*>(machine.device(HANDSET_TAG)); |
| 947 | else |
| 948 | driver->m_handset = NULL; |
| 949 | |
| 950 | if (input_port_read(machine, "MECMOUSE")==0x01) |
| 951 | driver->m_mecmouse = static_cast<mecmouse_device*>(machine.device(MECMOUSE_TAG)); |
| 952 | else |
| 953 | driver->m_mecmouse = NULL; |
| 825 | 954 | } |
| 826 | 955 | |
| 827 | | static MACHINE_CONFIG_START( ti99_4_60hz, ti99_4x_state ) |
| 828 | | /* basic machine hardware */ |
| 829 | | /* TMS9900 CPU @ 3.0 MHz */ |
| 956 | /* |
| 957 | TI-99/4 - the predecessor of the more popular TI-99/4A |
| 958 | */ |
| 959 | static MACHINE_CONFIG_START( ti99_4_60hz, ti99_4x ) |
| 830 | 960 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 831 | 961 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 832 | 962 | MCFG_CPU_IO_MAP(cru_map) |
| 833 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 834 | | |
| 963 | MCFG_MACHINE_START( ti99_4 ) |
| 835 | 964 | MCFG_MACHINE_RESET( ti99_4 ) |
| 836 | 965 | |
| 837 | | /* video hardware */ |
| 838 | | // MCFG_FRAGMENT_ADD(tms9928a) |
| 839 | | // MCFG_SCREEN_MODIFY("screen") |
| 840 | | // MCFG_SCREEN_REFRESH_RATE(60) |
| 841 | | // MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 966 | MCFG_TI_TMS991x_ADD_NTSC(VIDEO_SYSTEM_TAG, TMS9118, ti99_4_tms9928a_interface) |
| 842 | 967 | |
| 843 | | MCFG_TI_TMS991x_ADD_NTSC("video", TMS9118, ti99_4_tms9928a_interface) |
| 844 | | MCFG_GFXDECODE(ti99) |
| 968 | /* Main board */ |
| 969 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4, 3000000) |
| 970 | MCFG_DMUX_ADD( DATAMUX_TAG, dmux_devices ) |
| 971 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 845 | 972 | |
| 973 | /* Peripheral expansion box */ |
| 974 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 975 | |
| 846 | 976 | /* sound hardware */ |
| 847 | 977 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 848 | | MCFG_SOUND_ADD("soundgen", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 978 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 849 | 979 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 980 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 850 | 981 | |
| 982 | /* Cassette drives */ |
| 983 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 984 | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 985 | |
| 851 | 986 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 852 | 987 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 853 | 988 | |
| 854 | | MCFG_TI994_BOARD_ADD( "ti_board" ) |
| 989 | /* GROM devices */ |
| 990 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 991 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 992 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 855 | 993 | |
| 856 | | /* tms9901 */ |
| 857 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4) |
| 994 | /* User controller */ |
| 995 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 60 ) |
| 996 | MCFG_HANDSET_ADD( HANDSET_TAG, ti99_4_handset_interface, 60 ) |
| 858 | 997 | |
| 859 | | MCFG_CRUBUS_ADD( "crubus", cru_devices ) |
| 860 | | MCFG_DMUX_ADD( "datamux_16_8", dmux_devices ) |
| 861 | 998 | |
| 862 | | MCFG_GROM_ADD( "console_grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 863 | | MCFG_GROM_ADD( "console_grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 864 | | MCFG_GROM_ADD( "console_grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 865 | | |
| 866 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 867 | | |
| 868 | | MCFG_PBOX4_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 869 | | |
| 870 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 871 | | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 872 | | |
| 873 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 874 | | MCFG_HANDSET_ADD( "handset", "tms9901" ) |
| 875 | 999 | MACHINE_CONFIG_END |
| 876 | 1000 | |
| 877 | | static MACHINE_CONFIG_START( ti99_4_50hz, ti99_4x_state ) |
| 878 | | /* basic machine hardware */ |
| 879 | | /* TMS9900 CPU @ 3.0 MHz */ |
| 1001 | static MACHINE_CONFIG_START( ti99_4_50hz, ti99_4x ) |
| 880 | 1002 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 881 | 1003 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 882 | 1004 | MCFG_CPU_IO_MAP(cru_map) |
| 883 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 884 | | |
| 1005 | MCFG_MACHINE_START( ti99_4 ) |
| 885 | 1006 | MCFG_MACHINE_RESET( ti99_4 ) |
| 886 | 1007 | |
| 887 | 1008 | /* video hardware */ |
| 888 | | MCFG_TI_TMS991x_ADD_PAL("video", TMS9929, ti99_4, ti99_4_tms9928a_interface) |
| 1009 | MCFG_TI_TMS991x_ADD_PAL(VIDEO_SYSTEM_TAG, TMS9929, ti99_4_tms9928a_interface) |
| 889 | 1010 | |
| 890 | | MCFG_GFXDECODE(ti99) |
| 1011 | /* main board */ |
| 1012 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4, 3000000) |
| 1013 | MCFG_DMUX_ADD( DATAMUX_TAG, dmux_devices ) |
| 1014 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 891 | 1015 | |
| 1016 | /* Peripheral expansion box */ |
| 1017 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 1018 | |
| 892 | 1019 | /* sound hardware */ |
| 893 | 1020 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 894 | | MCFG_SOUND_ADD("soundgen", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 1021 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 895 | 1022 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 1023 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 896 | 1024 | |
| 1025 | /* Cassette drives */ |
| 1026 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1027 | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1028 | |
| 897 | 1029 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 898 | 1030 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 899 | 1031 | |
| 900 | | MCFG_TI994_BOARD_ADD( "ti_board" ) |
| 1032 | /* GROM devices */ |
| 1033 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 1034 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 1035 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 901 | 1036 | |
| 902 | | /* tms9901 */ |
| 903 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4) |
| 1037 | /* User controller */ |
| 1038 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 50 ) |
| 1039 | MCFG_HANDSET_ADD( HANDSET_TAG, ti99_4_handset_interface, 50 ) |
| 1040 | MACHINE_CONFIG_END |
| 904 | 1041 | |
| 905 | | MCFG_CRUBUS_ADD( "crubus", cru_devices ) |
| 906 | | MCFG_DMUX_ADD( "datamux_16_8", dmux_devices ) |
| 1042 | /* |
| 1043 | TI-99/4A - replaced the 99/4 |
| 1044 | */ |
| 907 | 1045 | |
| 908 | | MCFG_GROM_ADD( "console_grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 909 | | MCFG_GROM_ADD( "console_grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 910 | | MCFG_GROM_ADD( "console_grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 1046 | MACHINE_START( ti99_4a ) |
| 1047 | { |
| 1048 | ti99_4x *driver = machine.driver_data<ti99_4x>(); |
| 1049 | driver->m_mode = TI994A; |
| 911 | 1050 | |
| 912 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 1051 | driver->m_cpu = machine.device("maincpu"); |
| 1052 | driver->m_tms9901 = static_cast<tms9901_device*>(machine.device(TMS9901_TAG)); |
| 913 | 1053 | |
| 914 | | MCFG_PBOX4_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 1054 | driver->m_mecmouse = static_cast<mecmouse_device*>(machine.device(MECMOUSE_TAG)); |
| 1055 | driver->m_gromport = static_cast<gromport_device*>(machine.device(GROMPORT_TAG)); |
| 1056 | driver->m_peribox = static_cast<peribox_device*>(machine.device(PERIBOX_TAG)); |
| 915 | 1057 | |
| 916 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 917 | | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1058 | driver->m_peribox->senila(CLEAR_LINE); |
| 1059 | driver->m_peribox->senilb(CLEAR_LINE); |
| 1060 | } |
| 918 | 1061 | |
| 919 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 920 | | MCFG_HANDSET_ADD( "handset", "tms9901" ) |
| 921 | | MACHINE_CONFIG_END |
| 1062 | MACHINE_RESET( ti99_4a ) |
| 1063 | { |
| 1064 | ti99_4x *driver = machine.driver_data<ti99_4x>(); |
| 1065 | if (input_port_read(machine, "MECMOUSE")==0x01) |
| 1066 | driver->m_mecmouse = static_cast<mecmouse_device*>(machine.device(MECMOUSE_TAG)); |
| 1067 | else |
| 1068 | driver->m_mecmouse = NULL; |
| 1069 | } |
| 922 | 1070 | |
| 923 | | static MACHINE_CONFIG_START( ti99_4a_60hz, ti99_4x_state ) |
| 924 | | /* basic machine hardware */ |
| 925 | | /* TMS9900 CPU @ 3.0 MHz */ |
| 1071 | static MACHINE_CONFIG_START( ti99_4a_60hz, ti99_4x ) |
| 926 | 1072 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 927 | 1073 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 928 | 1074 | MCFG_CPU_IO_MAP(cru_map) |
| 929 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 930 | | |
| 1075 | MCFG_MACHINE_START( ti99_4a ) |
| 931 | 1076 | MCFG_MACHINE_RESET( ti99_4a ) |
| 932 | 1077 | |
| 933 | | /* video hardware */ |
| 934 | | MCFG_TI_TMS991x_ADD_NTSC("video", TMS9918A, ti99_4_tms9928a_interface) |
| 935 | | MCFG_GFXDECODE(ti99a) |
| 1078 | /* Video hardware */ |
| 1079 | MCFG_TI_TMS991x_ADD_NTSC(VIDEO_SYSTEM_TAG, TMS9918A, ti99_4_tms9928a_interface) |
| 936 | 1080 | |
| 1081 | /* Main board */ |
| 1082 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4a, 3000000) |
| 1083 | MCFG_DMUX_ADD( DATAMUX_TAG, dmux_devices ) |
| 1084 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 1085 | |
| 1086 | /* Peripheral expansion box */ |
| 1087 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 1088 | |
| 937 | 1089 | /* sound hardware */ |
| 938 | 1090 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 939 | | MCFG_SOUND_ADD("soundgen", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 1091 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 940 | 1092 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 1093 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 941 | 1094 | |
| 1095 | /* Cassette drives */ |
| 1096 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1097 | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1098 | |
| 942 | 1099 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 943 | 1100 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 944 | 1101 | |
| 945 | | MCFG_TI994A_BOARD_ADD( "ti_board" ) |
| 1102 | /* GROM devices */ |
| 1103 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 1104 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 1105 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 946 | 1106 | |
| 947 | | /* tms9901 */ |
| 948 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4a) |
| 949 | | |
| 950 | | MCFG_CRUBUS_ADD( "crubus", cru_devices ) |
| 951 | | MCFG_DMUX_ADD( "datamux_16_8", dmux_devices ) |
| 952 | | |
| 953 | | MCFG_GROM_ADD( "console_grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 954 | | MCFG_GROM_ADD( "console_grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 955 | | MCFG_GROM_ADD( "console_grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 956 | | |
| 957 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 958 | | |
| 959 | | MCFG_PBOX4A_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 960 | | |
| 961 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 962 | | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 963 | | |
| 964 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 1107 | /* User controller */ |
| 1108 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 60 ) |
| 965 | 1109 | MACHINE_CONFIG_END |
| 966 | 1110 | |
| 967 | | static MACHINE_CONFIG_START( ti99_4a_50hz, ti99_4x_state ) |
| 968 | | /* basic machine hardware */ |
| 969 | | /* TMS9900 CPU @ 3.0 MHz */ |
| 1111 | static MACHINE_CONFIG_START( ti99_4a_50hz, ti99_4x ) |
| 970 | 1112 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 971 | 1113 | MCFG_CPU_PROGRAM_MAP(memmap) |
| 972 | 1114 | MCFG_CPU_IO_MAP(cru_map) |
| 973 | | MCFG_CPU_VBLANK_INT("screen", ti99_vblank_interrupt) |
| 974 | | |
| 1115 | MCFG_MACHINE_START( ti99_4a ) |
| 975 | 1116 | MCFG_MACHINE_RESET( ti99_4a ) |
| 976 | 1117 | |
| 977 | | /* video hardware */ |
| 978 | | MCFG_TI_TMS991x_ADD_PAL("video", TMS9929A, ti99_4, ti99_4_tms9928a_interface) |
| 979 | | MCFG_GFXDECODE(ti99a) |
| 1118 | /* Video hardware */ |
| 1119 | MCFG_TI_TMS991x_ADD_PAL(VIDEO_SYSTEM_TAG, TMS9929A, ti99_4_tms9928a_interface) |
| 980 | 1120 | |
| 1121 | /* Main board */ |
| 1122 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4a, 3000000) |
| 1123 | MCFG_DMUX_ADD( DATAMUX_TAG, dmux_devices ) |
| 1124 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 1125 | |
| 1126 | /* Peripheral expansion box */ |
| 1127 | MCFG_PERIBOX_ADD( PERIBOX_TAG, peribox_conf ) |
| 1128 | |
| 981 | 1129 | /* sound hardware */ |
| 982 | 1130 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 983 | | MCFG_SOUND_ADD("soundgen", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 1131 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 984 | 1132 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 1133 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 985 | 1134 | |
| 1135 | /* Cassette drives */ |
| 1136 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1137 | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1138 | |
| 986 | 1139 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 987 | 1140 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 988 | 1141 | |
| 989 | | MCFG_TI994A_BOARD_ADD( "ti_board" ) |
| 1142 | /* GROM devices */ |
| 1143 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 1144 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 1145 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 990 | 1146 | |
| 991 | | /* tms9901 */ |
| 992 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4a) |
| 1147 | /* User controller */ |
| 1148 | MCFG_MECMOUSE_ADD( MECMOUSE_TAG, 50 ) |
| 1149 | MACHINE_CONFIG_END |
| 993 | 1150 | |
| 994 | | MCFG_CRUBUS_ADD( "crubus", cru_devices ) |
| 995 | | MCFG_DMUX_ADD( "datamux_16_8", dmux_devices ) |
| 996 | 1151 | |
| 997 | | MCFG_GROM_ADD( "console_grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 998 | | MCFG_GROM_ADD( "console_grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 999 | | MCFG_GROM_ADD( "console_grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 1000 | | |
| 1001 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 1002 | | |
| 1003 | | MCFG_PBOX4A_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 1004 | | |
| 1005 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1006 | | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1007 | | |
| 1008 | | MCFG_MECMOUSE_ADD( "mecmouse" ) |
| 1009 | | MACHINE_CONFIG_END |
| 1010 | | |
| 1011 | 1152 | TIMER_DEVICE_CALLBACK( ti99_4ev_hblank_interrupt ) |
| 1012 | 1153 | { |
| 1013 | | timer.machine().device<v9938_device>("video_v9938")->interrupt(); |
| 1154 | timer.machine().device<v9938_device>(V9938_TAG)->interrupt(); |
| 1014 | 1155 | } |
| 1015 | 1156 | |
| 1016 | | static MACHINE_CONFIG_START( ti99_4ev_60hz, ti99_4x_state ) |
| 1017 | | /* basic machine hardware */ |
| 1018 | | /* TMS9900 CPU @ 3.0 MHz */ |
| 1157 | /* |
| 1158 | TI-99/4A with 80-column support. Actually a separate expansion card (EVPC), |
| 1159 | replacing the console video processor. |
| 1160 | */ |
| 1161 | static MACHINE_CONFIG_START( ti99_4ev_60hz, ti99_4x ) |
| 1019 | 1162 | MCFG_CPU_ADD("maincpu", TMS9900, 3000000) |
| 1020 | 1163 | MCFG_CPU_PROGRAM_MAP(memmap_4ev) |
| 1021 | 1164 | MCFG_CPU_IO_MAP(cru_map) |
| 1022 | | MCFG_TIMER_ADD_SCANLINE("scantimer", ti99_4ev_hblank_interrupt, "screen", 0, 1) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 1165 | MCFG_MACHINE_START( ti99_4a ) |
| 1023 | 1166 | |
| 1024 | | MCFG_MACHINE_RESET( ti99_4a ) |
| 1167 | /* Video hardware */ |
| 1168 | // FIXME: (MZ) Lowered the screen rate to 30 Hz. This is a quick hack to |
| 1169 | // restore normal video speed for V9938-based systems until the V9938 implementation |
| 1170 | // is properly fixed. |
| 1171 | MCFG_TI_V9938_ADD(VIDEO_SYSTEM_TAG, 30, SCREEN_TAG, 2500, 512+32, (212+28)*2, DEVICE_SELF, ti99_4x, set_tms9901_INT2_from_v9938) |
| 1172 | MCFG_TIMER_ADD_SCANLINE("scantimer", ti99_4ev_hblank_interrupt, SCREEN_TAG, 0, 1) |
| 1025 | 1173 | |
| 1026 | | /* video hardware */ |
| 1027 | | /* FIXME: (MZ) Lowered the screen rate to 30 Hz. This is a quick hack to |
| 1028 | | restore normal video speed for V9938-based systems until the V9938 implementation |
| 1029 | | is properly fixed. */ |
| 1030 | | MCFG_TI_V9938_ADD("video", 30, "screen", 2500, 512+32, (212+28)*2, tms9901_set_int2_v9938) |
| 1174 | /* Main board */ |
| 1175 | MCFG_TMS9901_ADD(TMS9901_TAG, tms9901_wiring_ti99_4a, 3000000) |
| 1176 | MCFG_DMUX_ADD( DATAMUX_TAG, dmux_devices ) |
| 1177 | MCFG_TI99_GROMPORT_ADD( GROMPORT_TAG, console_cartslot ) |
| 1031 | 1178 | |
| 1032 | | MCFG_GFXDECODE(ti99b) |
| 1179 | /* Peripheral expansion box */ |
| 1180 | MCFG_PERIBOX_EV_ADD( PERIBOX_TAG, peribox_conf ) |
| 1033 | 1181 | |
| 1034 | 1182 | /* sound hardware */ |
| 1035 | 1183 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 1036 | | MCFG_SOUND_ADD("soundgen", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 1184 | MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */ |
| 1037 | 1185 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 1186 | MCFG_TI_SOUND_ADD( TISOUND_TAG ) |
| 1038 | 1187 | |
| 1188 | /* Cassette drives */ |
| 1189 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1190 | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1191 | |
| 1039 | 1192 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 1040 | 1193 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 1041 | 1194 | |
| 1042 | | MCFG_TI994A_BOARD_ADD( "ti_board" ) |
| 1195 | /* GROM devices */ |
| 1196 | MCFG_GROM_ADD( GROM0_TAG, grom0_config ) |
| 1197 | MCFG_GROM_ADD( GROM1_TAG, grom1_config ) |
| 1198 | MCFG_GROM_ADD( GROM2_TAG, grom2_config ) |
| 1199 | MACHINE_CONFIG_END |
| 1043 | 1200 | |
| 1044 | | MCFG_TMS9901_ADD("tms9901", tms9901_wiring_ti99_4a) |
| 1045 | 1201 | |
| 1046 | | MCFG_CRUBUS_ADD( "crubus", cru_devices ) |
| 1047 | | MCFG_DMUX_ADD( "datamux_16_8", dmux_devices ) |
| 1048 | | |
| 1049 | | MCFG_GROM_ADD( "console_grom_0", 0, region_grom, 0x0000, 0x1800, console_ready ) |
| 1050 | | MCFG_GROM_ADD( "console_grom_1", 1, region_grom, 0x2000, 0x1800, console_ready ) |
| 1051 | | MCFG_GROM_ADD( "console_grom_2", 2, region_grom, 0x4000, 0x1800, console_ready ) |
| 1052 | | |
| 1053 | | MCFG_TI99_GROMPORT_ADD( "gromport", console_ready ) |
| 1054 | | |
| 1055 | | MCFG_PBOXEV_ADD( "peribox", console_extint, console_notconnected, console_ready ) |
| 1056 | | |
| 1057 | | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 1058 | | MCFG_CASSETTE_ADD( CASSETTE2_TAG, default_cassette_interface ) |
| 1059 | | MACHINE_CONFIG_END |
| 1060 | | |
| 1061 | | /* |
| 1202 | /***************************************************************************** |
| 1062 | 1203 | ROM loading |
| 1063 | 1204 | Note that we use the same ROMset for 50Hz and 60Hz versions. |
| 1064 | 1205 | ROMs for peripheral equipment have been moved to the respective files. |
| 1065 | | */ |
| 1206 | ******************************************************************************/ |
| 1207 | #define rom_ti99_4e rom_ti99_4 |
| 1208 | #define rom_ti99_4ae rom_ti99_4a |
| 1066 | 1209 | |
| 1067 | 1210 | ROM_START(ti99_4) |
| 1068 | 1211 | /*CPU memory space*/ |
| r14513 | r14514 | |
| 1074 | 1217 | ROM_REGION(0x10000, region_grom, 0) |
| 1075 | 1218 | ROM_LOAD("u500.bin", 0x0000, 0x1800, CRC(aa757e13) SHA1(4658d3d01c0131c283a30cebd12e76754d41a84a)) /* system GROM 0 */ |
| 1076 | 1219 | ROM_LOAD("u501.bin", 0x2000, 0x1800, CRC(c863e460) SHA1(6d849a76011273a069a98ed0c3feaf13831c942f)) /* system GROM 1 */ |
| 1077 | | ROM_LOAD("u502.bin", 0x4000, 0x1800, CRC(b0eda548) SHA1(725e3f26f8c819f356e4bb405b4102b5ae1e0e70)) /* system GROM 1 */ |
| 1220 | ROM_LOAD("u502.bin", 0x4000, 0x1800, CRC(b0eda548) SHA1(725e3f26f8c819f356e4bb405b4102b5ae1e0e70)) /* system GROM 2 */ |
| 1078 | 1221 | ROM_END |
| 1079 | 1222 | |
| 1080 | 1223 | ROM_START(ti99_4a) |
| r14513 | r14514 | |
| 1097 | 1240 | ROM_LOAD("994agr38.bin", 0x0000, 0x6000, CRC(bdd9f09b) SHA1(9b058a55d2528d2a6a69d7081aa296911ed7c0de)) /* system GROMs */ |
| 1098 | 1241 | ROM_END |
| 1099 | 1242 | |
| 1100 | | #define rom_ti99_4e rom_ti99_4 |
| 1101 | | #define rom_ti99_4ae rom_ti99_4a |
| 1102 | | |
| 1103 | 1243 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 1104 | 1244 | COMP( 1979, ti99_4, 0, 0, ti99_4_60hz, ti99_4, 0, "Texas Instruments", "TI99/4 Home Computer (US)" , 0) |
| 1105 | 1245 | COMP( 1980, ti99_4e, ti99_4, 0, ti99_4_50hz, ti99_4, 0, "Texas Instruments", "TI99/4 Home Computer (Europe)" , 0) |
| 1106 | 1246 | COMP( 1981, ti99_4a, 0, 0, ti99_4a_60hz, ti99_4a, 0, "Texas Instruments", "TI99/4A Home Computer (US)" , 0) |
| 1107 | 1247 | COMP( 1981, ti99_4ae, ti99_4a, 0, ti99_4a_50hz, ti99_4a, 0, "Texas Instruments", "TI99/4A Home Computer (Europe)" , 0) |
| 1108 | | COMP( 1994, ti99_4ev, ti99_4a, 0, ti99_4ev_60hz,ti99_4ev, 0, "Texas Instruments", "TI99/4A Home Computer with EVPC" , 0) |
| 1248 | COMP( 1994, ti99_4ev, ti99_4a, 0, ti99_4ev_60hz,ti99_4a, 0, "Texas Instruments", "TI99/4A Home Computer with EVPC" , 0) |