3 * Adlib OPL2/OPL3 FM synthesizer chipset test program.
\r
4 * Play MIDI file using the OPLx synthesizer (well, poorly anyway)
\r
5 * (C) 2010-2012 Jonathan Campbell.
\r
6 * Hackipedia DOS library.
\r
8 * This code is licensed under the LGPL.
\r
9 * <insert LGPL legal text here>
\r
11 * Compiles for intended target environments:
\r
12 * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box]
\r
19 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
\r
29 //#include "src/lib/doslib/vga.h"
\r
30 #include "src/lib/doslib/dos.h"
\r
31 #include "src/lib/16_head.h"
\r
32 #include "src/lib/doslib/8254.h" /* 8254 timer */
\r
33 #include "src/lib/doslib/8259.h"
\r
34 //#include "src/lib/doslib/vgagui.h"
\r
35 //#include "src/lib/doslib/vgatty.h"
\r
36 #include "src/lib/doslib/adlib.h"
\r
38 /* one per OPL channel */
\r
40 unsigned char note_number;
\r
41 unsigned char note_velocity;
\r
42 unsigned char note_track; /* from what MIDI track */
\r
43 unsigned char note_channel; /* from what MIDI channel */
\r
44 unsigned int busy:1; /* if occupied */
\r
47 struct midi_channel {
\r
48 unsigned char program;
\r
52 /* track data, raw */
\r
53 unsigned char* raw; /* raw data base */
\r
54 unsigned char* fence; /* raw data end (last byte + 1) */
\r
55 unsigned char* read; /* raw data read ptr */
\r
57 unsigned long us_per_quarter_note; /* Microseconds per quarter note (def 120 BPM) */
\r
58 unsigned long us_tick_cnt_mtpq; /* Microseconds advanced (up to 10000 us or one unit at 100Hz) x ticks per quarter note */
\r
60 unsigned char last_status; /* MIDI last status byte */
\r
61 unsigned int eof:1; /* we hit the end of the track */
\r
64 #define MIDI_MAX_CHANNELS 16
\r
65 #define MIDI_MAX_TRACKS 64
\r
67 extern struct midi_note midi_notes[ADLIB_FM_VOICES];
\r
68 extern struct midi_channel midi_ch[MIDI_MAX_CHANNELS];
\r
69 extern struct midi_track midi_trk[MIDI_MAX_TRACKS];
\r
71 static void (interrupt *old_irq0)();
\r
72 static volatile unsigned long irq0_ticks=0;
\r
73 static volatile unsigned int irq0_cnt=0,irq0_add=0,irq0_max=0;
\r
74 static volatile unsigned char midi_playing=0;
\r
76 int load_midi_file(const char *path);
\r
77 void interrupt irq0();
\r
78 void adlib_shut_up();
\r
79 void midi_reset_tracks();
\r
80 void midi_reset_channels();
\r
83 #endif /* __MIDI__ */
\r