Initial community commit

This commit is contained in:
Jef 2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit fc06254474
16440 changed files with 4239995 additions and 2 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,123 @@
extern "C"
{
#include "main.h"
}
#include "drv_buffer.h"
#include <bfc/platform/types.h>
typedef struct
{
const char *cmd;
const char *file;
const char *title;
int titleLength;
int start;
int startUnit;
int loops;
int flags;
} PlayParams;
extern "C" int GetSampleSizeFlag();
extern "C" MMSTREAM *_mm_fopen_rf(const CHAR *fname); //rf_wrapper.c
BOOL GetPlayParams(const char *fileName, BOOL open, PlayParams *params);
BOOL InitPlayer(UNIMOD *mf, MPLAYER **ps, const PlayParams *params, BOOL quick);
// TODO; is there a way to get floating point out of this stuff?
extern "C"
{
__declspec(dllexport) intptr_t winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate)
{
PlayParams params;
if (!GetPlayParams(fn, FALSE, &params))
return 0;
int requested_channels = *nch;
int requested_bits = *bps;
int requested_srate = *srate;
uint md_mode = 0;
if (config_interp & 1) md_mode |= DMODE_INTERP;
if (config_interp & 2) md_mode |= DMODE_NOCLICK;
if (config_interp & 4) md_mode |= DMODE_FIR;
switch(requested_bits)
{
case 0:
md_mode |= GetSampleSizeFlag();
break;
case 16:
md_mode |= DMODE_16BITS;
break;
case 24:
md_mode |= DMODE_24BITS;
break;
}
if (requested_channels != 1 && requested_channels != 2) md_mode |= DMODE_SURROUND;
if (config_panrev) md_mode |= DMODE_REVERSE;
if (config_resonance) md_mode |= DMODE_RESONANCE;
MDRIVER *md = Mikmod_Init(requested_srate?requested_srate:config_srate, 0, 0, MD_STEREO, config_cpu, md_mode, &drv_buffer);
MPLAYER *mp;
MMSTREAM *fp;
fp = _mm_fopen_rf(params.file);
if (!fp)
{
Mikmod_Exit(md);
//CleanupTemp();
return 0;
}
UNIMOD *mf=Unimod_Load_FP(md, params.file,fp);
_mm_fclose(fp);
if (mf==NULL)
{
Mikmod_Exit(md);
// CleanupTemp();
return 0;
}
if (!InitPlayer(mf, &mp, &params, FALSE))
{
//CleanupTemp();
Unimod_Free(mf);
Mikmod_Exit(md);
return 0;
}
Player_Start(mp);
DecodeInfo *hwdata = (DecodeInfo *)md->device.local;
*bps = hwdata->bits;
*srate = hwdata->mixspeed;
*nch = hwdata->channels;
if (mf->songlen)
*size = MulDiv(mf->songlen, hwdata->mixspeed * hwdata->channels *hwdata->bits, 8*1000);
else
*size = -1;
return (intptr_t)mp;
}
__declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t handle, char *dest, size_t len, int *killswitch)
{
MPLAYER *mp = (MPLAYER *)handle;
DecodeInfo *hwdata = (DecodeInfo *)mp->mf->md->device.local;
if (!Player_Active(mp)) // check if we're done
return 0;
hwdata->buffer = dest;
hwdata->buffersize = len;
hwdata->bytesWritten = 0;
Mikmod_Update(mp->mf->md);
return hwdata->bytesWritten;
}
__declspec(dllexport) void winampGetExtendedRead_close(intptr_t handle)
{
MPLAYER *mp = (MPLAYER *)handle;
MDRIVER *md = mp->mf->md;
UNIMOD *mf = (UNIMOD *)mp->mf;
Player_Free(mp);
Unimod_Free(mf);
Mikmod_Exit(md);
}
}

View file

@ -0,0 +1,602 @@
#include "api.h"
#include "main.h"
#include "resource.h"
#include <commctrl.h>
#include "../../winamp/wa_ipc.h"
#include <strsafe.h>
static BOOL CALLBACK infoProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
static BOOL CALLBACK tabProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
static void OnSelChanged(HWND hwndDlg);
INFOBOX *infobox_list = NULL;
int config_info_x = 0, config_info_y = 0;
BOOL config_track = FALSE;
// =====================================================================================
void infobox_delete(HWND hwnd)
// =====================================================================================
// This function is called with the handle of the infobox to destroy. It unloads the
// module if appropriate (care must be take not to unload a module which is in use!).
{
INFOBOX *cruise, *old;
old = cruise = infobox_list;
while(cruise)
{
if(cruise->hwnd == hwnd)
{
if(cruise == infobox_list)
infobox_list = cruise->next;
else old->next = cruise->next;
// Destroy the info box window, then unload the module, *if*
// the module is not actively playing!
info_killseeker(hwnd);
DestroyWindow(hwnd);
if (cruise->dlg.module!=mf && cruise->dlg.ownModule)
Unimod_Free(cruise->dlg.module);
free(cruise->dlg.suse);
free(cruise);
return;
}
old = cruise;
cruise = cruise->next;
}
}
// =====================================================================================
MPLAYER *get_player(UNIMOD *othermf)
// =====================================================================================
// Checks the current module against the one given. if they match the MP is returned,
// else it returns NULL.
{
if (mf == othermf)
return mp;
return NULL;
}
// =====================================================================================
static void infoTabInit(HWND hwndDlg, UNIMOD *m, DLGHDR *pHdr)
// =====================================================================================
{
DWORD dwDlgBase = GetDialogBaseUnits();
int cxMargin = LOWORD(dwDlgBase) / 4,
cyMargin = HIWORD(dwDlgBase) / 8;
TC_ITEM tie;
int tabCounter;
// Add a tab for each of the three child dialog boxes.
// and lock the resources for the child frames that appear within.
tie.mask = TCIF_TEXT | TCIF_IMAGE;
tie.iImage = -1;
tabCounter = 0;
if(m->numsmp)
{
tie.pszText = WASABI_API_LNGSTRING(IDS_SAMPLES);
TabCtrl_InsertItem(pHdr->hwndTab, tabCounter, &tie);
pHdr->apRes[tabCounter] = WASABI_API_CREATEDIALOGPARAM(IDD_SAMPLES, hwndDlg, tabProc, IDD_SAMPLES);
SendMessage(mikmod.hMainWindow,WM_WA_IPC,(WPARAM)pHdr->apRes[tabCounter],IPC_USE_UXTHEME_FUNC);
SetWindowPos(pHdr->apRes[tabCounter], HWND_TOP, pHdr->left+1, pHdr->top+15, 0, 0, SWP_NOSIZE);
ShowWindow(pHdr->apRes[tabCounter++], SW_HIDE);
}
if(m->numins)
{
tie.pszText = WASABI_API_LNGSTRING(IDS_INSTRUMENTS);
TabCtrl_InsertItem(pHdr->hwndTab, tabCounter, &tie);
pHdr->apRes[tabCounter] = WASABI_API_CREATEDIALOGPARAM(IDD_INSTRUMENTS, hwndDlg, tabProc, IDD_INSTRUMENTS);
SendMessage(mikmod.hMainWindow,WM_WA_IPC,(WPARAM)pHdr->apRes[tabCounter],IPC_USE_UXTHEME_FUNC);
SetWindowPos(pHdr->apRes[tabCounter], HWND_TOP, pHdr->left+1, pHdr->top+15, 0, 0, SWP_NOSIZE);
ShowWindow(pHdr->apRes[tabCounter++], SW_HIDE);
}
if(m->comment && m->comment[0])
{
tie.pszText = WASABI_API_LNGSTRING(IDS_COMMENT);
TabCtrl_InsertItem(pHdr->hwndTab, tabCounter, &tie);
pHdr->apRes[tabCounter] = WASABI_API_CREATEDIALOGPARAM(IDD_COMMENT, hwndDlg, tabProc, CEMENT_BOX);
SendMessage(mikmod.hMainWindow,WM_WA_IPC,(WPARAM)pHdr->apRes[tabCounter],IPC_USE_UXTHEME_FUNC);
SetWindowPos(pHdr->apRes[tabCounter], HWND_TOP, pHdr->left+1, pHdr->top+15, 0, 0, SWP_NOSIZE);
ShowWindow(pHdr->apRes[tabCounter++], SW_HIDE);
}
// Simulate selection of the LAST item
TabCtrl_SetCurSel(pHdr->hwndTab, tabCounter-1);
OnSelChanged(hwndDlg);
}
// =====================================================================================
static BOOL CALLBACK tabProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
// =====================================================================================
// This is the callback procedure used by each of the three forms under the
// tab control on the Module info dialog box (sample, instrument, comment
// info forms).
{
switch (uMsg)
{ case WM_INITDIALOG:
{
HWND hwndLB;
DLGHDR *pHdr = (DLGHDR *)GetWindowLong(GetParent(hwndDlg), GWL_USERDATA);
UNIMOD *m = pHdr->module;
char sbuf[10280] = {0};
switch(lParam)
{ case IDD_SAMPLES:
{
uint x;
hwndLB = GetDlgItem(hwndDlg, IDC_SAMPLIST);
for (x=0; x<m->numsmp; x++)
{
StringCbPrintfA(sbuf, sizeof(sbuf), "%02d: %s",x+1, m->samples[x].samplename ? m->samples[x].samplename : "");
SendMessage(hwndLB, LB_ADDSTRING, 0, (LPARAM) sbuf);
}
SendMessage(hwndLB, LB_SETCURSEL, 0, 0);
tabProc(hwndDlg, WM_COMMAND, (WPARAM)((LBN_SELCHANGE << 16) + IDC_SAMPLIST), (LPARAM)hwndLB);
}
return TRUE;
case IDD_INSTRUMENTS:
{
uint x;
hwndLB = GetDlgItem(hwndDlg, IDC_INSTLIST);
for (x=0; x<m->numins; x++)
{
StringCbPrintfA(sbuf, sizeof(sbuf), "%02d: %s",x+1, m->instruments[x].insname ? m->instruments[x].insname : "");
SendMessage(hwndLB, LB_ADDSTRING, 0, (LPARAM) sbuf);
}
SendMessage(hwndLB, LB_SETCURSEL, 0, 0);
tabProc(hwndDlg, WM_COMMAND, (WPARAM)((LBN_SELCHANGE << 16) + IDC_INSTLIST), (LPARAM)hwndLB);
}
return TRUE;
case CEMENT_BOX:
if(m->comment && m->comment[0])
{
uint x,i;
hwndLB = GetDlgItem(hwndDlg, CEMENT_BOX);
// convert all CRs to CR/LF pairs. That's the way the edit box likes them!
for(x=0, i=0; x<strlen(m->comment) && i < sizeof(sbuf)-1; x++)
{
sbuf[i++] = m->comment[x];
if(m->comment[x]==0x0d && m->comment[x+1]!=0x0a)
sbuf[i++] = 0x0a;
}
sbuf[i] = 0;
SetWindowText(hwndLB, sbuf);
}
return TRUE;
}
}
break;
case WM_COMMAND:
if(HIWORD(wParam) == LBN_SELCHANGE)
{ // Processes the events for the sample and instrument list boxes, namely updating
// the samp/inst info upon a WM_COMMAND issuing a listbox selection change.
int moo = SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0);
char sbuf[1024] = {0}, st1[128] = {0}, st2[64] = {0}, st3[64] = {0};
char tmp1[32] = {0}, tmp2[32] = {0}, tmp3[32] = {0};
DLGHDR *pHdr = (DLGHDR *)GetWindowLong(GetParent(hwndDlg), GWL_USERDATA);
UNIMOD *m = pHdr->module;
switch (LOWORD(wParam))
{ case IDC_INSTLIST:
{ INSTRUMENT *inst = &m->instruments[moo];
uint x;
size_t cnt;
char *sbuf_p;
// --------------------
// Part 1: General instrument header info
// default volume, auto-vibrato, fadeout (in that order).
{
StringCbPrintfA(sbuf, sizeof(sbuf), "%d%%\n%s\n%s", (inst->globvol * 400) / 256,
WASABI_API_LNGSTRING_BUF((inst->vibdepth ? IDS_YES : IDS_NO),tmp1,sizeof(tmp1)/sizeof(*tmp1)),
WASABI_API_LNGSTRING_BUF((inst->volfade ? IDS_YES : IDS_NO),tmp2,sizeof(tmp2)/sizeof(*tmp2)));
SetWindowText(GetDlgItem(hwndDlg, IDC_INSTHEAD), sbuf);
}
//(inst->nnatype == NNA_CONTINUE) ? "Continue" : (inst->nnatype == NNA_OFF) ? "Off" : (inst->nnatype == NNA_FADE) ? "Fade" : "Cut");
// --------------------
// Part 2: The instrument envelope info (vol/pan/pitch)
// Wow this is ugly, but it works: Make a set of strings that have the
// '(loop / sustain)' string. Tricky, cuz the '/' is only added if it
// is needed of course.
if(inst->volflg & (EF_LOOP | EF_SUSTAIN))
{
StringCbPrintfA(st1, sizeof(st1), "(%s%s%s)",
(inst->volflg & EF_LOOP) ? WASABI_API_LNGSTRING(IDS_LOOP) : "",
((inst->volflg & EF_LOOP) && (inst->volflg & EF_SUSTAIN)) ? " / " : "",
(inst->volflg & EF_SUSTAIN) ? WASABI_API_LNGSTRING_BUF(IDS_SUSTAIN,tmp1,sizeof(tmp1)/sizeof(*tmp1)) : "");
} else st1[0] = 0;
if(inst->panflg & (EF_LOOP | EF_SUSTAIN))
{
StringCbPrintfA(st2, sizeof(st2), "(%s%s%s)",
(inst->panflg & EF_LOOP) ? WASABI_API_LNGSTRING(IDS_LOOP) : "",
((inst->panflg & EF_LOOP) && (inst->panflg & EF_SUSTAIN)) ? " / " : "",
(inst->panflg & EF_SUSTAIN) ? WASABI_API_LNGSTRING_BUF(IDS_SUSTAIN,tmp1,sizeof(tmp1)/sizeof(*tmp1)) : "");
} else st2[0] = 0;
if(inst->pitflg & (EF_LOOP | EF_SUSTAIN))
{
StringCchPrintfA(st3,sizeof(st3), "(%s%s%s)",
(inst->pitflg & EF_LOOP) ? WASABI_API_LNGSTRING(IDS_LOOP) : "",
((inst->pitflg & EF_LOOP) && (inst->pitflg & EF_SUSTAIN)) ? " / " : "",
(inst->pitflg & EF_SUSTAIN) ? WASABI_API_LNGSTRING_BUF(IDS_SUSTAIN,tmp1,sizeof(tmp1)/sizeof(*tmp1)) : "");
} else st3[0] = 0;
{
StringCbPrintfA(sbuf, sizeof(sbuf), "%s %s\n%s %s\n%s %s",
WASABI_API_LNGSTRING_BUF(((inst->volflg & EF_ON) ? IDS_ON : IDS_OFF),tmp1,sizeof(tmp1)/sizeof(*tmp1)),
st1[0] ? st1 : "",
WASABI_API_LNGSTRING_BUF(((inst->panflg & EF_ON) ? IDS_ON : IDS_OFF),tmp2,sizeof(tmp2)/sizeof(*tmp2)),
st2[0] ? st2 : "",
WASABI_API_LNGSTRING_BUF(((inst->pitflg & EF_ON) ? IDS_ON : IDS_OFF),tmp3,sizeof(tmp3)/sizeof(*tmp3)),
st3[0] ? st3 : "");
}
SetWindowText(GetDlgItem(hwndDlg, IDC_INSTENV), sbuf);
// --------------------
// Part 3: List of samples used by this instrument!
// the trick here is that that we have to figure out what samples are used from the
// sample index table in inst->samplenumber.
memset(pHdr->suse,0,m->numsmp*sizeof(BOOL));
for(x=0; x<120; x++)
if(inst->samplenumber[x] != 65535)
pHdr->suse[inst->samplenumber[x]] = 1;
sbuf[0] = 0; cnt = sizeof(sbuf)/sizeof(*sbuf);
sbuf_p = sbuf;
for (x=0; x<m->numsmp; x++)
{
if(pHdr->suse[x])
{
StringCbPrintfExA(sbuf_p, cnt, &sbuf_p, &cnt, 0, "%02d: %s\r\n",x+1, m->samples[x].samplename);
}
}
if (cnt < sizeof(sbuf)/sizeof(*sbuf))
{
sbuf[sizeof(sbuf)/sizeof(*sbuf) - cnt - 2] = 0; // cut off the final CR/LF set
}
SetWindowText(GetDlgItem(hwndDlg, TB_SAMPLELIST), sbuf);
}
break;
case IDC_SAMPLIST:
{ UNISAMPLE *samp = &m->samples[moo];
EXTSAMPLE *es = NULL;
if(m->extsamples) es = &m->extsamples[moo];
// Display sampe header info...
// Length, Format, Quality, Looping, Auto-vibrato, Volume, Panning (in that order).
{
char yn[64] = {0}, pp[64] = {0};
StringCbPrintfA(sbuf, sizeof(sbuf), "%d %s\n%d %s\n%s %s\n%s\n%s\n%d\n%d",
samp->length * (samp->format&SF_16BITS ? 2 : 1), WASABI_API_LNGSTRING_BUF(IDS_BYTES, tmp1, sizeof(tmp1)/sizeof(*tmp1)),
samp->speed, WASABI_API_LNGSTRING_BUF((m->flags&UF_XMPERIODS ? IDS_FINETUNE : (samp->format&SF_SIGNED ? IDS_HZ_SIGNED : IDS_HZ_UNSIGNED)),tmp2,sizeof(tmp2)/sizeof(*tmp2)),
samp->format & SF_16BITS ? "16" : "8", WASABI_API_LNGSTRING_BUF(IDS_BITS, tmp3, sizeof(tmp3)/sizeof(*tmp3)),
WASABI_API_LNGSTRING_BUF((samp->flags&SL_LOOP ? ( samp->flags&SL_BIDI ? IDS_PING_PONG : (samp->flags&SL_REVERSE ? IDS_REVERSE : IDS_FORWARD )) : samp->flags&SL_SUSTAIN_LOOP ? ( samp->flags&SL_SUSTAIN_BIDI ? IDS_SUSTAIN_PING_PONG : IDS_SUSTAIN ) : IDS_NONE),pp,sizeof(pp)/sizeof(*pp)),
WASABI_API_LNGSTRING_BUF(((es && es->vibdepth) ? IDS_YES : IDS_NO),yn,sizeof(yn)/sizeof(*yn)),
samp->volume, samp->panning);
}
SetWindowText(GetDlgItem(hwndDlg, IDC_SAMPINFO), sbuf);
}
break;
}
}
break;
}
return 0;
}
// =====================================================================================
static void OnSelChanged(HWND hwndDlg)
// =====================================================================================
{
DLGHDR *pHdr = (DLGHDR *) GetWindowLong(hwndDlg, GWL_USERDATA);
int iSel = TabCtrl_GetCurSel(pHdr->hwndTab);
if(pHdr->hwndDisplay) ShowWindow(pHdr->hwndDisplay,SW_HIDE);
ShowWindow(pHdr->apRes[iSel],SW_SHOW);
pHdr->hwndDisplay = pHdr->apRes[iSel];
// Note to self: Despite their inhernet use in interfaces, coding tab controls
// apparently REALLY sucks, and it should never ever be done again by myself
// or anyone else whom I respect as a sane individual and I would like to have
// remain that way. As for me, it is too late. Bruhahahaha!K!J!lkjgkljASBfkJBdglkn.
}
// =====================================================================================
static void CALLBACK UpdateInfoRight(HWND hwnd, UINT uMsg, UINT ident, DWORD systime)
// =====================================================================================
{
char str[256] = {0};
DLGHDR *pHdr = (DLGHDR *)GetWindowLong(hwnd, GWL_USERDATA);
MPLAYER *mp;
// Player info update .. BPM, sngspeed, position, row, voices.
// Only update if our mf struct is the same as the one currently loaded into the player.
if ((mp = get_player(pHdr->module)) == NULL)
{
// clean up
if (pHdr->inUse)
{
UNIMOD *m = pHdr->module;
pHdr->inUse = FALSE;
StringCbPrintfA(str, sizeof(str), WASABI_API_LNGSTRING(IDS_X_X_X_OF_X_NOT_PLAYING),
m->inittempo, m->initspeed, m->numpos);
SetDlgItemText(hwnd, IDC_INFORIGHT, str);
if (pHdr->seeker)
{
if (pHdr->seeker != mp)
Player_Free(pHdr->seeker);
pHdr->seeker = NULL;
}
}
// "track song" mode
if (mf && IsDlgButtonChecked(hwnd, IDC_TRACK)==BST_CHECKED)
{
SendMessage(hwnd, WM_USER+10, 0, 0);
infoDlg(GetParent(hwnd), mf, GetActiveWindow()==hwnd, FALSE);
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
}
else
{
MPLAYER *seeker;
long acv;
if (!pHdr->inUse)
{
assert(pHdr->seeker == NULL);
pHdr->inUse = TRUE;
// create our new player instance specifically for seeking
if (!(config_playflag & CPLAYFLG_SEEKBYORDERS))
{
if ((pHdr->seeker = Player_Dup(mp)) == NULL)
return;
// steal statelist from the original player
// (this will not require special handling,
// because of a smart allocation system)
pHdr->seeker->statelist = mp->statelist;
pHdr->seeker->statecount = mp->statecount;
}
else pHdr->seeker = NULL;
}
// Seek to our new song time, using a bastardized version of Player_SetPosTime code:
if (pHdr->seeker)
{
long curtime = mikmod.GetOutputTime() * 64;
seeker = pHdr->seeker;
if (seeker->statelist)
{
int t = 0;
while (t<seeker->statecount &&
seeker->statelist[t].curtime &&
curtime>=seeker->statelist[t].curtime)
t++;
if (t)
Player_Restore(seeker, t - 1);
else Player_Cleaner(seeker);
}
else Player_Cleaner(seeker);
while(!seeker->ended && seeker->state.curtime<curtime)
Player_PreProcessRow(seeker, NULL);
}
else seeker = mp;
// Display all the goodie info we have collected:
// ---------------------------------------------
acv = Mikmod_GetActiveVoices(mp->vs->md);
if (acv > pHdr->maxv) pHdr->maxv = acv;
StringCbPrintfA(str, sizeof(str), WASABI_API_LNGSTRING(IDS_X_X_X_OF_X_X_OF_X_X_OF_X),
seeker->state.bpm, seeker->state.sngspd, seeker->state.sngpos,
seeker->mf->numpos, seeker->mf->positions[seeker->state.sngpos],
seeker->state.patpos, seeker->state.numrow, acv, pHdr->maxv);
SetWindowText(GetDlgItem(hwnd,IDC_INFORIGHT), str);
}
}
// =====================================================================================
void infoDlg(HWND hwnd, UNIMOD *m, BOOL activate, BOOL primiary)
// =====================================================================================
{
INFOBOX *box;
HWND dialog, hwndPrev;
char str[256] = {0};
if (!m) return;
//
// create local dataplace
//
box = (INFOBOX*)calloc(1, sizeof(INFOBOX));
if (!box) return;
box->dlg.left = 7;
box->dlg.top = 168;
box->dlg.module = m;
box->dlg.ownModule = primiary;
box->next = infobox_list;
infobox_list = box;
//
// create dialog
//
hwndPrev = GetActiveWindow();
box->hwnd = dialog = WASABI_API_CREATEDIALOG(IDD_ID3EDIT, hwnd, infoProc);
box->dlg.hwndTab = GetDlgItem(dialog, IDC_TAB);
SetWindowLong(dialog, GWL_USERDATA, (LONG)&box->dlg);
SetDlgItemText(dialog, IDC_ID3_FN, m->filename);
// IDC_INFOLEFT contains static module information:
// File Size, Length (in mins), channels, samples, instruments.
StringCbPrintfA(str, sizeof(str), WASABI_API_LNGSTRING(IDS_X_BTYES_X_OF_X_MINUTES),
m->filesize, m->songlen/60000,(m->songlen%60000)/1000, m->numchn, m->numsmp, m->numins);
SetDlgItemText(dialog, IDC_INFOLEFT, str);
SetDlgItemText(dialog, IDC_TITLE, m->songname);
SetDlgItemText(dialog, IDC_TYPE, m->modtype);
// IDC_INFORIGHT - contains player information
StringCbPrintfA(str, sizeof(str), WASABI_API_LNGSTRING(IDS_X_X_X_OF_X_NOT_PLAYING),
m->inittempo, m->initspeed, m->numpos);
SetDlgItemText(dialog, IDC_INFORIGHT, str);
// pHdr->suse is a samples-used block, allocated if this module uses
// instruments, and used to display the sampels that each inst uses
if (m->numins)
box->dlg.suse = (BOOL*)calloc(m->numsmp, sizeof(BOOL));
CheckDlgButton(dialog, IDC_TRACK, config_track ? BST_CHECKED : BST_UNCHECKED);
infoTabInit(dialog, m, &box->dlg);
SetTimer(dialog, 1, 50, UpdateInfoRight);
ShowWindow(dialog, SW_SHOW);
if (!activate) SetActiveWindow(hwndPrev); // do not steal focus
}
// =====================================================================================
void info_killseeker(HWND hwnd)
// =====================================================================================
{
DLGHDR *pHdr = (DLGHDR *)GetWindowLong(hwnd, GWL_USERDATA);
if (pHdr->seeker)
{
assert(pHdr->inUse);
if (pHdr->seeker != mp)
Player_Free(pHdr->seeker);
pHdr->seeker = NULL;
}
pHdr->inUse = FALSE;
}
// =====================================================================================
static BOOL CALLBACK infoProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
// =====================================================================================
{
UNIMOD *m = NULL;
switch (uMsg)
{
case WM_INITDIALOG:
{
RECT rect, wrect;
if (GetWindowRect(mikmod.hMainWindow, &wrect) && GetWindowRect(hwndDlg, &rect))
{
wrect.left += config_info_x;
wrect.top += config_info_y;
if (wrect.left>=0 && wrect.top>=0 &&
wrect.left<GetSystemMetrics(SM_CXFULLSCREEN)-16 &&
wrect.top<GetSystemMetrics(SM_CYFULLSCREEN)-16)
MoveWindow(hwndDlg, wrect.left, wrect.top, rect.right-rect.left, rect.bottom-rect.top, FALSE);
}
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
break;
case IDC_TRACK:
config_track = IsDlgButtonChecked(hwndDlg, IDC_TRACK) == BST_CHECKED;
break;
}
break;
case WM_USER + 10:
case WM_CLOSE:
// save offset
{
RECT rect, wrect;
if (GetWindowRect(mikmod.hMainWindow, &wrect) && GetWindowRect(hwndDlg, &rect))
{
config_info_x = rect.left - wrect.left;
config_info_y = rect.top - wrect.top;
}
}
config_track = IsDlgButtonChecked(hwndDlg, IDC_TRACK) == BST_CHECKED;
// clean up
if (uMsg != WM_CLOSE)
break;
KillTimer(hwndDlg, 1);
infobox_delete(hwndDlg);
config_write();
break;
case WM_NOTIFY:
{
NMHDR *notice = (NMHDR*)lParam;
switch(notice->code)
{
case TCN_SELCHANGE:
OnSelChanged(hwndDlg);
break;
}
}
return TRUE;
}
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
#ifndef NULLSOFT_API_H
#define NULLSOFT_API_H
#include <api/service/waServiceFactory.h>
#include "../Agave/Language/api_language.h"
#include <api/application/api_application.h>
#define WASABI_API_APP applicationApi
#endif

View file

@ -0,0 +1,254 @@
#include <windows.h>
#include <malloc.h>
#include "mikmod.h"
#include "virtch.h"
#include "main.h"
#include <io.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUFSIZE 28
typedef struct AMP_LOCALINFO
{
uint mode;
uint mixspeed;
uint channels;
SBYTE RAW_DMABUF[(BUFSIZE*1024*2) + 64]; // added 64 for mmx mixer (it's not exact :)
int block_len, bits,ismono, bytes_per_sec;
} AMP_LOCALINFO;
extern int decode_pos; // from main.c
// =====================================================================================
static BOOL RAW_IsThere(void)
// =====================================================================================
{
return 1;
}
// =====================================================================================
static BOOL RAW_Init(MDRIVER *md, uint latency, void *optstr)
// =====================================================================================
{
AMP_LOCALINFO *hwdata;
hwdata = (AMP_LOCALINFO *)MikMod_calloc(md->allochandle, 1, sizeof(AMP_LOCALINFO));
md->device.vc = VC_Init();
if(!md->device.vc)
{ mikmod.outMod->Close();
return 1;
}
hwdata->mode = DMODE_16BITS | DMODE_INTERP | DMODE_NOCLICK;
hwdata->mixspeed = 48000;
hwdata->channels = 2;
md->device.local = hwdata;
return 0;
}
// =====================================================================================
static void RAW_Exit(MDRIVER *md)
// =====================================================================================
{
VC_Exit(md->device.vc);
mikmod.outMod->Close();
}
// =====================================================================================
static void RAW_Update(MDRIVER *md)
// =====================================================================================
{
AMP_LOCALINFO *hwdata = md->device.local;
int l;
char * vis;
int visbits;
if ((l=mikmod.outMod->CanWrite()) > hwdata->block_len*16) l = hwdata->block_len*16;
if (mikmod.dsp_isactive()) l>>=1;
if (l > hwdata->block_len)
{ int o=0;
l -= l % hwdata->block_len;
VC_WriteBytes(md, hwdata->RAW_DMABUF, l);
while (o < l)
{
int a = min(hwdata->block_len,l-o);
if (mikmod.dsp_isactive())
{ int t;
int k = (hwdata->bits>>3)*(hwdata->ismono?1:2);
t = mikmod.dsp_dosamples((short *)(hwdata->RAW_DMABUF+o),a / k,hwdata->bits,(hwdata->ismono?1:2),hwdata->mixspeed) * k;
mikmod.outMod->Write(hwdata->RAW_DMABUF+o,t);
} else
mikmod.outMod->Write(hwdata->RAW_DMABUF+o,a);
vis=hwdata->RAW_DMABUF+o;
visbits=hwdata->bits;
if (visbits > 16)
{
uint n = 576 * 2>>hwdata->ismono;
const uint d = visbits >> 3;
WORD *const visbuf = (WORD*)alloca(n * sizeof(WORD));
char *ptr = vis + d - 2;
WORD *vp = visbuf;
for (;n;n--)
{
*vp++ = *(WORD*)ptr;
ptr += d;
}
vis=(char*)visbuf;
visbits=16;
}
mikmod.SAAddPCMData(vis,hwdata->ismono ? 1 : 2, visbits, decode_pos/64);
mikmod.VSAAddPCMData(vis,hwdata->ismono ? 1 : 2, visbits, decode_pos/64);
decode_pos += (a*1000*64) / hwdata->bytes_per_sec;
o+=a;
}
} else Sleep(6);
}
// =====================================================================================
static BOOL RAW_SetMode(MDRIVER *md, uint mixspeed, uint mode, uint channels, uint cpumode)
// =====================================================================================
{
AMP_LOCALINFO *hwdata = md->device.local;
// Check capabilities...
// [...]
// Set the new mode of play
if (mixspeed) hwdata->mixspeed = mixspeed;
if(!(mode & DMODE_DEFAULT)) hwdata->mode = mode;
switch(channels)
{ case MD_MONO:
hwdata->channels = 1;
break;
default:
hwdata->channels = 2;
channels = MD_STEREO;
break;
}
VC_SetMode(md->device.vc, hwdata->mixspeed, hwdata->mode, channels, cpumode);
{
int bits = (hwdata->mode & DMODE_16BITS) ? 16: ((hwdata->mode & DMODE_24BITS) ? 24 : 8);
int z;
int a = 576*2*(bits>>3);
hwdata->bits = bits;
hwdata->ismono = (hwdata->channels == 1) ? 1 : 0;
if (hwdata->ismono) a/=2;
hwdata->block_len = a;
hwdata->bytes_per_sec = hwdata->mixspeed * (hwdata->bits>>3) * (hwdata->ismono ? 1 : 2);
z = mikmod.outMod->Open(hwdata->mixspeed,hwdata->channels,bits,-1,-1);
if (z < 0) return 1;
mikmod.SAVSAInit(z,hwdata->mixspeed);
mikmod.VSASetInfo(hwdata->mixspeed,hwdata->channels);
mikmod.outMod->SetVolume(-666);
}
return 0;
}
// =====================================================================================
static BOOL AMP_SetSoftVoices(MDRIVER *md, uint voices)
// =====================================================================================
{
return VC_SetSoftVoices(md->device.vc, voices);
}
// =====================================================================================
static void AMP_GetMode(MDRIVER *md, uint *mixspeed, uint *mode, uint *channels, uint *cpumode)
// =====================================================================================
{
VC_GetMode(md->device.vc, mixspeed, mode, channels, cpumode);
}
// =====================================================================================
MD_DEVICE drv_amp =
// =====================================================================================
{
"win32au",
BLAH("Nullsoft win32 output driver v0.700"),
0, VC_MAXVOICES,
NULL,
NULL,
NULL,
// Sample Loading
VC_SampleAlloc,
VC_SampleGetPtr,
VC_SampleLoad,
VC_SampleUnload,
VC_SampleSpace,
VC_SampleLength,
// Detection and Initialization
RAW_IsThere,
RAW_Init,
RAW_Exit,
RAW_Update,
VC_Preempt,
NULL,
AMP_SetSoftVoices,
RAW_SetMode,
AMP_GetMode,
VC_SetVolume,
VC_GetVolume,
// Voice control and Voie information
VC_GetActiveVoices,
VC_VoiceSetVolume,
VC_VoiceGetVolume,
VC_VoiceSetFrequency,
VC_VoiceGetFrequency,
VC_VoiceSetPosition,
VC_VoiceGetPosition,
VC_VoiceSetSurround,
VC_VoiceSetResonance,
VC_VoicePlay,
VC_VoiceResume,
VC_VoiceStop,
VC_VoiceStopped,
VC_VoiceReleaseSustain,
VC_VoiceRealVolume,
};

View file

@ -0,0 +1,176 @@
#include <windows.h>
#include <malloc.h>
#include "mikmod.h"
#include "virtch.h"
#include "main.h"
#include <io.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "drv_buffer.h"
#define BUFSIZE 28
// =====================================================================================
static BOOL Decode_IsThere(void)
// =====================================================================================
{
return 1;
}
// =====================================================================================
static BOOL Decode_Init(MDRIVER *md, uint latency, void *optstr)
// =====================================================================================
{
DecodeInfo *hwdata;
hwdata = (DecodeInfo *)MikMod_calloc(md->allochandle, 1, sizeof(DecodeInfo));
md->device.vc = VC_Init();
if(!md->device.vc)
{
hwdata->error = 1;
return 1;
}
hwdata->mode = DMODE_16BITS | DMODE_INTERP | DMODE_NOCLICK;
hwdata->mixspeed = 48000;
hwdata->channels = 2;
md->device.local = hwdata;
return 0;
}
// =====================================================================================
static void Decode_Exit(MDRIVER *md)
// =====================================================================================
{
DecodeInfo *hwdata = (DecodeInfo *)md->device.local;
VC_Exit(md->device.vc);
}
// =====================================================================================
static void Decode_Update(MDRIVER *md)
// =====================================================================================
{
DecodeInfo *hwdata = (DecodeInfo *)md->device.local;
hwdata->bytesWritten = VC_WriteBytes(md, (SBYTE *)hwdata->buffer, hwdata->buffersize);
}
// =====================================================================================
static BOOL Decode_SetMode(MDRIVER *md, uint mixspeed, uint mode, uint channels, uint cpumode)
// =====================================================================================
{
DecodeInfo *hwdata = (DecodeInfo *)md->device.local;
// Check capabilities...
// [...]
// Set the new mode of play
if (mixspeed) hwdata->mixspeed = mixspeed;
if(!(mode & DMODE_DEFAULT)) hwdata->mode = mode;
switch(channels)
{
case MD_MONO:
hwdata->channels = 1;
break;
default:
hwdata->channels = 2;
channels = MD_STEREO;
break;
}
VC_SetMode(md->device.vc, hwdata->mixspeed, hwdata->mode, channels, cpumode);
int bits = (hwdata->mode & DMODE_16BITS) ? 16: ((hwdata->mode & DMODE_24BITS) ? 24 : 8);
hwdata->bits = bits;
hwdata->frame_size = MulDiv(hwdata->channels, bits, 8);
return 0;
}
// =====================================================================================
static BOOL Decode_SetSoftVoices(MDRIVER *md, uint voices)
// =====================================================================================
{
return VC_SetSoftVoices(md->device.vc, voices);
}
// =====================================================================================
static void Decode_GetMode(MDRIVER *md, uint *mixspeed, uint *mode, uint *channels, uint *cpumode)
// =====================================================================================
{
VC_GetMode(md->device.vc, mixspeed, mode, channels, cpumode);
}
// =====================================================================================
extern "C" MD_DEVICE drv_buffer =
// =====================================================================================
{
"ExtendedRead",
BLAH("Nullsoft Extended Read decode driver v0.1"),
0, VC_MAXVOICES,
NULL,
NULL,
NULL,
// Sample Loading
VC_SampleAlloc,
VC_SampleGetPtr,
VC_SampleLoad,
VC_SampleUnload,
VC_SampleSpace,
VC_SampleLength,
// Detection and Initialization
Decode_IsThere,
Decode_Init,
Decode_Exit,
Decode_Update,
VC_Preempt,
NULL,
Decode_SetSoftVoices,
Decode_SetMode,
Decode_GetMode,
VC_SetVolume,
VC_GetVolume,
// Voice control and Voie information
VC_GetActiveVoices,
VC_VoiceSetVolume,
VC_VoiceGetVolume,
VC_VoiceSetFrequency,
VC_VoiceGetFrequency,
VC_VoiceSetPosition,
VC_VoiceGetPosition,
VC_VoiceSetSurround,
VC_VoiceSetResonance,
VC_VoicePlay,
VC_VoiceResume,
VC_VoiceStop,
VC_VoiceStopped,
VC_VoiceReleaseSustain,
VC_VoiceRealVolume,
};

View file

@ -0,0 +1,18 @@
#pragma once
#include "mikmod.h"
struct DecodeInfo
{
uint mode;
uint mixspeed;
uint channels;
void *buffer;
size_t buffersize;
int bits;
int frame_size; // cached channels*bits/8
int error;
size_t bytesWritten;
};
//extern MD_DEVICE drv_buffer;

View file

@ -0,0 +1,241 @@
#include <windows.h>
#include <mmio.h>
#include <shlwapi.h>
#include "../../winamp/wa_ipc.h"
#include "../../winamp/in2.h"
extern In_Module mikmod;
//big mess here
typedef struct // quick _thiscall hack
{
char *(_fastcall *GetDescription)(void*,int);
int (_fastcall *Open)(void*,int,char *url, int *killswitch);
int (_fastcall *Read)(void*,int,void *buffer, int length, int *killswitch);
int (_fastcall *GetLength)(void*);
int (_fastcall *CanSeek)(void*);
int (_fastcall *Seek)(void*,int,int position, int *killswitch);
char *(_fastcall *GetHeader)(void*,int,char *name);
void (_fastcall *Release)(void*,int,int); // rough ~WReader() hack
} RF_vtbl;
#define RF_Open(x,a,b) (*x)->Open(x,0,a,b)
#define RF_Read(x,a,b,c) (*x)->Read(x,0,a,b,c)
#define RF_GetLength(x) (*x)->GetLength(x)
#define RF_Seek(x,a,b) (*x)->Seek(x,0,a,b)
#define RF_Release(x) (*x)->Release(x,0,0)
#define READ_VER 0x100
typedef struct
{
int version;
char *description;
RF_vtbl ** (_cdecl *create)();
int (_cdecl *ismine)(char *url);
} reader_source;
typedef int (_cdecl *RF_entry)(HINSTANCE hIns,reader_source** s);
static int initialized,got_dll;
static HINSTANCE hRF;
typedef struct
{
RF_vtbl ** r;
UINT size,pos;
} RFstruct;
static RF_vtbl** (_cdecl *rf_create)();
static int rf_init()
{
wchar_t fn[MAX_PATH] = {0};
RF_entry rf_entry;
reader_source * source;
if (initialized) return got_dll;
initialized=1;
PathCombineW(fn, (wchar_t*)SendMessage(mikmod.hMainWindow, WM_WA_IPC, 0, IPC_GETSHAREDDLLDIRECTORYW), L"read_file.dll");
hRF=LoadLibraryW(fn);
if (!hRF) return 0;
rf_entry = (RF_entry)GetProcAddress(hRF,"readerSource");
if (!rf_entry)
{
FreeLibrary(hRF);
return 0;
}
rf_entry(hRF,&source);
if (source->version!=READ_VER)
{
FreeLibrary(hRF);
return 0;
}
rf_create=source->create;
got_dll=1;
return 1;
}
static void rf_quit()
{
if (got_dll)
{
FreeLibrary(hRF);
got_dll=0;
}
initialized=0;
}
static void * _cdecl rfopen(const char * fn)
{
int ks;
RF_vtbl ** r;
RFstruct * rs;
if (!got_dll) return 0;
r=rf_create();
if (!r) return 0;
ks=0;
if (RF_Open(r,(char*)fn,&ks))
{
RF_Release(r);
return 0;
}
rs=malloc(sizeof(RFstruct));
if (!rs)
{
RF_Release(r);
return 0;
}
rs->r=r;
rs->pos=0;
rs->size=RF_GetLength(r);
return rs;
}
static size_t _cdecl rfread( void *buffer, size_t size, size_t count, void *stream )
{
RFstruct * rs;
int ks,rv;
UINT siz;
rs=stream;
ks=0;
siz=size*count;
if (siz>rs->size-rs->pos) siz=rs->size-rs->pos;//just to be sure
rv=RF_Read(rs->r,buffer,siz,&ks);
if (rv>0) rs->pos+=rv;
return rv;
}
static size_t _cdecl rfwrite( const void *buffer, size_t size, size_t count, void *stream ) {return -1;}
static int _cdecl rfgetc( void *stream )
{
RFstruct * rs;
int rv,ks;
rv=0;
ks=0;
rs=stream;
if (RF_Read(rs->r,&rv,1,&ks)>0) rs->pos++;
else rv=EOF;
return rv;
}
static int _cdecl rfputc( int c, void *stream )
{
// not implemented
return -1;
}
static int _cdecl rfseek( void *stream, long offset, int origin )
{
RFstruct * rs;
int ks;
UINT new_pos;
ks=0;
rs=stream;
switch(origin)
{
case SEEK_CUR:
new_pos=rs->pos+offset;
break;
case SEEK_END:
new_pos=rs->size+offset;
break;
case SEEK_SET:
new_pos=offset;
break;
default:
return -1;
}
if (new_pos>rs->size) new_pos=rs->size;
if (RF_Seek(rs->r,new_pos,&ks))
{
return -1;
}
rs->pos=new_pos;
return 0;
}
static long _cdecl rftell(void * stream)
{
RFstruct * rs=stream;
return rs->pos;
}
static int _cdecl rfeof(void * stream)
{
RFstruct * rs=stream;
return rs->pos==rs->size;
}
static int _cdecl rfclose(void * stream)
{
RFstruct * rs=stream;
RF_Release(rs->r);
free(rs);
return 0;
}
static const MMSTREAM_CALLBACK callback_rf =
{
rfread,
rfwrite,
rfgetc,
rfputc,
rfseek,
rftell,
rfeof,
rfclose
};
MMSTREAM *_mm_fopen_rf(const CHAR *fname)
{
void * handle;
if (!rf_init()) return 0;
handle = rfopen(fname);
if (!handle) return _mm_fopen(fname,"rb");
return _mmstream_createfp_callback(handle,0,&callback_rf);
}