Remove built-in speaker support
The changes to amiga, mac and msdos builds are untested.
This commit is contained in:
@@ -182,7 +182,7 @@ MAKEDEFOBJ = \
|
||||
$(O)monstr.o
|
||||
|
||||
AMIGAOBJ = \
|
||||
$(O)amidos.o $(O)amirip.o $(O)amisnd.o $(O)amistack.o \
|
||||
$(O)amidos.o $(O)amirip.o $(O)amistack.o \
|
||||
$(O)amiwind.o $(O)winami.o $(O)winchar.o $(O)winfuncs.o \
|
||||
$(O)winkey.o $(O)winmenu.o $(O)winreq.o $(O)winstr.o
|
||||
|
||||
@@ -268,16 +268,6 @@ XDFILES= $(ADFILES) $(BDFILES) $(CDFILES) $(HDFILES) $(KDFILES) \
|
||||
$(MDFILES) $(PDFILES) $(RDFILES) $(RANFILES) $(SDFILES) $(TDFILES) \
|
||||
$(VDFILES) $(WDFILES)
|
||||
|
||||
SOUNDFILES= \
|
||||
$(SBIN)cvtsnd \
|
||||
$(SLIB)sounds \
|
||||
$(SLIB)sounds/Bell $(SLIB)sounds/Bugle \
|
||||
$(SLIB)sounds/Drum_Of_Earthquake \
|
||||
$(SLIB)sounds/Fire_Horn $(SLIB)sounds/Frost_Horn \
|
||||
$(SLIB)sounds/Leather_Drum $(SLIB)sounds/Magic_Flute \
|
||||
$(SLIB)sounds/Magic_Harp $(SLIB)sounds/Tooled_Horn \
|
||||
$(SLIB)sounds/Wooden_Flute $(SLIB)sounds/Wooden_Harp
|
||||
|
||||
TILEFILES= \
|
||||
$(SBIN)txt2iff \
|
||||
$(NETHACK)tiles \
|
||||
@@ -327,7 +317,7 @@ all: $(COMPACT_HEADERS) $(SBIN)lev_comp $(SBIN)dgn_comp $(SBIN)NetHack \
|
||||
$(SBIN)dlb $(NETHACK)recover #$(NETHACK)HackCli $(SBIN)splitter \
|
||||
# $(NETHACK)HackWB
|
||||
|
||||
install: inst-data inst-dungeon inst-fonts inst-sounds inst-tiles \
|
||||
install: inst-data inst-dungeon inst-fonts inst-tiles \
|
||||
$(NETHACK)recover $(NETHACK)NetHack $(NETHACK)nhdat
|
||||
#$(NETHACK)NetHack.dir inst-icons
|
||||
|
||||
@@ -376,7 +366,7 @@ clean:
|
||||
|
||||
spotless: clean
|
||||
-delete $(SBIN)NetHack $(SBIN)lev_comp $(SBIN)makedefs $(SBIN)dgn_comp
|
||||
-delete $(SBIN)cvtsnd $(SBIN)dlb $(SBIN)txt2iff $(SBIN)splitter
|
||||
-delete $(SBIN)dlb $(SBIN)txt2iff $(SBIN)splitter
|
||||
-delete $(SBIN)tilemap
|
||||
-delete $(SLIB)data $(SLIB)rumors
|
||||
-delete $(SLIB)\#?.lev
|
||||
@@ -568,8 +558,6 @@ $(O)amirip.o: $(AMI)amirip.c $(HDEP)
|
||||
$(O)aglue.o: $(AMI)aglue.a
|
||||
$(ASM) $(AFLAGS) $(AOBJSPEC)$(O)aglue.o $(AMI)aglue.a
|
||||
|
||||
$(O)amisnd.o: $(AMI)amisnd.c $(HDEP)
|
||||
|
||||
$(O)winchar.o: $(AMI)winchar.c $(NHS)tile.c $(HDEP)
|
||||
|
||||
$(NHS)tile.c: $(WSHARE)tilemap.c
|
||||
@@ -698,79 +686,6 @@ $(NETHACK)tiles/monsters.iff: $(WSHARE)monsters.txt $(SBIN)txt2iff
|
||||
$(NETHACK)tiles/other.iff: $(WSHARE)other.txt $(SBIN)txt2iff
|
||||
$(SBIN)txt2iff $(WSHARE)other.txt $(NETHACK)tiles/other.iff
|
||||
|
||||
# Sound installation rules.
|
||||
inst-sounds: $(SOUNDFILES)
|
||||
list to T:nhsdat.lst $(SLIB)sounds QUICK NOHEAD
|
||||
echo >T:make-nhsdat $(SBIN)dlb cCfI $(SLIB)sounds $(NETHACK)nhsdat T:nhsdat.lst
|
||||
echo >>T:make-nhsdat if not exists $(NETHACK)nhsdat
|
||||
echo >>T:make-nhsdat copy $(SLIB)sounds/\#? $(NETHACK)sounds
|
||||
echo >>T:make-nhsdat endif
|
||||
execute T:make-nhsdat
|
||||
-delete T:make-nhsdat
|
||||
|
||||
$(SLIB)sounds:
|
||||
-makedir $(SLIB)sounds
|
||||
|
||||
$(SBIN)cvtsnd: $(OO)cvtsnd.o
|
||||
$(LINK) $(LNSPEC) $@ $(LIN) $(OO)cvtsnd.o $(FLLIB)
|
||||
|
||||
$(OO)cvtsnd.o: $(AMI)cvtsnd.c
|
||||
|
||||
$(SLIB)sounds/Bell: $(SHARE)sounds/bell.uu
|
||||
$(UUDEC) $(SHARE)sounds/bell.uu
|
||||
$(SBIN)cvtsnd Bell $(SLIB)sounds/Bell
|
||||
-delete Bell
|
||||
|
||||
$(SLIB)sounds/Bugle: $(SHARE)sounds/bugle.uu
|
||||
$(UUDEC) $(SHARE)sounds/bugle.uu
|
||||
$(SBIN)cvtsnd Bugle $(SLIB)sounds/Bugle
|
||||
-delete Bugle
|
||||
|
||||
$(SLIB)sounds/Drum_Of_Earthquake: $(SHARE)sounds/erthdrum.uu
|
||||
$(UUDEC) $(SHARE)sounds/erthdrum.uu
|
||||
$(SBIN)cvtsnd Drum_Of_Earthquake $(SLIB)sounds/Drum_Of_Earthquake
|
||||
-delete Drum_Of_Earthquake
|
||||
|
||||
$(SLIB)sounds/Fire_Horn: $(SHARE)sounds/firehorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/firehorn.uu
|
||||
$(SBIN)cvtsnd Fire_Horn $(SLIB)sounds/Fire_Horn
|
||||
-delete Fire_Horn
|
||||
|
||||
$(SLIB)sounds/Frost_Horn: $(SHARE)sounds/frsthorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/frsthorn.uu
|
||||
$(SBIN)cvtsnd Frost_Horn $(SLIB)sounds/Frost_Horn
|
||||
-delete Frost_Horn
|
||||
|
||||
$(SLIB)sounds/Leather_Drum: $(SHARE)sounds/lethdrum.uu
|
||||
$(UUDEC) $(SHARE)sounds/lethdrum.uu
|
||||
$(SBIN)cvtsnd Leather_Drum $(SLIB)sounds/Leather_Drum
|
||||
-delete Leather_Drum
|
||||
|
||||
$(SLIB)sounds/Magic_Flute: $(SHARE)sounds/mgcflute.uu
|
||||
$(UUDEC) $(SHARE)sounds/mgcflute.uu
|
||||
$(SBIN)cvtsnd Magic_Flute $(SLIB)sounds/Magic_Flute
|
||||
-delete Magic_Flute
|
||||
|
||||
$(SLIB)sounds/Magic_Harp: $(SHARE)sounds/mgcharp.uu
|
||||
$(UUDEC) $(SHARE)sounds/mgcharp.uu
|
||||
$(SBIN)cvtsnd Magic_Harp $(SLIB)sounds/Magic_Harp
|
||||
-delete Magic_Harp
|
||||
|
||||
$(SLIB)sounds/Tooled_Horn: $(SHARE)sounds/toolhorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/toolhorn.uu
|
||||
$(SBIN)cvtsnd Tooled_Horn $(SLIB)sounds/Tooled_Horn
|
||||
-delete Tooled_Horn
|
||||
|
||||
$(SLIB)sounds/Wooden_Flute: $(SHARE)sounds/wdnflute.uu
|
||||
$(UUDEC) $(SHARE)sounds/wdnflute.uu
|
||||
$(SBIN)cvtsnd Wooden_Flute $(SLIB)sounds/Wooden_Flute
|
||||
-delete Wooden_Flute
|
||||
|
||||
$(SLIB)sounds/Wooden_Harp: $(SHARE)sounds/wdnharp.uu
|
||||
$(UUDEC) $(SHARE)sounds/wdnharp.uu
|
||||
$(SBIN)cvtsnd Wooden_Harp $(SLIB)sounds/Wooden_Harp
|
||||
-delete Wooden_Harp
|
||||
|
||||
inst-dungeon: $(INSTDUNGEONFILES)
|
||||
|
||||
$(NETHACK)options : $(DAT)options
|
||||
|
||||
@@ -389,7 +389,7 @@ MAKEDEFOBJ = \
|
||||
$(O)monstr.o
|
||||
|
||||
AMIGAOBJ = \
|
||||
$(O)amidos.o $(O)amirip.o $(O)amisnd.o $(O)amistack.o \
|
||||
$(O)amidos.o $(O)amirip.o $(O)amistack.o \
|
||||
$(O)amiwind.o $(O)winami.o $(O)winchar.o $(O)winfuncs.o \
|
||||
$(O)winkey.o $(O)winmenu.o $(O)winreq.o $(O)winstr.o
|
||||
|
||||
@@ -475,16 +475,6 @@ XDFILES= $(ADFILES) $(BDFILES) $(CDFILES) $(HDFILES) $(KDFILES) \
|
||||
$(MDFILES) $(PDFILES) $(RDFILES) $(RANFILES) $(SDFILES) $(TDFILES) \
|
||||
$(VDFILES) $(WDFILES)
|
||||
|
||||
SOUNDFILES= \
|
||||
$(SBIN)cvtsnd \
|
||||
$(SLIB)sounds \
|
||||
$(SLIB)sounds/Bell $(SLIB)sounds/Bugle \
|
||||
$(SLIB)sounds/Drum_Of_Earthquake \
|
||||
$(SLIB)sounds/Fire_Horn $(SLIB)sounds/Frost_Horn \
|
||||
$(SLIB)sounds/Leather_Drum $(SLIB)sounds/Magic_Flute \
|
||||
$(SLIB)sounds/Magic_Harp $(SLIB)sounds/Tooled_Horn \
|
||||
$(SLIB)sounds/Wooden_Flute $(SLIB)sounds/Wooden_Harp
|
||||
|
||||
TILEFILES= \
|
||||
$(SBIN)txt2iff \
|
||||
$(NETHACK)tiles \
|
||||
@@ -533,7 +523,7 @@ LIBFILES= \
|
||||
all: $(COMPACT_HEADERS) $(SBIN)lev_comp $(SBIN)dgn_comp $(SBIN)NetHack \
|
||||
$(SBIN)dlb $(NETHACK)recover
|
||||
|
||||
install: all inst-data inst-dungeon inst-fonts inst-sounds inst-tiles \
|
||||
install: all inst-data inst-dungeon inst-fonts inst-tiles \
|
||||
$(NETHACK)nhdat $(NETHACK)NetHack
|
||||
|
||||
$(SBIN)NetHack: $(HOBJ) $(AMI)ami.lnk
|
||||
@@ -604,7 +594,7 @@ clean:
|
||||
|
||||
spotless: clean
|
||||
-delete $(SBIN)NetHack $(SBIN)lev_comp $(SBIN)makedefs $(SBIN)dgn_comp
|
||||
-delete $(SBIN)cvtsnd $(SBIN)dlb $(SBIN)txt2iff $(SBIN)splitter
|
||||
-delete $(SBIN)dlb $(SBIN)txt2iff $(SBIN)splitter
|
||||
-delete $(SBIN)tilemap
|
||||
-delete $(SLIB)data $(SLIB)rumors
|
||||
-delete $(SLIB)\#?.lev
|
||||
@@ -839,8 +829,6 @@ $(O)amirip.o: $(AMI)amirip.c $(HDEP)
|
||||
$(O)aglue.o: $(AMI)aglue.a
|
||||
$(ASM) $(AFLAGS) $(AOBJSPEC)$(O)aglue.o $(AMI)aglue.a
|
||||
|
||||
$(O)amisnd.o: $(AMI)amisnd.c $(HDEP)
|
||||
|
||||
$(O)winchar.o: $(AMI)winchar.c $(NHS)tile.c $(HDEP)
|
||||
|
||||
$(NHS)tile.c: $(WSHARE)tilemap.c
|
||||
@@ -972,82 +960,6 @@ $(NETHACK)tiles/monsters.iff: $(WSHARE)monsters.txt $(SBIN)txt2iff
|
||||
$(NETHACK)tiles/other.iff: $(WSHARE)other.txt $(SBIN)txt2iff
|
||||
$(SBIN)txt2iff $(WSHARE)other.txt $(NETHACK)tiles/other.iff
|
||||
|
||||
# Sound installation rules.
|
||||
inst-sounds: $(SOUNDFILES)
|
||||
list to T:nhsdat.lst $(SLIB)sounds QUICK NOHEAD
|
||||
echo >T:make-nhsdat $(SBIN)dlb cCfI $(SLIB)sounds $(NETHACK)nhsdat T:nhsdat.lst
|
||||
echo >>T:make-nhsdat if not exists $(NETHACK)nhsdat
|
||||
echo >>T:make-nhsdat copy $(SLIB)sounds/\#? $(NETHACK)sounds
|
||||
echo >>T:make-nhsdat endif
|
||||
execute T:make-nhsdat
|
||||
-delete T:make-nhsdat
|
||||
|
||||
#SFD_INSTEAD $(SLIB)sounds: $(SLIB)sounds
|
||||
$(SLIB)sounds:
|
||||
-makedir $(SLIB)sounds
|
||||
|
||||
$(SBIN)cvtsnd: $(OO)cvtsnd.o
|
||||
$(LINK) $(LNSPEC) $@ $(LIN) $(OO)cvtsnd.o $(FLLIB)
|
||||
|
||||
$(OO)cvtsnd.o: $(AMI)cvtsnd.c
|
||||
#SFD_INSTEAD $(CC) $(CFLAGS) $(OBJSPEC)%(left) %(right)
|
||||
#none
|
||||
|
||||
$(SLIB)sounds/Bell: $(SHARE)sounds/bell.uu
|
||||
$(UUDEC) $(SHARE)sounds/bell.uu
|
||||
$(SBIN)cvtsnd Bell $(SLIB)sounds/Bell
|
||||
-delete Bell
|
||||
|
||||
$(SLIB)sounds/Bugle: $(SHARE)sounds/bugle.uu
|
||||
$(UUDEC) $(SHARE)sounds/bugle.uu
|
||||
$(SBIN)cvtsnd Bugle $(SLIB)sounds/Bugle
|
||||
-delete Bugle
|
||||
|
||||
$(SLIB)sounds/Drum_Of_Earthquake: $(SHARE)sounds/erthdrum.uu
|
||||
$(UUDEC) $(SHARE)sounds/erthdrum.uu
|
||||
$(SBIN)cvtsnd Drum_Of_Earthquake $(SLIB)sounds/Drum_Of_Earthquake
|
||||
-delete Drum_Of_Earthquake
|
||||
|
||||
$(SLIB)sounds/Fire_Horn: $(SHARE)sounds/firehorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/firehorn.uu
|
||||
$(SBIN)cvtsnd Fire_Horn $(SLIB)sounds/Fire_Horn
|
||||
-delete Fire_Horn
|
||||
|
||||
$(SLIB)sounds/Frost_Horn: $(SHARE)sounds/frsthorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/frsthorn.uu
|
||||
$(SBIN)cvtsnd Frost_Horn $(SLIB)sounds/Frost_Horn
|
||||
-delete Frost_Horn
|
||||
|
||||
$(SLIB)sounds/Leather_Drum: $(SHARE)sounds/lethdrum.uu
|
||||
$(UUDEC) $(SHARE)sounds/lethdrum.uu
|
||||
$(SBIN)cvtsnd Leather_Drum $(SLIB)sounds/Leather_Drum
|
||||
-delete Leather_Drum
|
||||
|
||||
$(SLIB)sounds/Magic_Flute: $(SHARE)sounds/mgcflute.uu
|
||||
$(UUDEC) $(SHARE)sounds/mgcflute.uu
|
||||
$(SBIN)cvtsnd Magic_Flute $(SLIB)sounds/Magic_Flute
|
||||
-delete Magic_Flute
|
||||
|
||||
$(SLIB)sounds/Magic_Harp: $(SHARE)sounds/mgcharp.uu
|
||||
$(UUDEC) $(SHARE)sounds/mgcharp.uu
|
||||
$(SBIN)cvtsnd Magic_Harp $(SLIB)sounds/Magic_Harp
|
||||
-delete Magic_Harp
|
||||
|
||||
$(SLIB)sounds/Tooled_Horn: $(SHARE)sounds/toolhorn.uu
|
||||
$(UUDEC) $(SHARE)sounds/toolhorn.uu
|
||||
$(SBIN)cvtsnd Tooled_Horn $(SLIB)sounds/Tooled_Horn
|
||||
-delete Tooled_Horn
|
||||
|
||||
$(SLIB)sounds/Wooden_Flute: $(SHARE)sounds/wdnflute.uu
|
||||
$(UUDEC) $(SHARE)sounds/wdnflute.uu
|
||||
$(SBIN)cvtsnd Wooden_Flute $(SLIB)sounds/Wooden_Flute
|
||||
-delete Wooden_Flute
|
||||
|
||||
$(SLIB)sounds/Wooden_Harp: $(SHARE)sounds/wdnharp.uu
|
||||
$(UUDEC) $(SHARE)sounds/wdnharp.uu
|
||||
$(SBIN)cvtsnd Wooden_Harp $(SLIB)sounds/Wooden_Harp
|
||||
-delete Wooden_Harp
|
||||
|
||||
inst-dungeon: $(INSTDUNGEONFILES)
|
||||
|
||||
$(NETHACK)options : $(DAT)options
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
/* NetHack 3.6 amisnd.c $NHDT-Date: 1432512796 2015/05/25 00:13:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* Copyright (c) 1992, 1993, 1995 by Gregg Wonderly */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/*
|
||||
* This file contains music playing code.
|
||||
*
|
||||
* If we were REALLY determined, we would make the sound play
|
||||
* asynchronously, but I'll save that one for a rainy day...
|
||||
*/
|
||||
|
||||
#include "hack.h"
|
||||
#include "dlb.h"
|
||||
|
||||
#undef red
|
||||
#undef blue
|
||||
#undef green
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <exec/io.h>
|
||||
#include <devices/audio.h>
|
||||
#include <dos/dos.h>
|
||||
#include <dos/dosextens.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
|
||||
#include <proto/exec.h>
|
||||
#include <clib/alib_protos.h>
|
||||
#include <proto/dos.h>
|
||||
#include <proto/graphics.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define AMII_AVERAGE_VOLUME 60
|
||||
|
||||
int amii_volume = AMII_AVERAGE_VOLUME;
|
||||
|
||||
typedef struct VHDR {
|
||||
char name[4];
|
||||
long len;
|
||||
unsigned long oneshot, repeat, samples;
|
||||
UWORD freq;
|
||||
UBYTE n_octaves, compress;
|
||||
LONG volume;
|
||||
} VHDR;
|
||||
|
||||
typedef struct IFFHEAD {
|
||||
char FORM[4];
|
||||
long flen;
|
||||
char _8SVX[4];
|
||||
VHDR vhdr;
|
||||
char NAME[4];
|
||||
long namelen;
|
||||
} IFFHEAD;
|
||||
|
||||
extern struct GfxBase *GfxBase;
|
||||
|
||||
UBYTE whichannel[] = { 1, 2, 4, 8 };
|
||||
void makesound(char *, char *, int vol);
|
||||
void amii_speaker(struct obj *instr, char *melody, int vol);
|
||||
|
||||
/* A major scale in indexs to freqtab... */
|
||||
int notetab[] = { 0, 2, 4, 5, 7, 9, 11, 12 };
|
||||
|
||||
/* Frequencies for a scale starting at one octave below 'middle C' */
|
||||
long freqtab[] = {
|
||||
220, /*A */
|
||||
233, /*Bb*/
|
||||
246, /*B */
|
||||
261, /*C */
|
||||
277, /*Db*/
|
||||
293, /*D */
|
||||
311, /*Eb*/
|
||||
329, /*E */
|
||||
349, /*F */
|
||||
370, /*Gb*/
|
||||
392, /*G */
|
||||
415, /*Ab*/
|
||||
440, /*A */
|
||||
};
|
||||
|
||||
#ifdef TESTING
|
||||
main(argc, argv) int argc;
|
||||
char **argv;
|
||||
{
|
||||
makesound("wooden_flute", "AwBwCwDwEwFwGwawbwcwdwewfwgw", 60);
|
||||
makesound("wooden_flute", "AhBhChDhEhFhGhahbhchdhehfhgh", 60);
|
||||
makesound("wooden_flute", "AqBqCqDqEqFqGqaqbqcqdqeqfqgq", 60);
|
||||
makesound("wooden_flute", "AeBeCeDeEeFeGeaebecedeeefege", 60);
|
||||
makesound("wooden_flute", "AxBxCxDxExFxGxaxbxcxdxexfxgx", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
|
||||
}
|
||||
#else
|
||||
void
|
||||
amii_speaker(struct obj *instr, char *melody, int vol)
|
||||
{
|
||||
int typ = instr->otyp;
|
||||
char *actualn = (char *) OBJ_NAME(objects[typ]);
|
||||
|
||||
/* Make volume be relative to users volume level, with 60 being the
|
||||
* average level that will be passed to us.
|
||||
*/
|
||||
vol = vol * amii_volume / AMII_AVERAGE_VOLUME;
|
||||
|
||||
makesound(actualn, melody, vol);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
makesound(char *actualn, char *melody, int vol)
|
||||
{
|
||||
char *t;
|
||||
int c, cycles, dot, dlay;
|
||||
dlb *stream = 0;
|
||||
IFFHEAD iffhead;
|
||||
struct IOAudio *AudioIO = 0;
|
||||
struct MsgPort *AudioMP = 0;
|
||||
struct Message *AudioMSG = 0;
|
||||
ULONG device = -1;
|
||||
BYTE *waveptr = 0;
|
||||
LONG frequency = 440, duration = 1, clock, samp, samples, samcyc = 1;
|
||||
unsigned char name[100];
|
||||
|
||||
if (flags.silent)
|
||||
return;
|
||||
|
||||
if (GfxBase->DisplayFlags & PAL)
|
||||
clock = 3546895;
|
||||
else
|
||||
clock = 3579545;
|
||||
|
||||
/*
|
||||
* Convert type to file name - if there's nothing to play we
|
||||
* shouldn't be here in the first place.
|
||||
*/
|
||||
strncpy(name, actualn, sizeof(name));
|
||||
for (t = strchr(name, ' '); t; t = strchr(name, ' '))
|
||||
*t = '_';
|
||||
if ((stream = dlb_fopen(name, "r")) == NULL) {
|
||||
perror(name);
|
||||
return;
|
||||
}
|
||||
|
||||
AudioIO = (struct IOAudio *) AllocMem(sizeof(struct IOAudio),
|
||||
MEMF_PUBLIC | MEMF_CLEAR);
|
||||
if (AudioIO == 0)
|
||||
goto killaudio;
|
||||
|
||||
AudioMP = CreateMsgPort();
|
||||
if (AudioMP == 0)
|
||||
goto killaudio;
|
||||
|
||||
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
|
||||
AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri = 0;
|
||||
AudioIO->ioa_Request.io_Command = ADCMD_ALLOCATE;
|
||||
AudioIO->ioa_Request.io_Flags = ADIOF_NOWAIT;
|
||||
AudioIO->ioa_AllocKey = 0;
|
||||
AudioIO->ioa_Data = whichannel;
|
||||
AudioIO->ioa_Length = sizeof(whichannel);
|
||||
|
||||
device = OpenDevice(AUDIONAME, 0L, (struct IORequest *) AudioIO, 0L);
|
||||
if (device != 0)
|
||||
goto killaudio;
|
||||
|
||||
if (dlb_fread((genericptr_t) &iffhead, sizeof(iffhead), 1, stream) != 1)
|
||||
goto killaudio;
|
||||
|
||||
/* This is an even number of bytes long */
|
||||
if (dlb_fread(name, (iffhead.namelen + 1) & ~1, 1, stream) != 1)
|
||||
goto killaudio;
|
||||
|
||||
if (dlb_fread((genericptr_t) &samples, 4, 1, stream) != 1)
|
||||
goto killaudio;
|
||||
|
||||
if (dlb_fread((genericptr_t) &samples, 4, 1, stream) != 1)
|
||||
goto killaudio;
|
||||
|
||||
waveptr = AllocMem(samples, MEMF_CHIP | MEMF_PUBLIC);
|
||||
if (!waveptr)
|
||||
goto killaudio;
|
||||
|
||||
if (dlb_fread(waveptr, samples, 1, stream) != 1)
|
||||
goto killaudio;
|
||||
|
||||
while (melody[0] && melody[1]) {
|
||||
c = *melody++;
|
||||
duration = *melody++;
|
||||
dot = 0;
|
||||
if (*melody == '.') {
|
||||
dot = 1;
|
||||
++melody;
|
||||
}
|
||||
switch (duration) {
|
||||
case 'w':
|
||||
dlay = 3;
|
||||
duration = 1;
|
||||
cycles = 1;
|
||||
break;
|
||||
case 'h':
|
||||
dlay = 3;
|
||||
duration = 2;
|
||||
cycles = 1;
|
||||
break;
|
||||
case 'q':
|
||||
dlay = 2;
|
||||
duration = 4;
|
||||
cycles = 1;
|
||||
break;
|
||||
case 'e':
|
||||
dlay = 1;
|
||||
duration = 8;
|
||||
cycles = 1;
|
||||
break;
|
||||
case 'x':
|
||||
dlay = 0;
|
||||
duration = 16;
|
||||
cycles = 1;
|
||||
break;
|
||||
case 't':
|
||||
dlay = 0;
|
||||
duration = 32;
|
||||
cycles = 1;
|
||||
break;
|
||||
default:
|
||||
goto killaudio; /* unrecognized duration */
|
||||
}
|
||||
|
||||
/* Lower case characters are one octave above upper case */
|
||||
switch (c) {
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
c -= 'a' - 7;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
c -= 'A';
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
samcyc = samples;
|
||||
|
||||
/* lowercase start at middle 'C', upper case are one octave below */
|
||||
frequency = c > 7 ? freqtab[notetab[c % 7]] * 2 : freqtab[notetab[c]];
|
||||
|
||||
/* We can't actually do a dotted whole note unless we add code for a
|
||||
* real
|
||||
* 8SVX sample which includes sustain sample information to tell us
|
||||
* how
|
||||
* to hold the note steady... So when duration == 1, ignore 'dot'...
|
||||
*/
|
||||
if (dot && duration > 1)
|
||||
samp = ((samples / duration) * 3) / 2;
|
||||
else
|
||||
samp = samples / duration;
|
||||
|
||||
/* Only use some of the samples based on frequency */
|
||||
samp = frequency * samp / 880;
|
||||
|
||||
/* The 22khz samples are middle C samples, so adjust the play
|
||||
* back frequency accordingly
|
||||
*/
|
||||
frequency = (frequency * (iffhead.vhdr.freq * 2) / 3) / 440L;
|
||||
|
||||
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
|
||||
AudioIO->ioa_Request.io_Command = CMD_WRITE;
|
||||
AudioIO->ioa_Request.io_Flags = ADIOF_PERVOL;
|
||||
AudioIO->ioa_Data = (BYTE *) waveptr;
|
||||
AudioIO->ioa_Length = samp;
|
||||
|
||||
/* The clock rate represents the unity rate, so dividing by
|
||||
* the frequency gives us a period ratio...
|
||||
*/
|
||||
/*printf( "clock: %ld, freq: %ld, div: %ld\n", clock, frequency,
|
||||
* clock/frequency );*/
|
||||
AudioIO->ioa_Period = clock / frequency;
|
||||
AudioIO->ioa_Volume = vol;
|
||||
AudioIO->ioa_Cycles = cycles;
|
||||
|
||||
BeginIO((struct IORequest *) AudioIO);
|
||||
WaitPort(AudioMP);
|
||||
AudioMSG = GetMsg(AudioMP);
|
||||
if (dlay)
|
||||
Delay(dlay);
|
||||
}
|
||||
|
||||
killaudio:
|
||||
if (stream)
|
||||
dlb_fclose(stream);
|
||||
if (waveptr)
|
||||
FreeMem(waveptr, samples);
|
||||
if (device == 0)
|
||||
CloseDevice((struct IORequest *) AudioIO);
|
||||
if (AudioMP)
|
||||
DeleteMsgPort(AudioMP);
|
||||
if (AudioIO)
|
||||
FreeMem(AudioIO, sizeof(*AudioIO));
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/* NetHack 3.6 cvtsnd.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* Copyright (c) 1995, Andrew Church, Olney, Maryland */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
short namelen;
|
||||
char name[62];
|
||||
char misc[64]; /* rest of MacBinary header */
|
||||
long FORM;
|
||||
long flen;
|
||||
long AIFF;
|
||||
long SSND;
|
||||
long sndlen;
|
||||
} AIFF;
|
||||
|
||||
typedef struct {
|
||||
char FORM[4];
|
||||
long flen;
|
||||
char _8SVX[4];
|
||||
char VHDR[4];
|
||||
long vhlen;
|
||||
long oneshot, repeat;
|
||||
long samples; /* 'samplesPerHiCycle' in the docs - usually 32, so
|
||||
* we'll use that */
|
||||
short freq;
|
||||
char octaves, compress;
|
||||
long volume;
|
||||
char NAME[4];
|
||||
long nlen; /* should be 64; see name[] comment */
|
||||
char name[64]; /* for simplicity, i.e. just fwrite() entiree header */
|
||||
char BODY[4];
|
||||
long blen;
|
||||
} IFF;
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
FILE *in, *out;
|
||||
AIFF aiff;
|
||||
IFF iff;
|
||||
static char buf[16384];
|
||||
long n, len;
|
||||
|
||||
if (ac != 3) {
|
||||
fprintf(stderr, "Usage: %s input-file output-file\n", av[0]);
|
||||
exit(20);
|
||||
}
|
||||
if (!(in = fopen(av[1], "r"))) {
|
||||
fprintf(stderr, "Can't open input file\n");
|
||||
exit(20);
|
||||
}
|
||||
if (!(out = fopen(av[2], "w"))) {
|
||||
fprintf(stderr, "Can't open output file\n");
|
||||
exit(20);
|
||||
}
|
||||
|
||||
fread(&aiff, sizeof(aiff), 1, in);
|
||||
memcpy(iff.FORM, "FORM", 4);
|
||||
iff.flen = sizeof(iff) + aiff.sndlen - 8;
|
||||
memcpy(iff._8SVX, "8SVX", 4);
|
||||
memcpy(iff.VHDR, "VHDR", 4);
|
||||
iff.vhlen = 20;
|
||||
iff.oneshot = aiff.sndlen;
|
||||
iff.repeat = 0;
|
||||
iff.samples = 32;
|
||||
iff.freq = 22000;
|
||||
iff.octaves = 1;
|
||||
iff.compress = 0;
|
||||
iff.volume = 0x10000;
|
||||
memcpy(iff.NAME, "NAME", 4);
|
||||
iff.nlen = 64;
|
||||
strncpy(iff.name, aiff.name, 62);
|
||||
iff.name[aiff.namelen] = 0;
|
||||
memcpy(iff.BODY, "BODY", 4);
|
||||
iff.blen = aiff.sndlen;
|
||||
fwrite(&iff, sizeof(iff), 1, out);
|
||||
len = aiff.sndlen;
|
||||
do {
|
||||
if (len >= sizeof(buf))
|
||||
n = fread(buf, 1, sizeof(buf), in);
|
||||
else
|
||||
n = fread(buf, 1, len, in);
|
||||
if (n) {
|
||||
fwrite(buf, 1, n, out);
|
||||
len -= n;
|
||||
}
|
||||
} while (len && n);
|
||||
|
||||
if (len)
|
||||
fprintf(stderr, "Warning: %ld bytes of sample missing\n", len);
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user