Skip to content

Commit

Permalink
2007-01-01 Pace Willisson <[email protected]>
Browse files Browse the repository at this point in the history
	* V15

	* add music
  • Loading branch information
pace committed Jan 2, 2007
1 parent bd3a87f commit fb6c92b
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 61 deletions.
1 change: 1 addition & 0 deletions .cvsignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ sdl
mtest
getvab
*.cat
sdltest
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2007-01-01 Pace Willisson <[email protected]>

* V15

* add music

* V14

* add audio to mission playback
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ EXTRA_WARNINGS = -Werror -Wextra -Wno-unused-parameter -Wno-sign-compare \

CFLAGS = -g -Wall -Dfar= -Dpascal= -I. `sdl-config --cflags`

LIBS = `sdl-config --libs` -lvorbisfile -lm

.c.o:
@echo "$(CC) ...flags... -c $*.c"
@$(CC) $(CFLAGS) $(EXTRA_WARNINGS) -O -c -o TMP.o $*.c
@$(CC) $(CFLAGS) $(EXTRA_WARNINGS) -c $*.c

PROGS = baris imgsplit vtest decode getport mkmovie getvab mtest
PROGS = baris imgsplit vtest decode getport mkmovie getvab mtest sdltest
all: $(PROGS)

BARIS_HFILES = Buzz_inc.h cdmaster.h cdrom.h data.h externs.h mis.h mtype.h \
Expand All @@ -23,9 +25,9 @@ BARIS_OBJS = admin.o aimast.o aimis.o aipur.o ast0.o ast1.o \
news_suq.o \
place.o port.o prefs.o prest.o radar.o rdplex.o recods.o \
replay.o review.o rush.o sel.o start.o \
vab.o pace.o gx.o gr.o sdl.o
vab.o pace.o gx.o gr.o sdl.o music.o
baris: $(BARIS_OBJS)
$(CC) $(CFLAGS) -o baris $(BARIS_OBJS) `sdl-config --libs` -lm
$(CC) $(CFLAGS) -o baris $(BARIS_OBJS) $(LIBS)

# $(BARIS_OBJS): $(BARIS_HFILES)

Expand Down Expand Up @@ -54,8 +56,8 @@ mtest: mtest.o
sdl.o: sdl.c
$(CC) $(CFLAGS) `sdl-config --cflags` -c sdl.c

sdl: sdl.o
$(CC) $(CFLAGS) -o sdl sdl.o `sdl-config --libs` -lm
sdltest: sdltest.o
$(CC) $(CFLAGS) -o sdltest sdltest.o `sdl-config --libs` -lvorbisfile -lm

clean:
rm -f *.o *~
Expand Down
1 change: 1 addition & 0 deletions QUESTIONS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
The frame rate in the FRM files seems to be 8, which means 8 frames
per second, right?

RLE bug

1 change: 1 addition & 0 deletions av.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct audio_chunk {
struct audio_chunk *next;
void *data;
int size;
int loop;
};
void play (struct audio_chunk *cp);

Expand Down
8 changes: 1 addition & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,7 @@ void remove_savedat(char *fName)
for (p = fullname; *p; p++)
*p = tolower (*p);

printf ("remove_savedat(\"%s\")...", fullname);

if (remove (fullname) < 0)
printf ("error %s\n", strerror (errno));
else
printf ("ok\n");

remove (fullname);
}

void
Expand Down
15 changes: 15 additions & 0 deletions mkogg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/sh

# note: using timidity++-2.13.2 and GS.ARJ
# makes an ogg file for each midi file


cd /home/pace/ris.music

for mid in *.MID
do
echo $mid

ogg=`basename $mid .MID`.ogg
timidity -Ov --output-mono -s 11025 -o $ogg $mid
done
96 changes: 74 additions & 22 deletions mtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,37 @@
#include <stdlib.h>
#include <string.h>

void
dump (void *buf, int n)
{
int i;
int j;
int c;

for (i = 0; i < n; i += 16) {
printf ("%04x: ", i);
for (j = 0; j < 16; j++) {
if (i+j < n)
printf ("%02x ", ((unsigned char *)buf)[i+j]);
else
printf (" ");
}
printf (" ");
for (j = 0; j < 16; j++) {
c = ((unsigned char *)buf)[i+j] & 0x7f;
if (i+j >= n)
putchar (' ');
else if (c < ' ' || c == 0x7f)
putchar ('.');
else
putchar (c);
}
printf ("\n");

}
}


#pragma pack(1)
struct TM {
char ID[6];
Expand Down Expand Up @@ -34,7 +65,10 @@ open_music_cat (char *filename)
fread (&dp->dir, 1, sizeof dp->dir, musicf);

for (i = 0, dp = dirs; i < MDIRS; i++, dp++) {
dp->nfiles = dp->dir.size / sizeof (struct TM);
printf ("%6.6s 0x%08lx %8ld\n", dp->dir.ID,
dp->dir.offset, dp->dir.size);

dp->nfiles = 32;
dp->files = calloc (dp->nfiles, sizeof *dp->files);
fseek (musicf, dp->dir.offset, SEEK_SET);
fread (dp->files, dp->nfiles, sizeof *dp->files, musicf);
Expand All @@ -49,6 +83,7 @@ get_music (char *filetype, int idx, void *buf, int bufsize)
int len;
int i;
struct music_dir *dp;
int n;

len = strlen (filetype);

Expand All @@ -60,36 +95,36 @@ get_music (char *filetype, int idx, void *buf, int bufsize)
if (i == MDIRS)
return (-1);

return (-1);
}
if (idx < 0 || idx >= dp->nfiles)
return (-1);



n = dp->files[idx].size;
if (n > bufsize)
n = bufsize;

fseek (musicf, dp->dir.offset + dp->files[idx].offset, SEEK_SET);
n = fread (buf, 1, n, musicf);
return (n);
}

void
do_display_cat (void)
{
FILE *f;
struct TM MusicIndex;
int i;
int i, j;
struct music_dir *dp;
struct TM *fp;
long base, offset;

if ((f = fopen ("/l/baris/gamedat/music.cat", "r")) == NULL) {
fprintf (stderr, "can't open music.cat\n");
exit (1);
}
base = 0;
for (i = 0, dp = dirs; i < MDIRS; i++, dp++) {
for (j = 0, fp = dp->files; j < dp->nfiles; j++, fp++) {
offset = dp->dir.offset + fp->offset;

for (i = 0; i < 36; i++) {
if (fread (&MusicIndex, 1, sizeof MusicIndex, f) == 0) {
printf ("unexpected EOF\n");
exit (1);
printf ("0x%08lx %8ld %.6s/%.6s\n",
offset, fp->size,
dp->dir.ID, fp->ID);
}
printf ("%6.6s 0x%08lx %8ld\n",
MusicIndex.ID,
MusicIndex.offset,
MusicIndex.size);
}

fclose (f);
}

int display_cat;
Expand All @@ -105,6 +140,10 @@ int
main (int argc, char **argv)
{
int c;
char *type = NULL;
int idx = 0;
int n;
char buf[1000 * 1000];

while ((c = getopt (argc, argv, "c")) != EOF) {
switch (c) {
Expand All @@ -116,14 +155,27 @@ main (int argc, char **argv)
}
}

if (optind < argc)
type = argv[optind++];

if (optind < argc)
idx = atoi (argv[optind++]);

if (optind != argc)
usage ();

open_music_cat ("/l/baris/gamedat/music.cat");

if (display_cat) {
do_display_cat ();
exit (0);
}

if (type) {
n = get_music (type, idx, buf, sizeof buf);
dump (buf, n);
}

return (0);
}

Expand Down
Loading

0 comments on commit fb6c92b

Please sign in to comment.