src/mess/drivers/cdi.c
| r0 | r4628 | |
| 1 | /****************************************************************************** |
| 2 | |
| 3 | |
| 4 | Philips CD-I |
| 5 | ------------------- |
| 6 | |
| 7 | Preliminary MAME driver by Roberto Fresca, David Haywood & Angelo Salese |
| 8 | Borrowed by incog for MESS |
| 9 | |
| 10 | |
| 11 | ******************************************************************************* |
| 12 | |
| 13 | |
| 14 | *** Hardware Notes *** |
| 15 | |
| 16 | These are actually the specs of the Philips CD-i console. |
| 17 | |
| 18 | Identified: |
| 19 | |
| 20 | - CPU: 1x Philips SCC 68070 CCA84 (16 bits Microprocessor, PLCC) @ 15 MHz |
| 21 | - VSC: 1x Philips SCC 66470 CAB (Video and System Controller, QFP) |
| 22 | |
| 23 | - Crystals: 1x 30.0000 MHz. |
| 24 | 1x 19.6608 MHz. |
| 25 | |
| 26 | |
| 27 | ******************************************************************************* |
| 28 | |
| 29 | TODO: |
| 30 | |
| 31 | -Proper handling of the 68070 (68k with 32 address lines instead of 24) |
| 32 | & handle the extra features properly (UART,DMA,Timers etc.) |
| 33 | |
| 34 | -Proper emulation of the 66470 Video Chip (still many unhandled features) |
| 35 | |
| 36 | -Inputs; |
| 37 | |
| 38 | -Unknown sound chip (it's an ADPCM with eight channels); |
| 39 | |
| 40 | -Many unknown memory maps; |
| 41 | |
| 42 | *******************************************************************************/ |
| 43 | |
| 44 | |
| 45 | #define CLOCK_A XTAL_30MHz |
| 46 | #define CLOCK_B XTAL_19_6608MHz |
| 47 | |
| 48 | #include "driver.h" |
| 49 | #include "cpu/m68000/m68000.h" |
| 50 | #include "sound/2413intf.h" |
| 51 | #include "devices/chd_cd.h" |
| 52 | |
| 53 | static UINT16 *ram; |
| 54 | static UINT16 *pcab_vregs; |
| 55 | |
| 56 | /************************* |
| 57 | * Video Hardware * |
| 58 | *************************/ |
| 59 | |
| 60 | /* |
| 61 | 66470 |
| 62 | video and system controller |
| 63 | 19901219/wjvg |
| 64 | */ |
| 65 | /* |
| 66 | TODO: check this register,doesn't seem to be 100% correct. |
| 67 | 1fffe0 csr = control and status register |
| 68 | w 00...... ........ DM = slow timing speed, normal dram mode |
| 69 | w 01...... ........ DM = fast timing speed, page dram mode |
| 70 | w 10...... ........ DM = fast timing speed, nibble dram mode |
| 71 | w 11...... ........ DM = slow timing speed, dual-port vram mode |
| 72 | w ..1..... ........ TD = 256/64 k dram's |
| 73 | w ...1.... ........ CG = enable character generator |
| 74 | w ....1... ........ DD = rom data acknowledge delay |
| 75 | w .....1.. ........ ED = early dtack |
| 76 | w ......0. ........ not used |
| 77 | w .......1 ........ BE = enable bus error (watchdog timer) |
| 78 | r ........ 1....... DA = vertical display active |
| 79 | r ........ .1...... FG = set during frame grabbing (if fg in dcr set) |
| 80 | r ........ ..xxx... not used |
| 81 | r ........ .....1.. IT2 = intn active |
| 82 | r ........ ......1. IT1 = pixac free and intn active |
| 83 | r ........ .......1 BE = bus error generated by watchdog timer |
| 84 | */ |
| 85 | |
| 86 | /*63 at post test,6d all the time.*/ |
| 87 | #define SCC_CSR_VREG (pcab_vregs[0x00/2] & 0xffff) |
| 88 | #define SCC_CG_VREG ((SCC_CSR_VREG & 0x10)>>4) |
| 89 | |
| 90 | /* |
| 91 | 1fffe2 dcr = display command register |
| 92 | w 1....... ........ DE = enable display |
| 93 | w .00..... ........ CF = 20 MHz (or 19.6608 MHz) |
| 94 | w .01..... ........ CF = 24 MHz |
| 95 | w .10..... ........ CF = 28.5 MHz |
| 96 | w .11..... ........ CF = 30 MHz |
| 97 | w ...1.... ........ FD = 60/50 Hz frame duration |
| 98 | w ....00.. ........ SM/SS = non-interlaced scan mode |
| 99 | w ....01.. ........ SM/SS = double frequency scan mode |
| 100 | w ....10.. ........ SM/SS = interlaced scan mode |
| 101 | w ....11.. ........ SM/SS = interlaced field repeat scan mode |
| 102 | w ......1. ........ LS = full screen/border |
| 103 | w .......1 ........ CM = logical/physical screen |
| 104 | w ........ 1....... FG = 4/8 bits per pixel |
| 105 | w ........ .1...... DF = enable frame grabbing |
| 106 | w ........ ..00.... IC/DC = ICA and DCA inactive |
| 107 | w ........ ..01.... IC/DC = ICA active, reduced DCA mode (DCA sz=16 byts) |
| 108 | w ........ ..10.... IC/DC = ICA active, DCA inactive |
| 109 | w ........ ..11.... IC/DC = ICA active, DCA active (DCA size=64 bytes) |
| 110 | w ........ ....aaaa VSR:H = video start address (MSB's) |
| 111 | */ |
| 112 | |
| 113 | #define SCC_DCR_VREG (pcab_vregs[0x02/2] & 0xffff) |
| 114 | #define SCC_DE_VREG ((SCC_DCR_VREG & 0x8000)>>15) |
| 115 | #define SCC_VSR_VREG_H ((SCC_DCR_VREG & 0xf)>>0) |
| 116 | |
| 117 | /* |
| 118 | 1fffe4 vsr = video start register |
| 119 | w aaaaaaaa aaaaaaaa VSR:L = video start address (LSB's) |
| 120 | */ |
| 121 | |
| 122 | #define SCC_VSR_VREG_L (pcab_vregs[0x04/2] & 0xffff) |
| 123 | #define SCC_VSR_VREG ((SCC_VSR_VREG_H)<<16) | (SCC_VSR_VREG_L) |
| 124 | |
| 125 | /* |
| 126 | 1fffe6 bcr = border colour register |
| 127 | w ........ nnnnnnnn in 8 bit mode |
| 128 | w ........ nnnn.... in 4 bit mode |
| 129 | */ |
| 130 | /* |
| 131 | (Note: not present on the original vreg listing) |
| 132 | 1fffe8 dcr2 = display command register 2 |
| 133 | w x....... ........ not used |
| 134 | w .nn..... ........ OM = lower port of the video mode (with CM) |
| 135 | w ...1.... ........ ID = Indipendent DCA bit |
| 136 | w ....nn.. ........ MF = Mosaic Factor (2,4,8,16) |
| 137 | w ......nn ........ FT = File Type (0/1 = bitmap, 2 = RLE, 3 = Mosaic) |
| 138 | w ........ xxxx.... not used |
| 139 | w ........ ....aaaa "data" (dunno the purpose...) |
| 140 | */ |
| 141 | #define SCC_DCR2_VREG (pcab_vregs[0x08/2] & 0xffff) |
| 142 | |
| 143 | /* |
| 144 | (Note: not present on the original vreg listing) |
| 145 | 1fffea dcp = ??? |
| 146 | w aaaaaaaa aaaaaa-- "data" (dunno the purpose...) |
| 147 | w -------- ------xx not used |
| 148 | */ |
| 149 | |
| 150 | /* |
| 151 | 1fffec swm = selective write mask register |
| 152 | w nnnnnnnn ........ mask |
| 153 | */ |
| 154 | /* |
| 155 | 1fffee stm = selective mask register |
| 156 | w ........ nnnnnnnn mask |
| 157 | */ |
| 158 | /* |
| 159 | 1ffff0 a = source register a |
| 160 | w nnnnnnnn nnnnnnnn source |
| 161 | */ |
| 162 | #define SCC_SRCA_VREG (pcab_vregs[0x10/2] & 0xffff) |
| 163 | |
| 164 | /* |
| 165 | 1ffff2 b = destination register b |
| 166 | rw nnnnnnnn nnnnnnnn destination |
| 167 | */ |
| 168 | |
| 169 | #define SCC_DSTB_VREG (pcab_vregs[0x12/2] & 0xffff) |
| 170 | |
| 171 | /* |
| 172 | 1ffff4 pcr = pixac command register |
| 173 | w 1....... ........ 4N = 8/4 bits per pixel |
| 174 | w .1....00 ....x00. COL = enable colour2 function |
| 175 | w .1....00 .....01. COL = enable colour1 function |
| 176 | w .1...0.. .....10. COL = enable bcolour2 function |
| 177 | w .1...0.. .....11. COL = enable bcolour1 function |
| 178 | w ..1..000 ....x00. EXC = enable exchange function |
| 179 | w ..1..000 .....01. EXC = enable swap function |
| 180 | w ..1..000 .....10. EXC = enable inverted exchange function |
| 181 | w ..1..000 .....11. EXC = enable inverted swap function |
| 182 | w ...1..0. ....x00. CPY = enable copy type b function |
| 183 | w ...1...0 ....x10. CPY = enable copy type a function |
| 184 | w ...1..0. .....01. CPY = enable patch type b function |
| 185 | w ...1...0 .....11. CPY = enable patch type a function |
| 186 | w ....1000 .....00. CMP = enable compare function |
| 187 | w ....1000 .....10. CMP = enable compact function |
| 188 | w .....1.. ........ RTL = manipulate right to left |
| 189 | w ......1. ........ SHK = shrink picture by factor 2 |
| 190 | w .......1 ........ ZOM = zoom picture by factor 2 |
| 191 | w ........ nnnn.... LGF = logical function |
| 192 | w ........ 0000.... LGF = d=r |
| 193 | w ........ 0001.... LGF = d=~r |
| 194 | w ........ 0010.... LGF = d=0 |
| 195 | w ........ 0011.... LGF = d=1 |
| 196 | w ........ 0100.... LGF = d=~(d^r) |
| 197 | w ........ 0101.... LGF = d=d^r |
| 198 | w ........ 0110.... LGF = d=d&r |
| 199 | w ........ 0111.... LGF = d=~d&r |
| 200 | w ........ 1000.... LGF = d=~d&~r |
| 201 | w ........ 1001.... LGF = d=d&~r |
| 202 | w ........ 1010.... LGF = d=~d|r |
| 203 | w ........ 1011.... LGF = d=d|r |
| 204 | w ........ 1100.... LGF = d=d|~r |
| 205 | w ........ 1101.... LGF = d=~d|~r |
| 206 | w ........ 1110.... LGF = d=d |
| 207 | w ........ 1111.... LGF = d=~d |
| 208 | w ........ ....1... INV = invert transparancy state of source bits |
| 209 | w ........ .....1.. BIT = copy: enable copy type a |
| 210 | w ........ .....1.. BIT = colour: enable bcolour/colour |
| 211 | w ........ .....1.. BIT = compare: compact/compare |
| 212 | w ........ ......1. TT = perform transparancy test |
| 213 | w ........ .......0 |
| 214 | */ |
| 215 | |
| 216 | #define SCC_PCR_VREG (pcab_vregs[0x14/2] & 0xffff) |
| 217 | |
| 218 | /* |
| 219 | 1ffff6 mask = mask register |
| 220 | w ........ ....nnnn mask nibbles/0 |
| 221 | */ |
| 222 | /* |
| 223 | 1ffff8 shift = shift register |
| 224 | w ......nn ........ shift by .. during source alignment |
| 225 | */ |
| 226 | /* |
| 227 | 1ffffa index = index register |
| 228 | w ........ ......nn bcolour: use bit .. in the source word |
| 229 | w ........ ......nn compact: nibble .. will hold the result |
| 230 | */ |
| 231 | /* |
| 232 | 1ffffc fc/bc = foreground/background colour register |
| 233 | w nnnnnnnn ........ FC = foreground colour |
| 234 | w ........ nnnnnnnn BC = background colour |
| 235 | */ |
| 236 | /* |
| 237 | 1ffffe tc = transparent colour register |
| 238 | w nnnnnnnn ........ transparent colour |
| 239 | */ |
| 240 | |
| 241 | |
| 242 | |
| 243 | static VIDEO_START(cdi) |
| 244 | { |
| 245 | |
| 246 | } |
| 247 | |
| 248 | static VIDEO_UPDATE(cdi) |
| 249 | { |
| 250 | int x,y; |
| 251 | UINT32 count; |
| 252 | |
| 253 | bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); //TODO |
| 254 | |
| 255 | if(!(SCC_DE_VREG)) //display enable |
| 256 | return 0; |
| 257 | |
| 258 | count = ((SCC_VSR_VREG)/2); |
| 259 | |
| 260 | for(y=0;y<300;y++) |
| 261 | { |
| 262 | for(x=0;x<168;x++) |
| 263 | { |
| 264 | UINT32 color; |
| 265 | |
| 266 | color = ((ram[count]) & 0x00ff)>>0; |
| 267 | |
| 268 | if((x*2)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y) |
| 269 | *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color]; |
| 270 | |
| 271 | color = ((ram[count]) & 0xff00)>>8; |
| 272 | |
| 273 | if(((x*2)+1)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y) |
| 274 | *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color]; |
| 275 | |
| 276 | count++; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | |
| 284 | /************************* |
| 285 | * Memory map information * |
| 286 | *************************/ |
| 287 | |
| 288 | static READ16_HANDLER( test_r ) |
| 289 | { |
| 290 | return mame_rand(space->machine); |
| 291 | } |
| 292 | |
| 293 | static WRITE16_HANDLER( paletteram_io_w ) |
| 294 | { |
| 295 | static int pal_offs,r,g,b,internal_pal_offs; |
| 296 | |
| 297 | switch(offset*2) |
| 298 | { |
| 299 | case 0: |
| 300 | pal_offs = data; |
| 301 | break; |
| 302 | case 4: |
| 303 | internal_pal_offs = 0; |
| 304 | break; |
| 305 | case 2: |
| 306 | switch(internal_pal_offs) |
| 307 | { |
| 308 | case 0: |
| 309 | r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 310 | internal_pal_offs++; |
| 311 | break; |
| 312 | case 1: |
| 313 | g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 314 | internal_pal_offs++; |
| 315 | break; |
| 316 | case 2: |
| 317 | b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4); |
| 318 | palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b)); |
| 319 | internal_pal_offs = 0; |
| 320 | pal_offs++; |
| 321 | break; |
| 322 | } |
| 323 | |
| 324 | break; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | static READ16_HANDLER( philips_66470_r ) |
| 329 | { |
| 330 | switch(offset) |
| 331 | { |
| 332 | // case 0/2: |
| 333 | // return mame_rand(space->machine); //TODO |
| 334 | } |
| 335 | |
| 336 | printf("[%04x]\n",offset*2); |
| 337 | |
| 338 | |
| 339 | return pcab_vregs[offset]; |
| 340 | } |
| 341 | |
| 342 | static WRITE16_HANDLER( philips_66470_w ) |
| 343 | { |
| 344 | COMBINE_DATA(&pcab_vregs[offset]); |
| 345 | |
| 346 | // if(offset == 0x10/2) |
| 347 | // { |
| 348 | //printf("%04x %04x %04x\n",data,pcab_vregs[0x12/2],pcab_vregs[0x14/2]); |
| 349 | //pcab_vregs[0x12/2] = pcab_vregs[0x10/2]; |
| 350 | // } |
| 351 | } |
| 352 | |
| 353 | static ADDRESS_MAP_START( cdi_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 354 | // ADDRESS_MAP_GLOBAL_MASK(0x1fffff) |
| 355 | AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE(&ram) /*only 0-7ffff accessed in Magic Card*/ |
| 356 | // AM_RANGE(0x100000, 0x17ffff) AM_RAM AM_REGION("maincpu", 0) |
| 357 | AM_RANGE(0x180000, 0x1ffbff) AM_ROM AM_REGION("maincpu", 0) |
| 358 | /* 1ffc00-1ffdff System I/O */ |
| 359 | AM_RANGE(0x1ffc00, 0x1ffc01) AM_READ(test_r) |
| 360 | AM_RANGE(0x1ffc40, 0x1ffc41) AM_READ(test_r) |
| 361 | AM_RANGE(0x1ffd00, 0x1ffd05) AM_WRITE(paletteram_io_w) //RAMDAC |
| 362 | /*not the right sound chip,unknown type,it should be an ADPCM with 8 channels.*/ |
| 363 | AM_RANGE(0x1ffd40, 0x1ffd43) AM_DEVWRITE8("ym", ym2413_w, 0x00ff) |
| 364 | AM_RANGE(0x1ffd80, 0x1ffd81) AM_READ(test_r) |
| 365 | AM_RANGE(0x1ffd80, 0x1ffd81) AM_WRITENOP //? |
| 366 | AM_RANGE(0x1fff80, 0x1fffbf) AM_RAM //DRAM I/O, not accessed by this game, CD buffer? |
| 367 | AM_RANGE(0x1fffe0, 0x1fffff) AM_READWRITE(philips_66470_r,philips_66470_w) AM_BASE(&pcab_vregs) //video registers |
| 368 | AM_RANGE(0x200000, 0x2fffff) AM_RAM |
| 369 | ADDRESS_MAP_END |
| 370 | |
| 371 | |
| 372 | /************************* |
| 373 | * Input ports * |
| 374 | *************************/ |
| 375 | |
| 376 | static INPUT_PORTS_START( cdi ) |
| 377 | INPUT_PORTS_END |
| 378 | |
| 379 | |
| 380 | static MACHINE_RESET( cdi ) |
| 381 | { |
| 382 | UINT16 *src = (UINT16*)memory_region( machine, "maincpu" ); |
| 383 | UINT16 *dst = ram; |
| 384 | memcpy (dst, src, 0x80000); |
| 385 | device_reset(cputag_get_cpu(machine, "maincpu")); |
| 386 | } |
| 387 | |
| 388 | /************************* |
| 389 | * Machine Drivers * |
| 390 | *************************/ |
| 391 | |
| 392 | /*Probably there's a mask somewhere if it REALLY uses irqs at all...irq vectors dynamically changes after some time.*/ |
| 393 | static INTERRUPT_GEN( cdi_irq ) |
| 394 | { |
| 395 | // if(input_code_pressed(KEYCODE_Z)) |
| 396 | // cpu_set_input_line(device->machine->cpu[0], 1, HOLD_LINE); |
| 397 | // ram[0x2004/2]^=0xffff; |
| 398 | } |
| 399 | |
| 400 | static MACHINE_DRIVER_START( cdi ) |
| 401 | MDRV_CPU_ADD("maincpu", M68000, CLOCK_A/2) /* SCC-68070 CCA84 datasheet */ |
| 402 | MDRV_CPU_PROGRAM_MAP(cdi_mem,0) |
| 403 | MDRV_CPU_VBLANK_INT("screen", cdi_irq) /* no interrupts? (it erases the vectors..) */ |
| 404 | |
| 405 | MDRV_SCREEN_ADD("screen", RASTER) |
| 406 | MDRV_SCREEN_REFRESH_RATE(60) |
| 407 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 408 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 409 | MDRV_SCREEN_SIZE(400, 300) |
| 410 | MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 256-1) //dynamic resolution,TODO |
| 411 | |
| 412 | MDRV_PALETTE_LENGTH(0x100) |
| 413 | |
| 414 | MDRV_VIDEO_START(cdi) |
| 415 | MDRV_VIDEO_UPDATE(cdi) |
| 416 | |
| 417 | MDRV_MACHINE_RESET(cdi) |
| 418 | |
| 419 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 420 | MDRV_SOUND_ADD("ym", YM2413, CLOCK_A/12) |
| 421 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 422 | |
| 423 | MDRV_CDROM_ADD( "cdrom" ) |
| 424 | MACHINE_DRIVER_END |
| 425 | |
| 426 | /************************* |
| 427 | * Rom Load * |
| 428 | *************************/ |
| 429 | |
| 430 | ROM_START( cdi ) |
| 431 | ROM_REGION(0x80000, "maincpu", 0) |
| 432 | ROM_SYSTEM_BIOS( 0, "mcdi200", "Magnavox CD-i 200" ) |
| 433 | ROMX_LOAD( "cdi200.rom", 0x000000, 0x80000, CRC(40c4e6b9) SHA1(d961de803c89b3d1902d656ceb9ce7c02dccb40a), ROM_BIOS(1) ) |
| 434 | ROM_SYSTEM_BIOS( 1, "cdi220", "Philips CD-i 220" ) |
| 435 | ROMX_LOAD( "cdi220.rom", 0x000000, 0x80000, CRC(40c4e6b9) SHA1(d961de803c89b3d1902d656ceb9ce7c02dccb40a), ROM_BIOS(2) ) |
| 436 | ROM_SYSTEM_BIOS( 2, "pcdi490", "Philips CD-i 490" ) |
| 437 | ROMX_LOAD( "cdi490.rom", 0x000000, 0x80000, CRC(e115f45b) SHA1(f71be031a5dfa837de225081b2ddc8dcb74a0552), ROM_BIOS(3) ) |
| 438 | ROM_SYSTEM_BIOS( 3, "pcdi910m", "Philips CD-i 910" ) |
| 439 | ROMX_LOAD( "cdi910.rom", 0x000000, 0x80000, CRC(8ee44ed6) SHA1(3fcdfa96f862b0cb7603fb6c2af84cac59527b05), ROM_BIOS(4) ) |
| 440 | /* Bad dump? */ |
| 441 | /* ROM_SYSTEM_BIOS( 4, "cdi205", "Philips CD-i 205" ) */ |
| 442 | /* ROMX_LOAD( "cdi205.rom", 0x000000, 0x7fc00, CRC(79ab41b2) SHA1(656890bbd3115b235bc8c6b1cf29a99e9db37c1b), ROM_BIOS(5) ) */ |
| 443 | ROM_END |
| 444 | |
| 445 | /************************* |
| 446 | * Game driver(s) * |
| 447 | *************************/ |
| 448 | |
| 449 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 450 | CONS( 1991, cdi, 0, 0, cdi, 0, 0, 0, "Philips", "CD-I", GAME_NO_SOUND | GAME_NOT_WORKING ) |