|
|
| version 1.1.1.1, 2003/10/16 17:58:29 | version 1.8, 2004/05/15 16:26:54 |
|---|---|
| Line 2 | Line 2 |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "fdd_mtr.h" | #include "fdd_mtr.h" |
| #if defined(SUPPORT_SWSEEKSND) | |
| #include "sound.h" | |
| #include "fdd_mtr.res" | |
| #endif | |
| #if defined(SUPPORT_SWSEEKSND) | |
| static struct { | |
| UINT enable; | |
| struct { | |
| PMIXHDR hdr; | |
| PMIXTRK trk[2]; | |
| } snd; | |
| } mtrsnd; | |
| void fddmtrsnd_initialize(UINT rate) { | |
| ZeroMemory(&mtrsnd, sizeof(mtrsnd)); | |
| if (np2cfg.MOTORVOL) { | |
| mtrsnd.enable = 1; | |
| mtrsnd.snd.hdr.enable = 3; | |
| pcmmix_regist(&mtrsnd.snd.trk[0].data, | |
| (void *)fddseek, sizeof(fddseek), rate); | |
| mtrsnd.snd.trk[0].flag = PMIXFLAG_L | PMIXFLAG_R | PMIXFLAG_LOOP; | |
| mtrsnd.snd.trk[0].volume = (np2cfg.MOTORVOL << 12) / 100; | |
| pcmmix_regist(&mtrsnd.snd.trk[1].data, | |
| (void *)fddseek1, sizeof(fddseek1), rate); | |
| mtrsnd.snd.trk[1].flag = PMIXFLAG_L | PMIXFLAG_R; | |
| mtrsnd.snd.trk[1].volume = (np2cfg.MOTORVOL << 12) / 100; | |
| } | |
| } | |
| void fddmtrsnd_bind(void) { | |
| if (mtrsnd.enable) { | |
| sound_streamregist(&mtrsnd.snd, (SOUNDCB)pcmmix_getpcm); | |
| } | |
| } | |
| void fddmtrsnd_deinitialize(void) { | |
| int i; | |
| void *ptr; | |
| for (i=0; i<2; i++) { | |
| ptr = mtrsnd.snd.trk[i].data.sample; | |
| mtrsnd.snd.trk[i].data.sample = NULL; | |
| if (ptr) { | |
| _MFREE(ptr); | |
| } | |
| } | |
| } | |
| static void fddmtrsnd_play(UINT num, BOOL play) { | |
| PMIXTRK *trk; | |
| int fddmtr_biosbusy = 0; // ver0.26 | if ((mtrsnd.enable) && (num < 2)) { |
| static BYTE mtr_curevent = 0; | sound_sync(); |
| static UINT nextevent = 0; | trk = mtrsnd.snd.trk + num; |
| static BYTE FDC_HEAD[4] = {0, 0, 0, 0}; | if (play) { |
| static BYTE curdrv = 0; | if (trk->data.sample) { |
| trk->pcm = trk->data.sample; | |
| trk->remain = trk->data.samples; | |
| mtrsnd.snd.hdr.playing |= (1 << num); | |
| } | |
| } | |
| else { | |
| mtrsnd.snd.hdr.playing &= ~(1 << num); | |
| } | |
| } | |
| } | |
| #endif | |
| // ---- | |
| enum { | enum { |
| MOVE1TCK_MS = 15, | MOVE1TCK_MS = 15, |
| Line 16 enum { | Line 86 enum { |
| DISK1ROL_MS = 166 | DISK1ROL_MS = 166 |
| }; | }; |
| _FDDMTR fddmtr; | |
| static void fddmtr_event(void) { | static void fddmtr_event(void) { |
| switch(mtr_curevent) { | switch(fddmtr.curevent) { |
| case 100: | case 100: |
| #if defined(SUPPORT_SWSEEKSND) | |
| fddmtrsnd_play(0, FALSE); | |
| #else | |
| soundmng_pcmstop(SOUND_PCMSEEK); | soundmng_pcmstop(SOUND_PCMSEEK); |
| mtr_curevent = 0; | #endif |
| fddmtr.curevent = 0; | |
| break; | break; |
| default: | default: |
| mtr_curevent = 0; | fddmtr.curevent = 0; |
| break; | break; |
| } | } |
| } | } |
| void fddmtr_init(void) { | void fddmtr_initialize(void) { |
| fddmtr_event(); | #if defined(SUPPORT_SWSEEKSND) |
| FillMemory(FDC_HEAD, sizeof(FDC_HEAD), 42); | fddmtrsnd_play(0, FALSE); |
| #else | |
| soundmng_pcmstop(SOUND_PCMSEEK); | |
| #endif | |
| ZeroMemory(&fddmtr, sizeof(fddmtr)); | |
| FillMemory(fddmtr.head, sizeof(fddmtr.head), 42); | |
| } | } |
| void fddmtr_callback(UINT time) { | void fddmtr_callback(UINT time) { |
| if ((mtr_curevent) && (time >= nextevent)) { | if ((fddmtr.curevent) && (time >= fddmtr.nextevent)) { |
| fddmtr_event(); | fddmtr_event(); |
| } | } |
| } | } |
| void fdbiosout(NEVENTITEM item) { | void fdbiosout(NEVENTITEM item) { |
| fddmtr_biosbusy = 0; | fddmtr.busy = 0; |
| (void)item; | (void)item; |
| } | } |
| void fddmtr_seek(BYTE drv, BYTE c, UINT size) { | void fddmtr_seek(REG8 drv, REG8 c, UINT size) { |
| int regmove = 0; | int regmove; |
| SINT32 waitms = 0; | SINT32 waitcnt; |
| drv &= 3; | |
| regmove = c - fddmtr.head[drv]; | |
| fddmtr.head[drv] = c; | |
| if (c != 0xff) { | |
| regmove = FDC_HEAD[curdrv] - c; | |
| FDC_HEAD[curdrv] = c; | |
| } | |
| if (!np2cfg.MOTOR) { | if (!np2cfg.MOTOR) { |
| SINT32 s = size * pc.multiple; | if (size) { |
| if (s) { // ver0.28 | fddmtr.busy = 1; |
| fddmtr_biosbusy = 1; | nevent_set(NEVENT_FDBIOSBUSY, size * pccore.multiple, |
| nevent_set(NEVENT_FDBIOSBUSY, s, fdbiosout, NEVENT_ABSOLUTE); | fdbiosout, NEVENT_ABSOLUTE); |
| } | } |
| return; | return; |
| } | } |
| if (regmove < 0) { // ver0.26 | waitcnt = (size * DISK1ROL_MS) / (1024 * 8); |
| regmove *= (-1); | if (regmove < 0) { |
| regmove = 0 - regmove; | |
| } | } |
| if (regmove == 1) { | if (regmove == 1) { |
| if (mtr_curevent < 80) { | if (fddmtr.curevent < 80) { |
| fddmtr_event(); | fddmtr_event(); |
| #if defined(SUPPORT_SWSEEKSND) | |
| fddmtrsnd_play(1, TRUE); | |
| #else | |
| soundmng_pcmplay(SOUND_PCMSEEK1, FALSE); | soundmng_pcmplay(SOUND_PCMSEEK1, FALSE); |
| mtr_curevent = 80; | #endif |
| nextevent = GETTICK() + MOVEMOTOR1_MS; | fddmtr.curevent = 80; |
| fddmtr.nextevent = GETTICK() + MOVEMOTOR1_MS; | |
| } | } |
| } | } |
| else if (regmove) { | else if (regmove) { |
| if (mtr_curevent < 100) { | if (fddmtr.curevent < 100) { |
| fddmtr_event(); | fddmtr_event(); |
| #if defined(SUPPORT_SWSEEKSND) | |
| fddmtrsnd_play(0, TRUE); | |
| #else | |
| soundmng_pcmplay(SOUND_PCMSEEK, TRUE); | soundmng_pcmplay(SOUND_PCMSEEK, TRUE); |
| mtr_curevent = 100; | #endif |
| nextevent = GETTICK() + (regmove * MOVE1TCK_MS); | fddmtr.curevent = 100; |
| fddmtr.nextevent = GETTICK() + (regmove * MOVE1TCK_MS); | |
| } | } |
| if (regmove >= 32) { | if (regmove >= 32) { |
| waitms += DISK1ROL_MS; | waitcnt += DISK1ROL_MS; |
| } | } |
| } | } |
| waitms += (size * DISK1ROL_MS) / (1024 * 8); | if (waitcnt) { |
| if (waitms) { | fddmtr.busy = 1; |
| fddmtr_biosbusy = 1; | nevent_setbyms(NEVENT_FDBIOSBUSY, |
| nevent_setbyms(NEVENT_FDBIOSBUSY, waitms, fdbiosout, NEVENT_ABSOLUTE); | waitcnt, fdbiosout, NEVENT_ABSOLUTE); |
| } | } |
| (void)drv; | (void)drv; |
| } | } |