<i>
</i>typedef struct
{
MREADER mr;
int offset;
int eof;
SDL_RWops *rw;
} LMM_MREADER;
BOOL LMM_Seek(struct MREADER *mr,long to,int dir)
{
int at;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
if(dir==SEEK_SET)
to+=lmmmr->offset;
at=SDL_RWseek(lmmmr->rw, to, dir);
return at<lmmmr>offset;
}
long LMM_Tell(struct MREADER *mr)
{
int at;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
at=SDL_RWtell(lmmmr->rw)-lmmmr->offset;
return at;
}
BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz)
{
int got;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
got=SDL_RWread(lmmmr->rw, buf, sz, 1);
return got;
}
int LMM_Get(struct MREADER *mr)
{
unsigned char c;
int i=EOF;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
if(SDL_RWread(lmmmr->rw,&c,1,1))
i=c;
return i;
}
BOOL LMM_Eof(struct MREADER *mr)
{
int offset;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
offset=LMM_Tell(mr);
return offset>=lmmmr->eof;
}
MODULE *MikMod_LoadSongRW(SDL_RWops *rw, int maxchan)
{
LMM_MREADER lmmmr={{
LMM_Seek,
LMM_Tell,
LMM_Read,
LMM_Get,
LMM_Eof},
0,
0,
rw
};
MODULE *m;
lmmmr.offset=SDL_RWtell(rw);
SDL_RWseek(rw,0,SEEK_END);
lmmmr.eof=SDL_RWtell(rw);
SDL_RWseek(rw,lmmmr.offset,SEEK_SET);
m=Player_LoadGeneric((MREADER*)&lmmmr,maxchan,0);
return m;
}