trunk/src/mame/drivers/gstream.c
r17532 | r17533 | |
160 | 160 | UINT32 m_tmap3_scrolly; |
161 | 161 | |
162 | 162 | /* misc */ |
163 | | int m_oki_bank_0; |
164 | 163 | int m_oki_bank_1; |
| 164 | int m_oki_bank_2; |
165 | 165 | |
166 | 166 | DECLARE_WRITE32_MEMBER(gstream_palette_w); |
167 | 167 | DECLARE_WRITE32_MEMBER(gstream_vram_w); |
r17532 | r17533 | |
293 | 293 | |
294 | 294 | WRITE32_MEMBER(gstream_state::gstream_oki_banking_w) |
295 | 295 | { |
296 | | /* OKI BANKING (still far from perfect, based on game behaviour) |
| 296 | /* |
| 297 | ****OKI BANKING**** |
| 298 | Possibly perfect? works perfectly in-game, may not cover all possibilities. |
| 299 | Needs code testing on PCB. |
297 | 300 | |
298 | | The two OKIs can independently play music or samples and are switched on the fly during game |
299 | | This is a preliminary table of the banks: |
| 301 | The two OKIs can independently play music or samples, and have half of the |
| 302 | sound ROMs to themselves. Sometimes the first OKI will play music, and some |
| 303 | times it will play samples. The second OKI is the same way. The banks for |
| 304 | both OKIs are laid out like so: |
300 | 305 | |
301 | | BANK MUSIC SAMPLES |
302 | | 0 X |
303 | | 1 X |
304 | | 2 X |
305 | | 3 X |
306 | | 4 X |
307 | | 5 X |
308 | | 6 X |
309 | | 7 X |
| 306 | BANK MUSIC SAMPLES |
| 307 | 0 X |
| 308 | 1 X |
| 309 | 2 X |
| 310 | 3 X |
310 | 311 | |
311 | | Two nibbles are used in this handler: (data & 0xf) and ((data >> 4) & 0xf) |
312 | | The values for the first nibble are the followings and should map the 8 oki banks: |
313 | | - 0x6, 0x7, 0x9, 0xa, 0xb, 0xd, 0xe, 0xf |
314 | | The values for the second nibble are the followings and should probably be used too: |
315 | | - 0x6, 0x9, 0xa |
| 312 | Bank 0 is the same in both ROMs. |
316 | 313 | |
317 | | Same values are redudant, for example: |
318 | | level 2: data = 0x99 |
319 | | level 6: data = 0x99 |
320 | | (this means same background music for the two levels - it could be correct, though) |
| 314 | The banking seems to be concerned with half-nibbles in the data byte. For |
| 315 | OKI1, the half-nibbles are bits 76 and 32. For OKI2, 54 and 10. |
| 316 | The bank's '2' bit is the first half-nibble's bottom bit bitwise AND with |
| 317 | the inverse of its top bit. The bank's '1' bit is the second half-nibble's |
| 318 | bottom bit bitwise AND with the top bit. |
321 | 319 | |
322 | | Also with current implementation, using only (data & 0xf), we have to force some values |
323 | | manually, because the correspondent places in the table are already used |
| 320 | This may or may not be correct, but further PCB tests are required, and it |
| 321 | certainly sounds perfect in-game, without using any "hacks". */ |
324 | 322 | |
325 | | Musics order is completely guessed but close to what the original PCB game should be */ |
| 323 | /* |
| 324 | 7654 3210 |
| 325 | 1010 1010 needs oki2 to be bank 0 |
| 326 | 1010 1011 needs oki2 to be bank 1 |
| 327 | 1010 1011 needs oki1 to be bank 0 |
326 | 328 | |
327 | | static const int bank_table_0[16] = { -1, -1, -1, -1, -1, -1, 0, 0, -1, 6, 0, 5, -1, 0, 0, 0 }; |
328 | | static const int bank_table_1[16] = { -1, -1, -1, -1, -1, -1, 2, 2, -1, 0, 0, 4, -1, 1, 1, 1 }; |
| 329 | 7654 3210 |
| 330 | 1010 1111 needs oki1 to be bank 1 |
| 331 | 1010 1110 needs oki1 to be bank 1 |
| 332 | 1010 1110 needs oki2 to be bank 0 |
329 | 333 | |
330 | | //popmessage("oki_0 banking value = %X\noki_1 banking value = %X\n",data & 0xf,(data >> 4) & 0xf); |
| 334 | 7654 3210 |
| 335 | 0110 0110 needs oki1 to be bank 2 |
| 336 | 0110 0110 needs oki2 to be bank 0 |
331 | 337 | |
332 | | m_oki_bank_0 = bank_table_0[data & 0xf]; |
333 | | m_oki_bank_1 = bank_table_1[data & 0xf]; // (data >> 4) & 0xf ?? |
| 338 | 6and!7 & 2and3 |
334 | 339 | |
335 | | /* some values are already used in the table, so we force them manually */ |
336 | | if ((data == 0x6f) || (data == 0x6e)) |
337 | | { |
338 | | m_oki_bank_0 = 0; // level 3b-5a samples |
339 | | m_oki_bank_1 = 6; // level 3b-5a music |
340 | | } |
| 340 | 4and!5 & 0and1 |
341 | 341 | |
342 | | if (data == 0x9b) |
343 | | { |
344 | | m_oki_bank_0 = 7; // level 7 music |
345 | | m_oki_bank_1 = 0; // level 7 samples |
346 | | } |
| 342 | */ |
347 | 343 | |
348 | | if (data == 0x9f) |
349 | | { |
350 | | m_oki_bank_0 = 0; // end sequence samples |
351 | | m_oki_bank_1 = 3; // end sequence music |
352 | | } |
| 344 | m_oki_bank_1 = ((BIT(data, 6) & !BIT(data, 7)) << 1) | (BIT(data, 2) & BIT(data, 3)); |
| 345 | m_oki_bank_2 = ((BIT(data, 4) & !BIT(data, 5)) << 1) | (BIT(data, 0) & BIT(data, 1)); |
353 | 346 | |
354 | | m_oki_1->set_bank_base(m_oki_bank_0 * 0x40000); |
355 | | m_oki_2->set_bank_base(m_oki_bank_1 * 0x40000); |
| 347 | //popmessage("oki bank = %X\noki_1 = %X\noki_2 = %X\n",data, m_oki_bank_1, m_oki_bank_2); |
| 348 | |
| 349 | m_oki_1->set_bank_base(m_oki_bank_1 * 0x40000); |
| 350 | m_oki_2->set_bank_base(m_oki_bank_2 * 0x40000); |
356 | 351 | } |
357 | 352 | |
| 353 | // Some clocking? |
358 | 354 | WRITE32_MEMBER(gstream_state::gstream_oki_4040_w) |
359 | 355 | { |
360 | 356 | // data == 0 or data == 0x81 |
r17532 | r17533 | |
365 | 361 | AM_RANGE(0x4010, 0x4013) AM_READ_PORT("IN1") |
366 | 362 | AM_RANGE(0x4020, 0x4023) AM_READ_PORT("IN2") // extra coin switches etc |
367 | 363 | AM_RANGE(0x4030, 0x4033) AM_WRITE(gstream_oki_banking_w) // oki banking |
368 | | AM_RANGE(0x4040, 0x4043) AM_WRITE(gstream_oki_4040_w) // ?? |
369 | | AM_RANGE(0x4050, 0x4053) AM_DEVREADWRITE8("oki2", okim6295_device, read, write, 0x000000ff) // music and samples |
370 | | AM_RANGE(0x4060, 0x4063) AM_DEVREADWRITE8("oki1", okim6295_device, read, write, 0x000000ff) // music and samples |
| 364 | AM_RANGE(0x4040, 0x4043) AM_WRITE(gstream_oki_4040_w) // some clocking? |
| 365 | AM_RANGE(0x4050, 0x4053) AM_DEVREADWRITE8("oki1", okim6295_device, read, write, 0x000000ff) // music and samples |
| 366 | AM_RANGE(0x4060, 0x4063) AM_DEVREADWRITE8("oki2", okim6295_device, read, write, 0x000000ff) // music and samples |
371 | 367 | ADDRESS_MAP_END |
372 | 368 | |
373 | 369 | static INPUT_PORTS_START( gstream ) |
r17532 | r17533 | |
545 | 541 | state->save_item(NAME(state->m_tmap1_scrolly)); |
546 | 542 | state->save_item(NAME(state->m_tmap2_scrolly)); |
547 | 543 | state->save_item(NAME(state->m_tmap3_scrolly)); |
548 | | state->save_item(NAME(state->m_oki_bank_0)); |
549 | 544 | state->save_item(NAME(state->m_oki_bank_1)); |
| 545 | state->save_item(NAME(state->m_oki_bank_2)); |
550 | 546 | } |
551 | 547 | |
552 | 548 | static MACHINE_RESET( gstream ) |
r17532 | r17533 | |
559 | 555 | state->m_tmap1_scrolly = 0; |
560 | 556 | state->m_tmap2_scrolly = 0; |
561 | 557 | state->m_tmap3_scrolly = 0; |
562 | | state->m_oki_bank_0 = 0; |
563 | 558 | state->m_oki_bank_1 = 0; |
| 559 | state->m_oki_bank_2 = 0; |
564 | 560 | } |
565 | 561 | |
566 | 562 | static MACHINE_CONFIG_START( gstream, gstream_state ) |
r17532 | r17533 | |
623 | 619 | ROM_LOAD( "gs_gr_05.u174", 0x800000, 0x200000, CRC(ef283a73) SHA1(8b598facb344eac33138611abc141a2acb375983) ) |
624 | 620 | ROM_LOAD( "gs_gr_06.u175", 0xa00000, 0x200000, CRC(d4e3a2b2) SHA1(4577c007172c718bf7ca55a8ccee5455c281026c) ) |
625 | 621 | |
626 | | ROM_REGION( 0x200000, "oki1", 0 ) |
| 622 | ROM_REGION( 0x100000, "oki1", 0 ) |
627 | 623 | ROM_LOAD( "gs_snd_01.u192", 0x000000, 0x080000, CRC(79b64d3f) SHA1(b2166210d3a3b85b9ace90749a444c881f69d551) ) |
628 | 624 | ROM_LOAD( "gs_snd_02.u194", 0x080000, 0x080000, CRC(e49ed92c) SHA1(a3d7b3fe93a786a246acf2657d9056398c793078) ) |
629 | | ROM_LOAD( "gs_snd_03.u191", 0x100000, 0x080000, CRC(2bfff4ac) SHA1(cce1bb3c78b86722c926854c737f9589806012ba) ) |
630 | | ROM_LOAD( "gs_snd_04.u193", 0x180000, 0x080000, CRC(b259de3b) SHA1(1a64f41d4344fefad5832332f1a7655e23f6b017) ) |
631 | 625 | |
632 | | ROM_REGION( 0x200000, "oki2", 0 ) |
633 | | ROM_COPY( "oki1", 0, 0, 0x200000 ) |
| 626 | ROM_REGION( 0x100000, "oki2", 0 ) |
| 627 | ROM_LOAD( "gs_snd_03.u191", 0x000000, 0x080000, CRC(2bfff4ac) SHA1(cce1bb3c78b86722c926854c737f9589806012ba) ) |
| 628 | ROM_LOAD( "gs_snd_04.u193", 0x080000, 0x080000, CRC(b259de3b) SHA1(1a64f41d4344fefad5832332f1a7655e23f6b017) ) |
634 | 629 | |
635 | 630 | ROM_REGION( 0x2000, "nvram", 0 ) |
636 | 631 | ROM_LOAD( "gstream.nv", 0x000000, 0x2000, CRC(895d724b) SHA1(97941102f94923220d9beb270939f0ad9a40fe0e) ) |
r17532 | r17533 | |
652 | 647 | } |
653 | 648 | |
654 | 649 | |
655 | | GAME( 2002, gstream, 0, gstream, gstream, gstream_state, gstream, ROT270, "Oriental Soft", "G-Stream G2020", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 650 | GAME( 2002, gstream, 0, gstream, gstream, gstream_state, gstream, ROT270, "Oriental Soft", "G-Stream G2020", GAME_SUPPORTS_SAVE ) |
| 651 | |