Previous 199869 Revisions Next

r17533 Tuesday 28th August, 2012 at 13:26:16 UTC by Tafoid
Fixed G-Stream G2020's sound banking. Compared with a real PCB and everything sounds as it should.  [trap15]
[src/mame/drivers]gstream.c

trunk/src/mame/drivers/gstream.c
r17532r17533
160160   UINT32    m_tmap3_scrolly;
161161
162162   /* misc */
163   int       m_oki_bank_0;
164163   int       m_oki_bank_1;
164   int       m_oki_bank_2;
165165
166166   DECLARE_WRITE32_MEMBER(gstream_palette_w);
167167   DECLARE_WRITE32_MEMBER(gstream_vram_w);
r17532r17533
293293
294294WRITE32_MEMBER(gstream_state::gstream_oki_banking_w)
295295{
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.
297300
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:
300305
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
310311
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.
316313
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.
321319
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". */
324322
325    Musics order is completely guessed but close to what the original PCB game should be */
323/*
3247654 3210
3251010 1010 needs oki2 to be bank 0
3261010 1011 needs oki2 to be bank 1
3271010 1011 needs oki1 to be bank 0
326328
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 };
3297654 3210
3301010 1111 needs oki1 to be bank 1
3311010 1110 needs oki1 to be bank 1
3321010 1110 needs oki2 to be bank 0
329333
330   //popmessage("oki_0 banking value = %X\noki_1 banking value = %X\n",data & 0xf,(data >> 4) & 0xf);
3347654 3210
3350110 0110 needs oki1 to be bank 2
3360110 0110 needs oki2 to be bank 0
331337
332   m_oki_bank_0 = bank_table_0[data & 0xf];
333   m_oki_bank_1 = bank_table_1[data & 0xf];      // (data >> 4) & 0xf ??
3386and!7 & 2and3
334339
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   }
3404and!5 & 0and1
341341
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*/
347343
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));
353346
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);
356351}
357352
353// Some clocking?
358354WRITE32_MEMBER(gstream_state::gstream_oki_4040_w)
359355{
360356   // data == 0 or data == 0x81
r17532r17533
365361   AM_RANGE(0x4010, 0x4013) AM_READ_PORT("IN1")
366362   AM_RANGE(0x4020, 0x4023) AM_READ_PORT("IN2")   // extra coin switches etc
367363   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
371367ADDRESS_MAP_END
372368
373369static INPUT_PORTS_START( gstream )
r17532r17533
545541   state->save_item(NAME(state->m_tmap1_scrolly));
546542   state->save_item(NAME(state->m_tmap2_scrolly));
547543   state->save_item(NAME(state->m_tmap3_scrolly));
548   state->save_item(NAME(state->m_oki_bank_0));
549544   state->save_item(NAME(state->m_oki_bank_1));
545   state->save_item(NAME(state->m_oki_bank_2));
550546}
551547
552548static MACHINE_RESET( gstream )
r17532r17533
559555   state->m_tmap1_scrolly = 0;
560556   state->m_tmap2_scrolly = 0;
561557   state->m_tmap3_scrolly = 0;
562   state->m_oki_bank_0 = 0;
563558   state->m_oki_bank_1 = 0;
559   state->m_oki_bank_2 = 0;
564560}
565561
566562static MACHINE_CONFIG_START( gstream, gstream_state )
r17532r17533
623619   ROM_LOAD( "gs_gr_05.u174", 0x800000, 0x200000, CRC(ef283a73) SHA1(8b598facb344eac33138611abc141a2acb375983) )
624620   ROM_LOAD( "gs_gr_06.u175", 0xa00000, 0x200000, CRC(d4e3a2b2) SHA1(4577c007172c718bf7ca55a8ccee5455c281026c) )
625621
626   ROM_REGION( 0x200000, "oki1", 0 )
622   ROM_REGION( 0x100000, "oki1", 0 )
627623   ROM_LOAD( "gs_snd_01.u192", 0x000000, 0x080000, CRC(79b64d3f) SHA1(b2166210d3a3b85b9ace90749a444c881f69d551) )
628624   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) )
631625
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) )
634629
635630   ROM_REGION( 0x2000, "nvram", 0 )
636631   ROM_LOAD( "gstream.nv", 0x000000, 0x2000, CRC(895d724b) SHA1(97941102f94923220d9beb270939f0ad9a40fe0e) )
r17532r17533
652647}
653648
654649
655GAME( 2002, gstream, 0, gstream, gstream, gstream_state, gstream, ROT270, "Oriental Soft", "G-Stream G2020", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
650GAME( 2002, gstream, 0, gstream, gstream, gstream_state, gstream, ROT270, "Oriental Soft", "G-Stream G2020", GAME_SUPPORTS_SAVE )
651

Previous 199869 Revisions Next


© 1997-2024 The MAME Team