trunk/src/mame/drivers/gammagic.c
| r0 | r18204 | |
| 1 | /************************************************************************************ |
| 2 | |
| 3 | Game Magic (c) 1997 Bally Gaming Co. |
| 4 | |
| 5 | Preliminary driver by Grull Osgo |
| 6 | |
| 7 | Game Magic |
| 8 | |
| 9 | Is a Mutigame machine build on a Bally's V8000 platform. |
| 10 | |
| 11 | This is the first PC based gaming machine developed by Bally Gaming. |
| 12 | |
| 13 | V8000 platform includes: |
| 14 | |
| 15 | 1 Motherboard MICRONICS M55Hi-Plus PCI/ISA, Chipset INTEL i430HX (TRITON II), 64 MB Ram (4 SIMM M x 16 MB SIMM) |
| 16 | On board Sound Blaster Vibra 16C chipset. |
| 17 | 1 TOSHIBA CD-ROM or DVD-ROM Drive w/Bootable CD-ROM with Game. |
| 18 | 1 OAK SVGA PCI Video Board. |
| 19 | 1 Voodoo Graphics PCI Video Board, connected to the monitor. |
| 20 | 1 21" SVGA Color Monitor, 16x9 Aspect, Vertical mount, with touchscreen. |
| 21 | 1 Bally's IO-Board, Based on 68000 procesor as interface to all gaming devices |
| 22 | (Buttons, Lamps, Switches, Coin acceptor, Bill Validator, Hopper, Touchscreen, etc...) |
| 23 | |
| 24 | PC and IO-Board communicates via RS-232 Serial Port. |
| 25 | |
| 26 | Additional CD-ROM games: "99 Bottles of Beer" |
| 27 | |
| 28 | *************************************************************************************/ |
| 29 | |
| 30 | #include "emu.h" |
| 31 | #include "cpu/i386/i386.h" |
| 32 | #include "machine/cr589.h" |
| 33 | #include "machine/8237dma.h" |
| 34 | #include "machine/pic8259.h" |
| 35 | //#include "machine/i82371sb.h" |
| 36 | //#include "machine/i82439tx.h" |
| 37 | #include "machine/pit8253.h" |
| 38 | #include "machine/mc146818.h" |
| 39 | #include "machine/pcshare.h" |
| 40 | #include "machine/pci.h" |
| 41 | #include "machine/8042kbdc.h" |
| 42 | #include "machine/pckeybrd.h" |
| 43 | #include "video/pc_vga.h" |
| 44 | |
| 45 | #define ATAPI_CYCLES_PER_SECTOR (5000) // plenty of time to allow DMA setup etc. BIOS requires this be at least 2000, individual games may vary. |
| 46 | |
| 47 | #define ATAPI_ERRFEAT_ABRT 0x04 |
| 48 | |
| 49 | #define ATAPI_STAT_BSY 0x80 |
| 50 | #define ATAPI_STAT_DRDY 0x40 |
| 51 | #define ATAPI_STAT_DMARDDF 0x20 |
| 52 | #define ATAPI_STAT_SERVDSC 0x10 |
| 53 | #define ATAPI_STAT_DRQ 0x08 |
| 54 | #define ATAPI_STAT_CORR 0x04 |
| 55 | #define ATAPI_STAT_CHECK 0x01 |
| 56 | |
| 57 | #define ATAPI_INTREASON_COMMAND 0x01 |
| 58 | #define ATAPI_INTREASON_IO 0x02 |
| 59 | #define ATAPI_INTREASON_RELEASE 0x04 |
| 60 | |
| 61 | #define ATAPI_REG_DATA 0 |
| 62 | #define ATAPI_REG_ERRFEAT 1 |
| 63 | #define ATAPI_REG_INTREASON 2 |
| 64 | #define ATAPI_REG_SAMTAG 3 |
| 65 | #define ATAPI_REG_COUNTLOW 4 |
| 66 | #define ATAPI_REG_COUNTHIGH 5 |
| 67 | #define ATAPI_REG_DRIVESEL 6 |
| 68 | #define ATAPI_REG_CMDSTATUS 7 |
| 69 | #define ATAPI_REG_MAX 16 |
| 70 | |
| 71 | #define ATAPI_DATA_SIZE ( 64 * 1024 ) |
| 72 | |
| 73 | #define MAX_TRANSFER_SIZE ( 63488 ) |
| 74 | |
| 75 | class gammagic_state : public driver_device |
| 76 | { |
| 77 | public: |
| 78 | gammagic_state(const machine_config &mconfig, device_type type, const char *tag) |
| 79 | : driver_device(mconfig, type, tag) |
| 80 | { } |
| 81 | |
| 82 | int m_dma_channel; |
| 83 | UINT8 m_dma_offset[2][4]; |
| 84 | UINT8 m_at_pages[0x10]; |
| 85 | |
| 86 | device_t *m_pit8254; |
| 87 | device_t *m_pic8259_1; |
| 88 | device_t *m_pic8259_2; |
| 89 | device_t *m_dma8237_1; |
| 90 | device_t *m_dma8237_2; |
| 91 | |
| 92 | emu_timer *m_atapi_timer; |
| 93 | //SCSIInstance *m_inserted_cdrom; |
| 94 | |
| 95 | int m_atapi_data_ptr; |
| 96 | int m_atapi_data_len; |
| 97 | int m_atapi_xferlen; |
| 98 | int m_atapi_xferbase; |
| 99 | int m_atapi_cdata_wait; |
| 100 | int m_atapi_xfermod; |
| 101 | /* memory */ |
| 102 | UINT8 m_atapi_regs[ATAPI_REG_MAX]; |
| 103 | UINT8 m_atapi_data[ATAPI_DATA_SIZE]; |
| 104 | |
| 105 | DECLARE_DRIVER_INIT(gammagic); |
| 106 | DECLARE_READ8_MEMBER(vga_setting); |
| 107 | }; |
| 108 | |
| 109 | //static void atapi_irq(running_machine &machine, int state); |
| 110 | |
| 111 | static READ8_DEVICE_HANDLER(at_dma8237_2_r) |
| 112 | { |
| 113 | return i8237_r(device, space, offset / 2); |
| 114 | } |
| 115 | |
| 116 | static WRITE8_DEVICE_HANDLER(at_dma8237_2_w) |
| 117 | { |
| 118 | i8237_w(device, space, offset / 2, data); |
| 119 | } |
| 120 | |
| 121 | static READ8_HANDLER(at_page8_r) |
| 122 | { |
| 123 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 124 | UINT8 data = state->m_at_pages[offset % 0x10]; |
| 125 | |
| 126 | switch(offset % 8) { |
| 127 | case 1: |
| 128 | data = state->m_dma_offset[(offset / 8) & 1][2]; |
| 129 | break; |
| 130 | case 2: |
| 131 | data = state->m_dma_offset[(offset / 8) & 1][3]; |
| 132 | break; |
| 133 | case 3: |
| 134 | data = state->m_dma_offset[(offset / 8) & 1][1]; |
| 135 | break; |
| 136 | case 7: |
| 137 | data = state->m_dma_offset[(offset / 8) & 1][0]; |
| 138 | break; |
| 139 | } |
| 140 | return data; |
| 141 | } |
| 142 | |
| 143 | static WRITE8_HANDLER(at_page8_w) |
| 144 | { |
| 145 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 146 | state->m_at_pages[offset % 0x10] = data; |
| 147 | |
| 148 | switch(offset % 8) { |
| 149 | case 1: |
| 150 | state->m_dma_offset[(offset / 8) & 1][2] = data; |
| 151 | break; |
| 152 | case 2: |
| 153 | state->m_dma_offset[(offset / 8) & 1][3] = data; |
| 154 | break; |
| 155 | case 3: |
| 156 | state->m_dma_offset[(offset / 8) & 1][1] = data; |
| 157 | break; |
| 158 | case 7: |
| 159 | state->m_dma_offset[(offset / 8) & 1][0] = data; |
| 160 | break; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed ) |
| 165 | { |
| 166 | device->machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); |
| 167 | |
| 168 | /* Assert HLDA */ |
| 169 | i8237_hlda_w( device, state ); |
| 170 | } |
| 171 | |
| 172 | static READ8_HANDLER( pc_dma_read_byte ) |
| 173 | { |
| 174 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 175 | offs_t page_offset = (((offs_t) state->m_dma_offset[0][state->m_dma_channel]) << 16) |
| 176 | & 0xFF0000; |
| 177 | |
| 178 | return space.read_byte(page_offset + offset); |
| 179 | } |
| 180 | |
| 181 | static WRITE8_HANDLER( pc_dma_write_byte ) |
| 182 | { |
| 183 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 184 | offs_t page_offset = (((offs_t) state->m_dma_offset[0][state->m_dma_channel]) << 16) |
| 185 | & 0xFF0000; |
| 186 | |
| 187 | space.write_byte(page_offset + offset, data); |
| 188 | } |
| 189 | |
| 190 | static void set_dma_channel(device_t *device, int channel, int state) |
| 191 | { |
| 192 | gammagic_state *drvstate = device->machine().driver_data<gammagic_state>(); |
| 193 | if (!state) drvstate->m_dma_channel = channel; |
| 194 | } |
| 195 | |
| 196 | static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); } |
| 197 | static WRITE_LINE_DEVICE_HANDLER( pc_dack1_w ) { set_dma_channel(device, 1, state); } |
| 198 | static WRITE_LINE_DEVICE_HANDLER( pc_dack2_w ) { set_dma_channel(device, 2, state); } |
| 199 | static WRITE_LINE_DEVICE_HANDLER( pc_dack3_w ) { set_dma_channel(device, 3, state); } |
| 200 | |
| 201 | static I8237_INTERFACE( dma8237_1_config ) |
| 202 | { |
| 203 | DEVCB_LINE(pc_dma_hrq_changed), |
| 204 | DEVCB_NULL, |
| 205 | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_read_byte), |
| 206 | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_write_byte), |
| 207 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, |
| 208 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, |
| 209 | { DEVCB_LINE(pc_dack0_w), DEVCB_LINE(pc_dack1_w), DEVCB_LINE(pc_dack2_w), DEVCB_LINE(pc_dack3_w) } |
| 210 | }; |
| 211 | |
| 212 | static I8237_INTERFACE( dma8237_2_config ) |
| 213 | { |
| 214 | DEVCB_NULL, |
| 215 | DEVCB_NULL, |
| 216 | DEVCB_NULL, |
| 217 | DEVCB_NULL, |
| 218 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, |
| 219 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, |
| 220 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL } |
| 221 | }; |
| 222 | /* |
| 223 | static READ32_HANDLER( atapi_r ) |
| 224 | { |
| 225 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 226 | UINT8 *atapi_regs = state->m_atapi_regs; |
| 227 | //running_machine &machine = space.machine(); |
| 228 | int reg, data; |
| 229 | |
| 230 | if (mem_mask == 0x0000ffff) // word-wide command read |
| 231 | { |
| 232 | logerror("ATAPI: packet read = %04x\n", state->m_atapi_data[state->m_atapi_data_ptr]); |
| 233 | |
| 234 | // assert IRQ and drop DRQ |
| 235 | if (state->m_atapi_data_ptr == 0 && state->m_atapi_data_len == 0) |
| 236 | { |
| 237 | // get the data from the device |
| 238 | if( state->m_atapi_xferlen > 0 ) |
| 239 | { |
| 240 | SCSIReadData( state->m_inserted_cdrom, state->m_atapi_data, state->m_atapi_xferlen ); |
| 241 | state->m_atapi_data_len = state->m_atapi_xferlen; |
| 242 | } |
| 243 | |
| 244 | if (state->m_atapi_xfermod > MAX_TRANSFER_SIZE) |
| 245 | { |
| 246 | state->m_atapi_xferlen = MAX_TRANSFER_SIZE; |
| 247 | state->m_atapi_xfermod = state->m_atapi_xfermod - MAX_TRANSFER_SIZE; |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | state->m_atapi_xferlen = state->m_atapi_xfermod; |
| 252 | state->m_atapi_xfermod = 0; |
| 253 | } |
| 254 | |
| 255 | //verboselog\\( machine, 2, "atapi_r: atapi_xferlen=%d\n", state->m_atapi_xferlen ); |
| 256 | if( state->m_atapi_xferlen != 0 ) |
| 257 | { |
| 258 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC; |
| 259 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; |
| 260 | } |
| 261 | else |
| 262 | { |
| 263 | logerror("ATAPI: dropping DRQ\n"); |
| 264 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 265 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; |
| 266 | } |
| 267 | |
| 268 | atapi_regs[ATAPI_REG_COUNTLOW] = state->m_atapi_xferlen & 0xff; |
| 269 | atapi_regs[ATAPI_REG_COUNTHIGH] = (state->m_atapi_xferlen>>8)&0xff; |
| 270 | |
| 271 | atapi_irq(space.machine(), ASSERT_LINE); |
| 272 | } |
| 273 | |
| 274 | if( state->m_atapi_data_ptr < state->m_atapi_data_len ) |
| 275 | { |
| 276 | data = state->m_atapi_data[state->m_atapi_data_ptr++]; |
| 277 | data |= ( state->m_atapi_data[state->m_atapi_data_ptr++] << 8 ); |
| 278 | if( state->m_atapi_data_ptr >= state->m_atapi_data_len ) |
| 279 | { |
| 280 | |
| 281 | state->m_atapi_data_ptr = 0; |
| 282 | state->m_atapi_data_len = 0; |
| 283 | |
| 284 | if( state->m_atapi_xferlen == 0 ) |
| 285 | { |
| 286 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 287 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; |
| 288 | atapi_irq(space.machine(), ASSERT_LINE); |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | data = 0; |
| 295 | } |
| 296 | } |
| 297 | else |
| 298 | { |
| 299 | atapi_irq(space.machine(), CLEAR_LINE); |
| 300 | int shift; |
| 301 | shift = 0; |
| 302 | reg = offset<<2; |
| 303 | switch(mem_mask) |
| 304 | { |
| 305 | case 0x000000ff: |
| 306 | break; |
| 307 | case 0x0000ff00: |
| 308 | reg+=1; |
| 309 | data >>= 8; |
| 310 | shift=8; |
| 311 | break; |
| 312 | case 0x00ff0000: |
| 313 | reg+=2; |
| 314 | data >>=16; |
| 315 | shift=16; |
| 316 | break; |
| 317 | case 0xff000000: |
| 318 | reg+=3; |
| 319 | data >>=24; |
| 320 | shift=24; |
| 321 | break; |
| 322 | } |
| 323 | data = atapi_regs[reg]; |
| 324 | data <<= shift; |
| 325 | } |
| 326 | return data; |
| 327 | } |
| 328 | |
| 329 | static WRITE32_HANDLER( atapi_w ) |
| 330 | { |
| 331 | gammagic_state *state = space.machine().driver_data<gammagic_state>(); |
| 332 | UINT8 *atapi_regs = state->m_atapi_regs; |
| 333 | UINT8 *atapi_data = state->m_atapi_data; |
| 334 | int reg; |
| 335 | if (mem_mask == 0x0000ffff) // word-wide command write |
| 336 | { |
| 337 | atapi_data[state->m_atapi_data_ptr++] = data & 0xff; |
| 338 | atapi_data[state->m_atapi_data_ptr++] = data >> 8; |
| 339 | |
| 340 | if (state->m_atapi_cdata_wait) |
| 341 | { |
| 342 | logerror("ATAPI: waiting, ptr %d wait %d\n", state->m_atapi_data_ptr, state->m_atapi_cdata_wait); |
| 343 | if (state->m_atapi_data_ptr == state->m_atapi_cdata_wait) |
| 344 | { |
| 345 | // send it to the device |
| 346 | SCSIWriteData( state->m_inserted_cdrom, atapi_data, state->m_atapi_cdata_wait ); |
| 347 | |
| 348 | // assert IRQ |
| 349 | atapi_irq(space.machine(), ASSERT_LINE); |
| 350 | |
| 351 | // not sure here, but clear DRQ at least? |
| 352 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | else if ( state->m_atapi_data_ptr == 12 ) |
| 357 | { |
| 358 | int phase; |
| 359 | // reset data pointer for reading SCSI results |
| 360 | state->m_atapi_data_ptr = 0; |
| 361 | state->m_atapi_data_len = 0; |
| 362 | |
| 363 | // send it to the SCSI device |
| 364 | SCSISetCommand( state->m_inserted_cdrom, state->m_atapi_data, 12 ); |
| 365 | SCSIExecCommand( state->m_inserted_cdrom, &state->m_atapi_xferlen ); |
| 366 | SCSIGetPhase( state->m_inserted_cdrom, &phase ); |
| 367 | |
| 368 | if (state->m_atapi_xferlen != -1) |
| 369 | { |
| 370 | logerror("ATAPI: SCSI command %02x returned %d bytes from the device\n", atapi_data[0]&0xff, state->m_atapi_xferlen); |
| 371 | |
| 372 | // store the returned command length in the ATAPI regs, splitting into |
| 373 | // multiple transfers if necessary |
| 374 | state->m_atapi_xfermod = 0; |
| 375 | if (state->m_atapi_xferlen > MAX_TRANSFER_SIZE) |
| 376 | { |
| 377 | state->m_atapi_xfermod = state->m_atapi_xferlen - MAX_TRANSFER_SIZE; |
| 378 | state->m_atapi_xferlen = MAX_TRANSFER_SIZE; |
| 379 | } |
| 380 | |
| 381 | atapi_regs[ATAPI_REG_COUNTLOW] = state->m_atapi_xferlen & 0xff; |
| 382 | atapi_regs[ATAPI_REG_COUNTHIGH] = (state->m_atapi_xferlen>>8)&0xff; |
| 383 | |
| 384 | if (state->m_atapi_xferlen == 0) |
| 385 | { |
| 386 | // if no data to return, set the registers properly |
| 387 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY; |
| 388 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO|ATAPI_INTREASON_COMMAND; |
| 389 | } |
| 390 | else |
| 391 | { |
| 392 | // indicate data ready: set DRQ and DMA ready, and IO in INTREASON |
| 393 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC; |
| 394 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; |
| 395 | } |
| 396 | |
| 397 | switch( phase ) |
| 398 | { |
| 399 | case SCSI_PHASE_DATAOUT: |
| 400 | state->m_atapi_cdata_wait = state->m_atapi_xferlen; |
| 401 | break; |
| 402 | } |
| 403 | |
| 404 | // perform special ATAPI processing of certain commands |
| 405 | switch (atapi_data[0]&0xff) |
| 406 | { |
| 407 | case 0x00: // BUS RESET / TEST UNIT READY |
| 408 | case 0xbb: // SET CDROM SPEED |
| 409 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 410 | break; |
| 411 | |
| 412 | case 0x45: // PLAY |
| 413 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY; |
| 414 | state->m_atapi_timer->adjust( downcast<cpu_device *>(&space->device())->cycles_to_attotime( ATAPI_CYCLES_PER_SECTOR ) ); |
| 415 | break; |
| 416 | } |
| 417 | |
| 418 | // assert IRQ |
| 419 | atapi_irq(space.machine(), ASSERT_LINE); |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | logerror("ATAPI: SCSI device returned error!\n"); |
| 424 | |
| 425 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_CHECK; |
| 426 | atapi_regs[ATAPI_REG_ERRFEAT] = 0x50; // sense key = ILLEGAL REQUEST |
| 427 | atapi_regs[ATAPI_REG_COUNTLOW] = 0; |
| 428 | atapi_regs[ATAPI_REG_COUNTHIGH] = 0; |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | else |
| 433 | { |
| 434 | reg = offset<<2; |
| 435 | switch(mem_mask) |
| 436 | { |
| 437 | case 0x000000ff: |
| 438 | break; |
| 439 | case 0x0000ff00: |
| 440 | reg+=1; |
| 441 | data >>= 8; |
| 442 | break; |
| 443 | case 0x00ff0000: |
| 444 | reg+=2; |
| 445 | data >>=16; |
| 446 | break; |
| 447 | case 0xff000000: |
| 448 | reg+=3; |
| 449 | data >>=24; |
| 450 | break; |
| 451 | } |
| 452 | |
| 453 | atapi_regs[reg] = data; |
| 454 | logerror("ATAPI: reg %d = %x (offset %x mask %x PC=%x)\n", reg, data, offset, mem_mask, cpu_get_pc(&space->device())); |
| 455 | |
| 456 | if (reg == ATAPI_REG_CMDSTATUS) |
| 457 | { |
| 458 | logerror("ATAPI command %x issued! (PC=%x)\n", data, cpu_get_pc(&space->device())); |
| 459 | switch (data) |
| 460 | { |
| 461 | case 0xa0: // PACKET |
| 462 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ; |
| 463 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_COMMAND; |
| 464 | |
| 465 | state->m_atapi_data_ptr = 0; |
| 466 | state->m_atapi_data_len = 0; |
| 467 | |
| 468 | // we have no data |
| 469 | state->m_atapi_xferlen = 0; |
| 470 | state->m_atapi_xfermod = 0; |
| 471 | |
| 472 | state->m_atapi_cdata_wait = 0; |
| 473 | break; |
| 474 | |
| 475 | case 0xa1: // IDENTIFY PACKET DEVICE |
| 476 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ; |
| 477 | |
| 478 | state->m_atapi_data_ptr = 0; |
| 479 | state->m_atapi_data_len = 512; |
| 480 | |
| 481 | // we have no data |
| 482 | state->m_atapi_xferlen = 0; |
| 483 | state->m_atapi_xfermod = 0; |
| 484 | |
| 485 | memset( atapi_data, 0, state->m_atapi_data_len ); |
| 486 | |
| 487 | atapi_data[ 0 ^ 1 ] = 0x85; // ATAPI device, cmd set 5 compliant, DRQ within 3 ms of PACKET command |
| 488 | atapi_data[ 1 ^ 1 ] = 0x80; // ATAPI device, removable media |
| 489 | |
| 490 | memset( &atapi_data[ 46 ], ' ', 8 ); |
| 491 | atapi_data[ 46 ^ 1 ] = '1'; |
| 492 | atapi_data[ 47 ^ 1 ] = '.'; |
| 493 | atapi_data[ 48 ^ 1 ] = '0'; |
| 494 | |
| 495 | |
| 496 | memset( &atapi_data[ 54 ], ' ', 40 ); |
| 497 | atapi_data[ 54 ^ 1 ] = 'T'; |
| 498 | atapi_data[ 55 ^ 1 ] = 'O'; |
| 499 | atapi_data[ 56 ^ 1 ] = 'S'; |
| 500 | atapi_data[ 57 ^ 1 ] = 'H'; |
| 501 | atapi_data[ 58 ^ 1 ] = 'I'; |
| 502 | atapi_data[ 59 ^ 1 ] = 'B'; |
| 503 | atapi_data[ 60 ^ 1 ] = 'A'; |
| 504 | atapi_data[ 61 ^ 1 ] = ' '; |
| 505 | atapi_data[ 62 ^ 1 ] = 'X'; |
| 506 | atapi_data[ 63 ^ 1 ] = 'M'; |
| 507 | atapi_data[ 64 ^ 1 ] = '-'; |
| 508 | atapi_data[ 65 ^ 1 ] = '3'; |
| 509 | atapi_data[ 66 ^ 1 ] = '3'; |
| 510 | atapi_data[ 67 ^ 1 ] = '0'; |
| 511 | atapi_data[ 68 ^ 1 ] = '1'; |
| 512 | atapi_data[ 69 ^ 1 ] = ' '; |
| 513 | |
| 514 | atapi_data[ 98 ^ 1 ] = 0x06; // Word 49=Capabilities, IORDY may be disabled (bit_10), LBA Supported mandatory (bit_9) |
| 515 | atapi_data[ 99 ^ 1 ] = 0x00; |
| 516 | |
| 517 | atapi_regs[ATAPI_REG_COUNTLOW] = 0; |
| 518 | atapi_regs[ATAPI_REG_COUNTHIGH] = 2; |
| 519 | |
| 520 | atapi_irq(space.machine(), ASSERT_LINE); |
| 521 | break; |
| 522 | case 0xec: //IDENTIFY DEVICE - Must abort here and set for packet data |
| 523 | atapi_regs[ATAPI_REG_ERRFEAT] = ATAPI_ERRFEAT_ABRT; |
| 524 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_CHECK; |
| 525 | |
| 526 | atapi_irq(space.machine(), ASSERT_LINE); |
| 527 | |
| 528 | case 0xef: // SET FEATURES |
| 529 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 530 | |
| 531 | state->m_atapi_data_ptr = 0; |
| 532 | state->m_atapi_data_len = 0; |
| 533 | |
| 534 | atapi_irq(space.machine(), ASSERT_LINE); |
| 535 | break; |
| 536 | |
| 537 | default: |
| 538 | logerror("ATAPI: Unknown IDE command %x\n", data); |
| 539 | break; |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | */ |
| 545 | // Memory is mostly handled by the chipset |
| 546 | static ADDRESS_MAP_START( gammagic_map, AS_PROGRAM, 32, gammagic_state ) |
| 547 | AM_RANGE(0x00000000, 0x0009ffff) AM_RAM |
| 548 | AM_RANGE(0x000a0000, 0x000bffff) AM_NOP |
| 549 | AM_RANGE(0x00100000, 0x07ffffff) AM_RAM |
| 550 | AM_RANGE(0x08000000, 0xfffdffff) AM_NOP |
| 551 | AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("user", 0x20000)/* System BIOS */ |
| 552 | ADDRESS_MAP_END |
| 553 | |
| 554 | static ADDRESS_MAP_START( gammagic_io, AS_IO, 32, gammagic_state) |
| 555 | AM_RANGE(0x0000, 0x001f) AM_DEVREADWRITE8_LEGACY("dma8237_1", i8237_r, i8237_w, 0xffffffff) |
| 556 | AM_RANGE(0x0020, 0x003f) AM_DEVREADWRITE8_LEGACY("pic8259_1", pic8259_r, pic8259_w, 0xffffffff) |
| 557 | AM_RANGE(0x0040, 0x005f) AM_DEVREADWRITE8_LEGACY("pit8254", pit8253_r, pit8253_w, 0xffffffff) |
| 558 | AM_RANGE(0x0060, 0x006f) AM_READWRITE8_LEGACY(kbdc8042_8_r, kbdc8042_8_w, 0xffffffff) |
| 559 | AM_RANGE(0x0070, 0x007f) AM_DEVREADWRITE8("rtc", mc146818_device, read, write, 0xffffffff) |
| 560 | AM_RANGE(0x0080, 0x009f) AM_READWRITE8_LEGACY(at_page8_r, at_page8_w, 0xffffffff) |
| 561 | AM_RANGE(0x00a0, 0x00bf) AM_DEVREADWRITE8_LEGACY("pic8259_2", pic8259_r, pic8259_w, 0xffffffff) |
| 562 | AM_RANGE(0x00c0, 0x00df) AM_DEVREADWRITE8_LEGACY("dma8237_2", at_dma8237_2_r, at_dma8237_2_w, 0xffffffff) |
| 563 | AM_RANGE(0x00e8, 0x00ef) AM_NOP |
| 564 | AM_RANGE(0x00f0, 0x01ef) AM_NOP |
| 565 | //AM_RANGE(0x01f0, 0x01f7) AM_READWRITE_LEGACY(atapi_r, atapi_w) |
| 566 | AM_RANGE(0x01f8, 0x03ef) AM_NOP |
| 567 | AM_RANGE(0x03f0, 0x0cf7) AM_NOP |
| 568 | AM_RANGE(0x0cf8, 0x0cff) AM_DEVREADWRITE("pcibus", pci_bus_device, read, write) |
| 569 | AM_RANGE(0x0400, 0xffff) AM_NOP |
| 570 | |
| 571 | |
| 572 | ADDRESS_MAP_END |
| 573 | |
| 574 | #define AT_KEYB_HELPER(bit, text, key1) \ |
| 575 | PORT_BIT( bit, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME(text) PORT_CODE(key1) |
| 576 | |
| 577 | #if 1 |
| 578 | static INPUT_PORTS_START( gammagic ) |
| 579 | PORT_START("pc_keyboard_0") |
| 580 | PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */ |
| 581 | AT_KEYB_HELPER( 0x0002, "Esc", KEYCODE_Q ) /* Esc 01 81 */ |
| 582 | |
| 583 | PORT_START("pc_keyboard_1") |
| 584 | AT_KEYB_HELPER( 0x0010, "T", KEYCODE_T ) /* T 14 94 */ |
| 585 | AT_KEYB_HELPER( 0x0020, "Y", KEYCODE_Y ) /* Y 15 95 */ |
| 586 | AT_KEYB_HELPER( 0x0100, "O", KEYCODE_O ) /* O 18 98 */ |
| 587 | AT_KEYB_HELPER( 0x1000, "Enter", KEYCODE_ENTER ) /* Enter 1C 9C */ |
| 588 | |
| 589 | PORT_START("pc_keyboard_2") |
| 590 | |
| 591 | PORT_START("pc_keyboard_3") |
| 592 | AT_KEYB_HELPER( 0x0001, "B", KEYCODE_B ) /* B 30 B0 */ |
| 593 | AT_KEYB_HELPER( 0x0002, "N", KEYCODE_N ) /* N 31 B1 */ |
| 594 | AT_KEYB_HELPER( 0x0800, "F1", KEYCODE_S ) /* F1 3B BB */ |
| 595 | AT_KEYB_HELPER( 0x1000, "F2", KEYCODE_D ) /* F2 3C BC */ |
| 596 | AT_KEYB_HELPER( 0x4000, "F4", KEYCODE_F ) /* F4 3E BE */ |
| 597 | |
| 598 | |
| 599 | PORT_START("pc_keyboard_4") |
| 600 | AT_KEYB_HELPER( 0x0004, "F8", KEYCODE_F8 ) // f8=42 /f10=44 /minus 4a /plus=4e |
| 601 | AT_KEYB_HELPER( 0x0010, "F10", KEYCODE_F10 ) // f8=42 /f10=44 /minus 4a /plus=4e |
| 602 | AT_KEYB_HELPER( 0x0100, "KP 8(UP)", KEYCODE_8_PAD ) /* Keypad 8 (Up arrow) 48 C8 */ |
| 603 | AT_KEYB_HELPER( 0x0400, "KP -", KEYCODE_MINUS_PAD ) // f8=42 /f10=44 /minus 4a /plus=4e |
| 604 | AT_KEYB_HELPER( 0x4000, "KP +", KEYCODE_PLUS_PAD ) // f8=42 /f10=44 /minus 4a /plus=4e |
| 605 | |
| 606 | PORT_START("pc_keyboard_5") |
| 607 | AT_KEYB_HELPER( 0x0001, "KP 2(DN)", KEYCODE_2_PAD ) /* Keypad 2 (Down arrow) 50 D0 */ |
| 608 | |
| 609 | PORT_START("pc_keyboard_6") |
| 610 | AT_KEYB_HELPER( 0x0040, "(MF2)Cursor Up", KEYCODE_UP ) /* Up 67 e7 */ |
| 611 | AT_KEYB_HELPER( 0x0080, "(MF2)Page Up", KEYCODE_PGUP ) /* Page Up 68 e8 */ |
| 612 | AT_KEYB_HELPER( 0x0100, "(MF2)Cursor Left", KEYCODE_LEFT ) /* Left 69 e9 */ |
| 613 | AT_KEYB_HELPER( 0x0200, "(MF2)Cursor Right", KEYCODE_RIGHT ) /* Right 6a ea */ |
| 614 | AT_KEYB_HELPER( 0x0800, "(MF2)Cursor Down", KEYCODE_DOWN ) /* Down 6c ec */ |
| 615 | AT_KEYB_HELPER( 0x1000, "(MF2)Page Down", KEYCODE_PGDN ) /* Page Down 6d ed */ |
| 616 | AT_KEYB_HELPER( 0x4000, "Del", KEYCODE_A ) /* Delete 6f ef */ |
| 617 | |
| 618 | PORT_START("pc_keyboard_7") |
| 619 | |
| 620 | INPUT_PORTS_END |
| 621 | #endif |
| 622 | |
| 623 | static IRQ_CALLBACK(irq_callback) |
| 624 | { |
| 625 | gammagic_state *state = device->machine().driver_data<gammagic_state>(); |
| 626 | return pic8259_acknowledge( state->m_pic8259_1); |
| 627 | } |
| 628 | |
| 629 | READ8_MEMBER( gammagic_state::vga_setting ) { return 0xff; } // hard-code to color |
| 630 | |
| 631 | static MACHINE_START(gammagic) |
| 632 | { |
| 633 | gammagic_state *state = machine.driver_data<gammagic_state>(); |
| 634 | machine.device("maincpu")->execute().set_irq_acknowledge_callback(irq_callback); |
| 635 | |
| 636 | state->m_pit8254 = machine.device( "pit8254" ); |
| 637 | state->m_pic8259_1 = machine.device( "pic8259_1" ); |
| 638 | state->m_pic8259_2 = machine.device( "pic8259_2" ); |
| 639 | state->m_dma8237_1 = machine.device( "dma8237_1" ); |
| 640 | state->m_dma8237_2 = machine.device( "dma8237_2" ); |
| 641 | } |
| 642 | |
| 643 | static MACHINE_RESET( gammagic ) |
| 644 | { |
| 645 | //gammagic_state *state = machine.driver_data<gammagic_state>(); |
| 646 | |
| 647 | //void *cd; |
| 648 | //SCSIGetDevice( state->m_inserted_cdrom, &cd ); |
| 649 | |
| 650 | } |
| 651 | |
| 652 | |
| 653 | /*static void atapi_irq(running_machine &machine, int state) |
| 654 | { |
| 655 | gammagic_state *drvstate = machine.driver_data<gammagic_state>(); |
| 656 | pic8259_ir6_w(drvstate->m_pic8259_2, state); |
| 657 | } |
| 658 | |
| 659 | static void atapi_exit(running_machine& machine) |
| 660 | { |
| 661 | gammagic_state *state = machine.driver_data<gammagic_state>(); |
| 662 | SCSIDeleteInstance(state->m_inserted_cdrom); |
| 663 | |
| 664 | } |
| 665 | */ |
| 666 | |
| 667 | static void atapi_init(running_machine &machine) |
| 668 | { |
| 669 | gammagic_state *state = machine.driver_data<gammagic_state>(); |
| 670 | |
| 671 | state->m_atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 672 | state->m_atapi_regs[ATAPI_REG_ERRFEAT] = 1; |
| 673 | state->m_atapi_regs[ATAPI_REG_COUNTLOW] = 0x14; |
| 674 | state->m_atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb; |
| 675 | state->m_atapi_data_ptr = 0; |
| 676 | state->m_atapi_data_len = 0; |
| 677 | state->m_atapi_cdata_wait = 0; |
| 678 | |
| 679 | //SCSIAllocInstance( machine, &SCSIClassCr589, &state->m_inserted_cdrom, ":cdrom" ); |
| 680 | |
| 681 | //machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(atapi_exit), &machine)); |
| 682 | |
| 683 | } |
| 684 | |
| 685 | |
| 686 | /************************************************************* |
| 687 | * |
| 688 | * pic8259 configuration |
| 689 | * |
| 690 | *************************************************************/ |
| 691 | |
| 692 | static WRITE_LINE_DEVICE_HANDLER( gammagic_pic8259_1_set_int_line ) |
| 693 | { |
| 694 | device->machine().device("maincpu")->execute().set_input_line( 0, state ? HOLD_LINE : CLEAR_LINE); |
| 695 | } |
| 696 | |
| 697 | static READ8_DEVICE_HANDLER( get_slave_ack ) |
| 698 | { |
| 699 | gammagic_state *state = device->machine().driver_data<gammagic_state>(); |
| 700 | if (offset==2) { |
| 701 | return pic8259_acknowledge(state->m_pic8259_2); |
| 702 | } |
| 703 | return 0x00; |
| 704 | } |
| 705 | |
| 706 | static const struct pic8259_interface gammagic_pic8259_1_config = |
| 707 | { |
| 708 | DEVCB_LINE(gammagic_pic8259_1_set_int_line), |
| 709 | DEVCB_LINE_VCC, |
| 710 | DEVCB_HANDLER(get_slave_ack) |
| 711 | }; |
| 712 | |
| 713 | static const struct pic8259_interface gammagic_pic8259_2_config = |
| 714 | { |
| 715 | DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w), |
| 716 | DEVCB_LINE_GND, |
| 717 | DEVCB_NULL |
| 718 | }; |
| 719 | |
| 720 | /************************************************************* |
| 721 | * |
| 722 | * pit8254 configuration |
| 723 | * |
| 724 | *************************************************************/ |
| 725 | |
| 726 | static const struct pit8253_config gammagic_pit8254_config = |
| 727 | { |
| 728 | { |
| 729 | { |
| 730 | 4772720/4, /* heartbeat IRQ */ |
| 731 | DEVCB_NULL, |
| 732 | DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir0_w) |
| 733 | }, { |
| 734 | 4772720/4, /* dram refresh */ |
| 735 | DEVCB_NULL, |
| 736 | DEVCB_NULL |
| 737 | }, { |
| 738 | 4772720/4, /* pio port c pin 4, and speaker polling enough */ |
| 739 | DEVCB_NULL, |
| 740 | DEVCB_NULL |
| 741 | } |
| 742 | } |
| 743 | }; |
| 744 | |
| 745 | static void set_gate_a20(running_machine &machine, int a20) |
| 746 | { |
| 747 | machine.device("maincpu")->execute().set_input_line(INPUT_LINE_A20, a20); |
| 748 | } |
| 749 | |
| 750 | static void keyboard_interrupt(running_machine &machine, int state) |
| 751 | { |
| 752 | gammagic_state *drvstate = machine.driver_data<gammagic_state>(); |
| 753 | pic8259_ir1_w(drvstate->m_pic8259_1, state); |
| 754 | } |
| 755 | |
| 756 | static int gammagic_get_out2(running_machine &machine) |
| 757 | { |
| 758 | gammagic_state *state = machine.driver_data<gammagic_state>(); |
| 759 | return pit8253_get_output(state->m_pit8254, 2 ); |
| 760 | } |
| 761 | |
| 762 | static const struct kbdc8042_interface at8042 = |
| 763 | { |
| 764 | KBDC8042_AT386, set_gate_a20, keyboard_interrupt, NULL, gammagic_get_out2 |
| 765 | }; |
| 766 | |
| 767 | static void gammagic_set_keyb_int(running_machine &machine, int state) |
| 768 | { |
| 769 | gammagic_state *drvstate = machine.driver_data<gammagic_state>(); |
| 770 | pic8259_ir1_w(drvstate->m_pic8259_1, state); |
| 771 | } |
| 772 | |
| 773 | static MACHINE_CONFIG_START( gammagic, gammagic_state ) |
| 774 | MCFG_CPU_ADD("maincpu", PENTIUM, 133000000) // Intel Pentium 133 |
| 775 | MCFG_CPU_PROGRAM_MAP(gammagic_map) |
| 776 | MCFG_CPU_IO_MAP(gammagic_io) |
| 777 | MCFG_MACHINE_START(gammagic) |
| 778 | MCFG_MACHINE_RESET( gammagic ) |
| 779 | MCFG_PIT8254_ADD( "pit8254", gammagic_pit8254_config ) |
| 780 | MCFG_I8237_ADD( "dma8237_1", XTAL_14_31818MHz/3, dma8237_1_config ) |
| 781 | MCFG_I8237_ADD( "dma8237_2", XTAL_14_31818MHz/3, dma8237_2_config ) |
| 782 | MCFG_PIC8259_ADD( "pic8259_1", gammagic_pic8259_1_config ) |
| 783 | MCFG_PIC8259_ADD( "pic8259_2", gammagic_pic8259_2_config ) |
| 784 | MCFG_MC146818_ADD( "rtc", MC146818_STANDARD ) |
| 785 | // MCFG_I82371SB_ADD("i82371sb") |
| 786 | // MCFG_I82439TX_ADD("i82439tx", "maincpu", "user") |
| 787 | MCFG_PCI_BUS_ADD("pcibus", 0) |
| 788 | // MCFG_PCI_BUS_DEVICE(0, "i82439tx", i82439tx_pci_read, i82439tx_pci_write) |
| 789 | // MCFG_PCI_BUS_DEVICE(1, "i82371sb", i82371sb_pci_read, i82371sb_pci_write) |
| 790 | /* video hardware */ |
| 791 | MCFG_FRAGMENT_ADD( pcvideo_vga ) |
| 792 | |
| 793 | MACHINE_CONFIG_END |
| 794 | |
| 795 | |
| 796 | DRIVER_INIT_MEMBER(gammagic_state,gammagic) |
| 797 | { |
| 798 | pc_vga_init(machine(), read8_delegate(FUNC(gammagic_state::vga_setting),this), NULL); |
| 799 | pc_vga_io_init(machine(), machine().device("maincpu")->memory().space(AS_PROGRAM), 0xa0000, machine().device("maincpu")->memory().space(AS_IO), 0x0000); |
| 800 | init_pc_common(machine(), PCCOMMON_KEYBOARD_AT, gammagic_set_keyb_int); |
| 801 | kbdc8042_init(machine(), &at8042); |
| 802 | atapi_init(machine()); |
| 803 | } |
| 804 | |
| 805 | ROM_START( gammagic ) |
| 806 | ROM_REGION32_LE(0x40000, "user", 0) |
| 807 | //Original Memory Set |
| 808 | //ROM_LOAD("m7s04.rom", 0, 0x40000, CRC(3689f5a9) SHA1(8daacdb0dc6783d2161680564ffe83ac2515f7ef)) |
| 809 | //ROM_LOAD("otivga_tx2953526.rom", 0x0000, 0x8000, CRC(916491af) SHA1(d64e3a43a035d70ace7a2d0603fc078f22d237e1)) |
| 810 | |
| 811 | //Temp. Memory Set (Only for initial driver development stage) |
| 812 | ROM_LOAD16_BYTE( "trident_tgui9680_bios.bin", 0x0000, 0x4000, CRC(1eebde64) SHA1(67896a854d43a575037613b3506aea6dae5d6a19) ) |
| 813 | ROM_CONTINUE( 0x0001, 0x4000 ) |
| 814 | ROM_LOAD("5hx29.bin", 0x20000, 0x20000, CRC(07719a55) SHA1(b63993fd5186cdb4f28c117428a507cd069e1f68)) |
| 815 | |
| 816 | DISK_REGION( "cdrom" ) |
| 817 | DISK_IMAGE_READONLY( "gammagic", 0,SHA1(caa8fc885d84dbc07fb0604c76cd23c873a65ce6) ) |
| 818 | ROM_END |
| 819 | |
| 820 | ROM_START( 99bottles ) |
| 821 | ROM_REGION32_LE(0x40000, "user", 0) |
| 822 | //Original BIOS/VGA-BIOS Rom Set |
| 823 | //ROM_LOAD("m7s04.rom", 0, 0x40000, CRC(3689f5a9) SHA1(8daacdb0dc6783d2161680564ffe83ac2515f7ef)) |
| 824 | //ROM_LOAD("otivga_tx2953526.rom", 0x0000, 0x8000, CRC(916491af) SHA1(d64e3a43a035d70ace7a2d0603fc078f22d237e1)) |
| 825 | |
| 826 | //Temporary (Chipset compatible Rom Set, only for driver development stage) |
| 827 | ROM_LOAD16_BYTE( "trident_tgui9680_bios.bin", 0x0000, 0x4000, CRC(1eebde64) SHA1(67896a854d43a575037613b3506aea6dae5d6a19) ) |
| 828 | ROM_CONTINUE( 0x0001, 0x4000 ) |
| 829 | ROM_LOAD("5hx29.bin", 0x20000, 0x20000, CRC(07719a55) SHA1(b63993fd5186cdb4f28c117428a507cd069e1f68)) |
| 830 | |
| 831 | DISK_REGION( "cdrom" ) |
| 832 | DISK_IMAGE_READONLY( "99bottles", 0, SHA1(0b874178c8dd3cfc451deb53dc7936dc4ad5a04f)) |
| 833 | ROM_END |
| 834 | |
| 835 | |
| 836 | /*************************************************************************** |
| 837 | |
| 838 | Game driver(s) |
| 839 | |
| 840 | ***************************************************************************/ |
| 841 | /************************* |
| 842 | * Game Drivers * |
| 843 | *************************/ |
| 844 | |
| 845 | /* YEAR NAME PARENT MACHINE INPUT INIT ROT COMPANY FULLNAME FLAGS */ |
| 846 | GAME( 1999, gammagic, 0, gammagic, gammagic, gammagic_state, gammagic , ROT0, "Bally Gaming Co.", "Game Magic", GAME_IS_SKELETON ) |
| 847 | GAME( 1999, 99bottles, gammagic, gammagic, gammagic, gammagic_state, gammagic , ROT0, "Bally Gaming Co.", "99 Bottles of Beer", GAME_IS_SKELETON ) |
| 848 | |