annotate frontend/mikmodux.c @ 20:0e9afd6bdaf0

Don't know why this file was here :)
author darius
date Fri, 24 Apr 1998 01:24:55 +0000
parents e5529b6e3b1c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
1 /*
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
2 * Basic mod player. Just takes the name of the mod to play
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
3 */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
4
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
5 #include <stdio.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
6 #include <stdlib.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
7 #include <unistd.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
8 #include <string.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
9 #include <fnmatch.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
10 #include <signal.h>
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
11 #include "mikmod.h"
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
12 #include "mikmodux.h"
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
13 #include "mmio.h"
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
14
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
15
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
16 int
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
17 main(int argc, char *argv[])
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
18 {
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
19 static BOOL
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
20 cfg_extspd = 1, /* Extended Speed enable */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
21 cfg_panning = 1, /* DMP panning enable (8xx effects) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
22 cfg_loop = 0; /* auto song-looping disable */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
23 int
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
24 cfg_maxchn = 64, c;
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
25
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
26 UNIMOD *mf = NULL;
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
27
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
28 if (argc != 2) {
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
29 printf("Usage is mikmod <mod name>\n");
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
30 exit(1);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
31 }
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
32
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
33 init_mikmod();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
34
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
35 if ((mf = MikMod_LoadSong(argv[1], cfg_maxchn)) != NULL) {
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
36 mf->extspd = cfg_extspd;
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
37 mf->panflag = cfg_panning;
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
38 mf->loop = cfg_loop;
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
39
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
40 Player_Start(mf);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
41
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
42 /*
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
43 * set the number of voices to use.. you could add extra channels
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
44 * here (e.g. md_numchn=mf->numchn+4; ) to use for your own
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
45 * soundeffects:
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
46 */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
47
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
48 while (Player_Active()) { /* if we have a quit signal, exit
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
49 * loop */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
50 MikMod_Update();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
51
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
52 usleep(500);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
53 }
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
54
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
55 Player_Stop(); /* stop playing */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
56 MikMod_FreeSong(mf); /* and free the module */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
57 } else {
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
58 /* didn't work -> exit with errormsg. */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
59 printf("MikMod Error\n");
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
60 }
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
61
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
62 MikMod_Exit();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
63 }
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
64
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
65 void
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
66 init_mikmod(void)
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
67 {
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
68 /*
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
69 * Initialize soundcard parameters.. you _have_ to do this before calling
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
70 * MD_Init(), and it's illegal to change them after you've called
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
71 * MD_Init()
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
72 */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
73
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
74 md_mixfreq = 44100; /* standard mixing freq */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
75 md_dmabufsize = 32768; /* standard dma buf size (max 32000) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
76 md_device = 0; /* standard device: autodetect */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
77 md_volume = 96; /* driver volume (max 128) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
78 md_musicvolume = 128; /* music volume (max 128) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
79 md_sndfxvolume = 128; /* sound effects volume (max 128) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
80 md_pansep = 128; /* panning separation (0 = mono, 128 = full
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
81 * stereo) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
82 /* md_stereodelay = 10; /* Stereo Delay (max 15) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
83 md_reverb = 0; /* Reverb (max 15) */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
84 md_mode =
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
85 DMODE_16BITS |
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
86 DMODE_STEREO |
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
87 DMODE_SOFT_MUSIC; /* default mixing mode */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
88
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
89 /* Register the loaders we want to use.. */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
90 MikMod_RegisterAllLoaders();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
91
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
92 /* Register the drivers we want to use: */
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
93 MikMod_RegisterAllDrivers();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
94
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
95 MikMod_RegisterDriver(drv_wav);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
96 MikMod_RegisterDriver(drv_raw);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
97 MikMod_RegisterDriver(drv_nos);
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
98
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
99 MikMod_Init();
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
100
e5529b6e3b1c Inistal commit of the Cheesy Mod Player (tm)
darius
parents:
diff changeset
101 }