⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 segar.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************

Sega G-80 Raster game sound code

Across these games, there's a mixture of discrete sound circuitry,
speech boards, ADPCM samples, and a TMS3617 music chip.

05-DEC-1998 - MAB:
 - completely rewrote sound code to use Samples interface.
   (It's based on the Zaxxon sndhrdw code.)

TODO:
 - Astro Blaster needs "Attack Rate" modifiers implemented
 - True ADPCM decoding for Monster Bash (NEC7715 chip)
 - Sample support for 005
 - Melody support for 005
 - Sound for Pig Newton
 - Speech for Astro Blaster

- Mike Balfour (mab22@po.cwru.edu)
***************************************************************************/

/* sound: segar.c */

#include "driver.h"

extern void TMS3617_voice_enable(int voice, int enable);
extern void TMS3617_pitch_w(int offset, int pitch);
extern void TMS3617_doupdate(void);

/* Special temporary code for Astro Blaster Speech handling */
#define MAX_SPEECH_QUEUE 10
#define NOT_PLAYING     -1              /* The queue holds the sample # so -1 will indicate no sample */
#define SPEECH_CHANNEL 11           /* Note that Astro Blaster sounds only use tracks 0-10 */

static int speechQueue[MAX_SPEECH_QUEUE];
static int speechQueuePtr = 0;
/* End of speech code */


#define TOTAL_SOUNDS 16

struct sa
{
        int channel;
        int num;
        int looped;
        int stoppable;
        int restartable;
};

const char *astrob_sample_names[] =
{
        "*astrob",
        "invadr1.sam","winvadr1.sam","invadr2.sam","winvadr2.sam",
        "invadr3.sam","winvadr3.sam","invadr4.sam","winvadr4.sam",
        "asteroid.sam","refuel.sam",

        "pbullet.sam","ebullet.sam","eexplode.sam","pexplode.sam",
        "deedle.sam","sonar.sam",

        "01.sam","02.sam","03.sam","04.sam","05.sam","06.sam","07.sam","08.sam",
        "09.sam","0a.sam","0b.sam","0c.sam","0d.sam","0e.sam","0f.sam","10.sam",
        "11.sam","12.sam","13.sam","14.sam","15.sam","16.sam","17.sam","18.sam",
        "19.sam","1a.sam","1b.sam","1c.sam","1d.sam","1e.sam","1f.sam","20.sam",
        "22.sam","23.sam",
        0
};

const char *s005_sample_names[] =
{
        0
};

const char *monsterb_sample_names[] =
{
        "zap.sam","jumpdown.sam","laughter.sam","wolfman.sam","warping.sam","tongue.sam",
        0
};

const char *spaceod_sample_names[] =
{
        "fire.sam", "bomb.sam", "eexplode.sam", "pexplode.sam",
        "warp.sam", "birth.sam", "scoreup.sam", "ssound.sam",
        "accel.sam", "damaged.sam", "erocket.sam",
        0
};

/* Astro Blaster */
enum
{
        invadr1 = 0,winvadr1,invadr2,winvadr2,
        invadr3,winvadr3,invadr4,winvadr4,
        asteroid,refuel,
        pbullet,ebullet,eexplode,pexplode,
        deedle,sonar,
        v01,v02,v03,v04,v05,v06,v07,v08,
        v09,v0a,v0b,v0c,v0d,v0e,v0f,v10,
        v11,v12,v13,v14,v15,v16,v17,v18,
        v19,v1a,v1b,v1c,v1d,v1e,v1f,v20,
        v22,v23
};

/* Monster Bash */
enum
{
        mbzap = 0,mbjumpdown,mblaughter,mbwolfman,mbwarping,mbtongue
};

/* Space Odyssey */
enum
{
        sofire = 0,sobomb,soeexplode,sopexplode,
        sowarp,sobirth,soscoreup,sossound,
        soaccel,sodamaged,soerocket
};


static struct sa astrob_sa[TOTAL_SOUNDS] =
{
        /* Port 0x3E: */
        {  0, invadr1,  1, 1, 1 },      /* Line  0 - Invader 1 */
        {  1, invadr2,  1, 1, 1 },      /* Line  1 - Invader 2 */
        {  2, invadr3,  1, 1, 1 },      /* Line  2 - Invader 3 */
        {  3, invadr4,  1, 1, 1 },      /* Line  3 - Invader 4 */
        {  4, asteroid, 1, 1, 1 },      /* Line  4 - Asteroids */
        { -1 },                                         /* Line  5 - <Mute> */
        {  5, refuel,   1, 1, 1 },      /* Line  6 - Refill */
        { -1 },                                         /* Line  7 - <Warp Modifier> */

        /* Port 0x3F: */
        {  6, pbullet,  0, 0, 1 },      /* Line  0 - Laser #1 */
        {  7, ebullet,  0, 0, 1 },      /* Line  1 - Laser #2 */
        {  8, eexplode, 0, 0, 1 },      /* Line  2 - Short Explosion */
        {  8, pexplode, 0, 0, 1 },      /* Line  3 - Long Explosion */
        { -1 },                                         /* Line  4 - <Attack Rate> */
        { -1 },                                         /* Line  5 - <Rate Reset> */
        {  9, deedle,   0, 0, 1 },      /* Line  6 - Bonus */
        { 10, sonar,    0, 0, 1 },      /* Line  7 - Sonar */
};

static struct sa spaceod_sa[TOTAL_SOUNDS] =
{
        /* Port 0x0E: */
        { -1 },                                                 /* Line  0 - background noise */
        { -1 },                                                 /* Line  1 - unused */
        {  1, soeexplode, 0, 0, 1 },    /* Line  2 - Short Explosion */
        { -1 },                                                 /* Line  3 - unused */
        {  2, soaccel,    0, 0, 1 },    /* Line  4 - Accelerate */
        {  3, soerocket,  0, 0, 1 },    /* Line  5 - Battle Star */
        {  4, sobomb,     0, 0, 1 },    /* Line  6 - D. Bomb */
        {  5, sopexplode, 0, 0, 1 },    /* Line  7 - Long Explosion */
        /* Port 0x0F: */
        {  6, sofire,     0, 0, 1 },    /* Line  0 - Shot */
        {  7, soscoreup,  0, 0, 1 },    /* Line  1 - Bonus Up */
        { -1 },                                                 /* Line  2 - unused */
        {  8, sowarp,     0, 0, 1 },    /* Line  3 - Warp */
        { -1 },                                                 /* Line  4 - unused */
        { -1 },                                                 /* Line  5 - unused */
        {  9, sobirth,    0, 0, 1 },    /* Line  6 - Appearance UFO */
        { 10, sodamaged,  0, 0, 1 },    /* Line  7 - Black Hole */
};


/* Special speech handling code.  Someday this will hopefully be
   replaced with true speech synthesis. */
int astrob_speech_sh_start(void)
{
   int i;

   for (i = 0; i < MAX_SPEECH_QUEUE; i++)
   {
      speechQueue[i] = NOT_PLAYING;
   }
   speechQueuePtr = 0;

   return 0;
}

void astrob_speech_sh_update (void)
{
        int sound;

        if( Machine->samples == 0 )
                return;

        if (speechQueue[speechQueuePtr] != NOT_PLAYING)
        {
                sound = speechQueue[speechQueuePtr];

                if (!sample_playing(SPEECH_CHANNEL))
                {
                      if (Machine->samples->sample[sound])
                        sample_start(SPEECH_CHANNEL, sound, 0);
                      speechQueue[speechQueuePtr] = NOT_PLAYING;
                      speechQueuePtr = ((speechQueuePtr + 1) % MAX_SPEECH_QUEUE);
                }
   }
}


static void astrob_queue_speech(int sound)
{
    int newPtr;

    /* Queue the new sound */
    newPtr = speechQueuePtr;
    while (speechQueue[newPtr] != NOT_PLAYING)
    {
        newPtr = ((newPtr + 1) % MAX_SPEECH_QUEUE);
        if (newPtr == speechQueuePtr)
        {
             /* The queue has overflowed. Oops. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -