X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmidi.h;h=356255d24c992ab1001af18c86458e21dda9cd41;hb=bd35bd7d97646cc726bd40cc54c9a158af008b4d;hp=b98f0590ac7de0d1365f1a3a13e1026e41bb5f89;hpb=1ce4037e53ce951438ba7e35597b08248dd1257a;p=16.git diff --git a/src/lib/midi.h b/src/lib/midi.h old mode 100644 new mode 100755 index b98f0590..356255d2 --- a/src/lib/midi.h +++ b/src/lib/midi.h @@ -1,83 +1,83 @@ -/* midi.h - * - * Adlib OPL2/OPL3 FM synthesizer chipset test program. - * Play MIDI file using the OPLx synthesizer (well, poorly anyway) - * (C) 2010-2012 Jonathan Campbell. - * Hackipedia DOS library. - * - * This code is licensed under the LGPL. - * - * - * Compiles for intended target environments: - * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box] - */ - +/* midi.h + * + * Adlib OPL2/OPL3 FM synthesizer chipset test program. + * Play MIDI file using the OPLx synthesizer (well, poorly anyway) + * (C) 2010-2012 Jonathan Campbell. + * Hackipedia DOS library. + * + * This code is licensed under the LGPL. + * + * + * Compiles for intended target environments: + * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box] + */ + #ifndef __MIDI__ -#define __MIDI__ - -#include -#include /* this is where Open Watcom hides the outp() etc. functions */ -#include -#include -#include -#include -#include -#include -#include -#include - -//#include "src/lib/doslib/vga.h" -//#include "src/lib/doslib/dos.h" -#include "src/lib/16_head.h" -#include "src/lib/doslib/8254.h" /* 8254 timer */ -#include "src/lib/doslib/8259.h" -//#include "src/lib/doslib/vgagui.h" -//#include "src/lib/doslib/vgatty.h" -#include "src/lib/doslib/adlib.h" - -/* one per OPL channel */ -struct midi_note { - unsigned char note_number; - unsigned char note_velocity; - unsigned char note_track; /* from what MIDI track */ - unsigned char note_channel; /* from what MIDI channel */ - unsigned int busy:1; /* if occupied */ -}; - -struct midi_channel { - unsigned char program; -}; - -struct midi_track { - /* track data, raw */ - unsigned char* raw; /* raw data base */ - unsigned char* fence; /* raw data end (last byte + 1) */ - unsigned char* read; /* raw data read ptr */ - /* state */ - unsigned long us_per_quarter_note; /* Microseconds per quarter note (def 120 BPM) */ - unsigned long us_tick_cnt_mtpq; /* Microseconds advanced (up to 10000 us or one unit at 100Hz) x ticks per quarter note */ - unsigned long wait; - unsigned char last_status; /* MIDI last status byte */ - unsigned int eof:1; /* we hit the end of the track */ -}; - -#define MIDI_MAX_CHANNELS 16 -#define MIDI_MAX_TRACKS 64 - -extern struct midi_note midi_notes[ADLIB_FM_VOICES]; -extern struct midi_channel midi_ch[MIDI_MAX_CHANNELS]; -extern struct midi_track midi_trk[MIDI_MAX_TRACKS]; - -static void (interrupt *old_irq0)(); -static volatile unsigned long irq0_ticks=0; -static volatile unsigned int irq0_cnt=0,irq0_add=0,irq0_max=0; -static volatile unsigned char midi_playing=0; - -int load_midi_file(const char *path); -void interrupt irq0(); -void adlib_shut_up(); -void midi_reset_tracks(); -void midi_reset_channels(); -void midi_tick(); - -#endif /* __MIDI__ */ +#define __MIDI__ + +#include +#include /* this is where Open Watcom hides the outp() etc. functions */ +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "src/lib/doslib/vga.h" +#include "src/lib/doslib/dos.h" +#include "src/lib/16_head.h" +#include "src/lib/doslib/8254.h" /* 8254 timer */ +#include "src/lib/doslib/8259.h" +//#include "src/lib/doslib/vgagui.h" +//#include "src/lib/doslib/vgatty.h" +#include "src/lib/doslib/adlib.h" + +/* one per OPL channel */ +struct midi_note { + unsigned char note_number; + unsigned char note_velocity; + unsigned char note_track; /* from what MIDI track */ + unsigned char note_channel; /* from what MIDI channel */ + unsigned int busy:1; /* if occupied */ +}; + +struct midi_channel { + unsigned char program; +}; + +struct midi_track { + /* track data, raw */ + unsigned char* raw; /* raw data base */ + unsigned char* fence; /* raw data end (last byte + 1) */ + unsigned char* read; /* raw data read ptr */ + /* state */ + unsigned long us_per_quarter_note; /* Microseconds per quarter note (def 120 BPM) */ + unsigned long us_tick_cnt_mtpq; /* Microseconds advanced (up to 10000 us or one unit at 100Hz) x ticks per quarter note */ + unsigned long wait; + unsigned char last_status; /* MIDI last status byte */ + unsigned int eof:1; /* we hit the end of the track */ +}; + +#define MIDI_MAX_CHANNELS 16 +#define MIDI_MAX_TRACKS 64 + +extern struct midi_note midi_notes[ADLIB_FM_VOICES]; +extern struct midi_channel midi_ch[MIDI_MAX_CHANNELS]; +extern struct midi_track midi_trk[MIDI_MAX_TRACKS]; + +static void (interrupt *old_irq0)(); +static volatile unsigned long irq0_ticks=0; +static volatile unsigned int irq0_cnt=0,irq0_add=0,irq0_max=0; +static volatile unsigned char midi_playing=0; + +int load_midi_file(const char *path); +void interrupt irq0(); +void adlib_shut_up(); +void midi_reset_tracks(); +void midi_reset_channels(); +void midi_tick(); + +#endif /* __MIDI__ */