diff options
author | Eugene Sandulenko | 2004-04-12 21:40:49 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-04-12 21:40:49 +0000 |
commit | f3d340fb0ce72b9db59b8c701153bc82b595f75e (patch) | |
tree | bf250cf3a1e6aee35c7f40d766994b0c2c188e5c /saga/xmidi.h | |
parent | 0a0a0c7b0609d8774cef849e7511e7b21d12c5db (diff) | |
download | scummvm-rg350-f3d340fb0ce72b9db59b8c701153bc82b595f75e.tar.gz scummvm-rg350-f3d340fb0ce72b9db59b8c701153bc82b595f75e.tar.bz2 scummvm-rg350-f3d340fb0ce72b9db59b8c701153bc82b595f75e.zip |
WIP for SAGA engine.
o text formatting is not consistent with rules, just indent utility is too
dumb for that
o it does not use OSystem, i.e. it runs on direct SDL calls
o it may not even compile on your box
o if you enable it, expect zillions of warnings
o no sound
Now it runs ITE intro as reinherit did
svn-id: r13564
Diffstat (limited to 'saga/xmidi.h')
-rw-r--r-- | saga/xmidi.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/saga/xmidi.h b/saga/xmidi.h new file mode 100644 index 0000000000..a408cfc74e --- /dev/null +++ b/saga/xmidi.h @@ -0,0 +1,117 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004 The ScummVM project + * + * The ReInherit Engine is (C)2000-2003 by Daniel Balsom. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ +/* + Description: + + XMIDI conversion routines + + Notes: + + Code adapted from XMILoader by Keet ( fox@foxpaws.net ), (C)2000 +*/ + +#ifndef SAGA_XMIDI_H_ +#define SAGA_XMIDI_H_ + +namespace Saga { + +#define XMIDI_TIMEDIV 0x3C + +/* XMIDI/IFF 4CC codes +\*--------------------------------------------------------------------------*/ +#define IFF_FORMAT_4CC "FORM" +#define IFF_CATEGORY_4CC "CAT " + +#define XMI_DESC_4CC "XDIR" +#define XMI_INFO_4CC "INFO" + +#define XMIDI_DESC_4CC "XMID" +#define XMIDI_TIMBRE_4CC "TIMB" +#define XMIDI_EVENT_4CC "EVNT" + +/* IFF/XMI Data structures +\*--------------------------------------------------------------------------*/ + +typedef struct IFF_ID_CHUNK_tag { + char id_4cc[4]; /* 4cc */ + ulong chunk_len; /* u32_be */ + char desc_4cc[4]; /* 4cc */ +} IFF_ID_CHUNK; + +#define IFF_ID_CHUNK_HEADERLEN 12 + +typedef struct XMI_INFO_CHUNK_tag { + char id_4cc[4]; /* 4cc */ + ulong chunk_len; /* u32_be */ + uint n_tracks; /* u16_le */ +} XMI_INFO_CHUNK; + +typedef struct XMI_TIMB_CHUNK_tag { + char id_4cc[4]; /* 4cc */ + ulong chunk_len; /* u32_be */ +} XMI_TIMB_CHUNK; + +typedef struct XMI_EVENT_CHUNK_tag { + char id_4cc[4]; /* 4cc */ + ulong chunk_len; /* u32_be */ +} XMI_EVENT_CHUNK; + +typedef struct SMF_HEADER_CHUNK_tag { + char smf_id[4]; /* u8 */ + unsigned int smf_header_len; /* u32_be */ + unsigned short smf_format; /* u16_be */ + unsigned short smf_ntracks; /* u16_be */ + union { + unsigned short ppqn; /* u16_be */ + signed char smpte[2]; + } time_division; +} SMF_HEADER_CHUNK; + +typedef struct SMF_TRACK_CHUNK_tag { + char smf_track_id[4]; + unsigned int smf_track_len; +} SMF_TRACK_CHUNK; + +#define MIDI_HEADER_LEN 14 +#define MIDI_HEADER_CHUNK_LEN 6 +#define MIDI_TRACK_CHUNK_LEN 8 + +#define MIDI_HEADER_TAG "MThd" +#define MIDI_TRACK_TAG "MTrk" + +int XMIDI_ReadXMIHeader(const uchar *XMI_img, const uchar **XMIDI_data, uint *n_tracks); +int ReadIFF_IDChunk(IFF_ID_CHUNK *chunk, const uchar *read_p, const uchar **read_pp); +int Print4CC(char *fourcc); +int XMIDI_ReadEvents(XMIDIEVENT_LIST *event_list, const uchar *event_data, + size_t event_data_len, uint n_tracks); +int WriteVLQ_DW(char *write_ptr, DWORD value); +DWORD ReadVLQ_DW(char *data, DWORD bytes_left, DWORD *value); +DWORD ReadVLQ2_DW(char *data, DWORD bytes_left, DWORD *value); +int GetLengthAsVLQ(DWORD data); +int AddEventToList(XMIDIEVENT_LIST *event_list, int smf_size, int time, + int event, int channel, int sysex_op, int op1, int op2, int op3, int op4); +int ProcessEventList(XMIDIEVENT_LIST *event_list); +void PrintMidiOutError(unsigned long err); +} // End of namespace Saga + +#endif /* SAGA_XMIDI_H_ */ |