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