uae_u16 len;
uae_u32 offs;
int bitlen, track;
- unsigned int sync;
+ uae_u16 sync;
image_tracktype type;
int revolutions;
} trackid;
static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR *fname)
{
- uae_char buffer[2 + 2 + 4 + 4];
+ uae_u8 buffer[2 + 2 + 4 + 4];
trackid *tid;
int num_tracks, size;
int canauto;
_tcscpy (drv->newname, fname);
gui_filename (dnum, fname);
- memset (buffer, 0, sizeof (buffer));
+ memset (buffer, 0, sizeof buffer);
size = 0;
if (drv->diskfile) {
zfile_fread (buffer, sizeof (char), 8, drv->diskfile);
drv->ddhd = 1;
#ifdef CAPS
- } else if (strncmp (buffer, "CAPS", 4) == 0) {
+ } else if (strncmp ((char*)buffer, "CAPS", 4) == 0) {
drv->wrprot = 1;
if (!caps_loadimage (drv->diskfile, drv - floppy, &num_tracks)) {
drv->num_secs = fdi2raw_get_num_sector (drv->fdi);
drv->filetype = ADF_FDI;
#endif
- } else if (strncmp (buffer, "UAE-1ADF", 8) == 0) {
+ } else if (strncmp ((char*)buffer, "UAE-1ADF", 8) == 0) {
read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
drv->filetype = ADF_EXT2;
if (drv->ddhd > 1)
drv->num_secs = 22;
- } else if (strncmp (buffer, "UAE--ADF", 8) == 0) {
+ } else if (strncmp ((char*)buffer, "UAE--ADF", 8) == 0) {
int offs = 160 * 4 + 8;
int i;
{
int i;
- if (! lockscr ()) {
+ if (! lockscr (false)) {
notice_screen_contents_lost ();
return;
}
int win32_notaskbarbutton;
int win32_alwaysontop;
int win32_powersavedisabled;
+ int win32_minimize_inactive;
int win32_active_priority;
int win32_inactive_priority;
extern void flush_screen (int, int);
extern void flush_clear_screen (void);
-extern int lockscr (void);
+extern int lockscr (int);
extern void unlockscr (void);
extern int debuggable (void);
toggle_inhibit_frame (IHF_SCROLLLOCK);
break;
case AKS_STATEREWIND:
- savestate_dorewind(1);
+ savestate_dorewind (1);
break;
case AKS_VOLDOWN:
sound_volume (-1);
static ID3DXSprite *sprite;
static HWND d3dhwnd;
static int devicelost;
-static int locked;
+static int locked, fulllocked;
static int cursor_offset_x, cursor_offset_y;
static float maskmult_x, maskmult_y;
}
done = 1;
}
- hr = ledtexture->LockRect (0, &locked, NULL, 0);
+ hr = ledtexture->LockRect (0, &locked, NULL, D3DLOCK_DISCARD);
if (FAILED (hr)) {
write_log (L"%d: SL LockRect failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
return;
}
for (y = 0; y < TD_TOTAL_HEIGHT; y++) {
uae_u8 *buf = (uae_u8*)locked.pBits + y * locked.Pitch;
+ memset (buf, 0, ledwidth * 4);
draw_status_line_single (buf, 32 / 8, y, ledwidth, rc, gc, bc, a);
}
ledtexture->UnlockRect (0);
if (locked)
hr = texture->UnlockRect (0);
locked = 0;
+ fulllocked = 0;
}
void D3D_flushtexture (int miny, int maxy)
{
+ if (fulllocked)
+ return;
if (miny >= 0 && maxy >= 0) {
RECT r;
maxy++;
}
}
-uae_u8 *D3D_locktexture (int *pitch)
+uae_u8 *D3D_locktexture (int *pitch, int fullupdate)
{
D3DLOCKED_RECT lock;
HRESULT hr;
lock.pBits = NULL;
lock.Pitch = 0;
- hr = texture->LockRect (0, &lock, NULL, D3DLOCK_NO_DIRTY_UPDATE);
+ hr = texture->LockRect (0, &lock, NULL, fullupdate ? D3DLOCK_DISCARD : D3DLOCK_NO_DIRTY_UPDATE);
if (FAILED (hr)) {
write_log (L"%s: LockRect failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
return NULL;
return NULL;
}
locked = 1;
+ fulllocked = fullupdate;
*pitch = lock.Pitch;
return (uae_u8*)lock.pBits;
}
extern void D3D_getpixelformat (int depth,int *rb, int *bb, int *gb, int *rs, int *bs, int *gs, int *ab, int *ar, int *a);
extern void D3D_refresh (void);
extern void D3D_flip (void);
-extern uae_u8 *D3D_locktexture(int*);
+extern uae_u8 *D3D_locktexture(int*,int);
extern void D3D_unlocktexture(void);
extern void D3D_flushtexture (int miny, int maxy);
extern void D3D_guimode (int guion);
src += picasso96_state.BytesPerRow;
}
} else {
+ uae_u8 *src2 = src;
for (y = 0; y < picasso96_state.Height; y++) {
for (x = 0; x < w; x++)
- src[x] ^= 0xff;
+ src2[x] ^= 0xff;
copyrow (src, dst, 0, y, picasso96_state.Width);
for (x = 0; x < w; x++)
- src[x] ^= 0xff;
+ src2[x] ^= 0xff;
+ src2 += picasso96_state.BytesPerRow;
}
}
}
dofull = gwwcnt >= ((src_end - src_start) / gwwpagesize) * 80 / 100;
- dst = gfx_lock_picasso ();
+ dst = gfx_lock_picasso (dofull);
if (dst == NULL)
break;
lock = 1;
if (!currprefs.gfx_api && (currprefs.leds_on_screen & STATUSLINE_RTG)) {
if (dst == NULL) {
- dst = gfx_lock_picasso ();
+ dst = gfx_lock_picasso (false);
lock = 1;
}
if (dst) {
extern void gfx_set_picasso_colors (RGBFTYPE rgbfmt);
extern void gfx_set_picasso_baseaddr (uaecptr);
extern void gfx_set_picasso_state (int on);
-extern uae_u8 *gfx_lock_picasso (void);
+extern uae_u8 *gfx_lock_picasso (int);
extern void gfx_unlock_picasso (void);
extern void picasso_clip_mouse (int *, int *);
extern int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubledsprite, int chipset);
#define IDC_PORT3_JOYS 1032
#define IDC_PARALLEL 1033
#define IDC_JULIAN 1040
+#define IDC_JULIAN2 1041
+#define IDC_FOCUSMINIMIZE 1041
#define IDC_FASTTEXT 1043
#define IDC_FASTRAM 1044
#define IDC_CHIPRAM 1045
#define IDC_RTG_VBLANKRATE 1793
#define IDC_DF0WPTEXTQ 1793
#define IDC_DF1WPTEXTQ 1794
-#define IDC_INPUTENABLEGAMEPORTS 1796
#define ID__FLOPPYDRIVES 40004
#define ID_FLOPPYDRIVES_DF0 40005
#define ID_ST_CONFIGURATION 40010
BEGIN\r
GROUPBOX "Miscellaneous Options",IDC_STATIC,8,2,290,136\r
CONTROL "Untrap = middle button",IDC_JULIAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,19,110,10\r
- CONTROL "Show GUI on startup",IDC_SHOWGUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,31,109,10\r
+ CONTROL "Show GUI on startup",IDC_SHOWGUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,43,109,10\r
CONTROL "Native On-screen LEDs",IDC_SHOWLEDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,138,80,109,10\r
- CONTROL "Don't show taskbar button",IDC_NOTASKBARBUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,56,109,10\r
- CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,43,110,10\r
+ CONTROL "Don't show taskbar button",IDC_NOTASKBARBUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,67,109,10\r
+ CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,55,110,10\r
GROUPBOX "Keyboard LEDs",IDC_STATIC,7,140,85,94\r
COMBOBOX IDC_KBLED1,22,154,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
COMBOBOX IDC_KBLED2,22,173,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
COMBOBOX IDC_STATE_RATE,248,197,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP\r
RTEXT "Recording buffer (MB):",IDC_STATIC,160,219,83,10,SS_CENTERIMAGE | WS_TABSTOP\r
COMBOBOX IDC_STATE_BUFFERSIZE,248,217,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP\r
- CONTROL "Always on top",IDC_ALWAYSONTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,69,110,10\r
+ CONTROL "Always on top",IDC_ALWAYSONTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,79,110,10\r
CONTROL "USB mode",IDC_KBLED_USB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,216,64,10\r
COMBOBOX IDC_SCSIMODE,213,30,80,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
COMBOBOX IDC_LANGUAGE,153,117,122,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
GROUPBOX "Language",IDC_STATIC,138,107,154,27\r
- CONTROL "Disable screensaver",IDC_POWERSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,82,109,10\r
+ CONTROL "Disable screensaver",IDC_POWERSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,91,109,10\r
COMBOBOX IDC_DD_SURFACETYPE,213,63,79,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r
RTEXT "DirectDraw display buffer:",IDC_STATIC,195,50,92,10,SS_CENTERIMAGE\r
RTEXT "SCSI and CD/DVD access method:",IDC_STATIC,151,12,126,10,SS_CENTERIMAGE\r
- CONTROL "Synchronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,95,111,10\r
+ CONTROL "Synchronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,103,111,10\r
CONTROL "Faster RTG [] Enables less accurate custom chipset emulation mode when Picasso96 is enabled.",IDC_FASTERRTG,\r
- "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,19,108,100,10\r
+ "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,19,115,100,10\r
CONTROL "RTG On-screen LEDs",IDC_SHOWLEDSRTG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,138,93,109,10\r
LTEXT "Graphics API:",IDC_STATIC,136,49,62,10,SS_CENTERIMAGE\r
COMBOBOX IDC_DXMODE,138,62,61,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r
+ CONTROL "Minimize when focus is lost",IDC_FOCUSMINIMIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,31,110,10\r
END\r
\r
IDD_HARDFILE DIALOGEX 0, 0, 299, 249\r
BOTTOMMARGIN, 237\r
END\r
\r
+ IDD_MISC2, DIALOG\r
+ BEGIN\r
+ END\r
+\r
IDD_DISK, DIALOG\r
BEGIN\r
END\r
inputdevice_acquire (FALSE);
wait_keyrelease ();
inputdevice_acquire (TRUE);
- if (isfullscreen() > 0 && !gui_active)
+ if (isfullscreen() != 0 && !gui_active)
setmouseactive (1);
#ifdef LOGITECHLCD
if (!minimized)
dx_check ();
break;
case WM_ACTIVATEAPP:
+ if (!wParam && isfullscreen () <= 0 && currprefs.win32_minimize_inactive)
+ minimizewindow ();
+
#ifdef RETROPLATFORM
rp_activate (wParam, lParam);
#endif
if (isfullscreen () > 0)
minimizewindow ();
#endif
+ if (isfullscreen () < 0 && currprefs.win32_minimize_inactive)
+ minimizewindow ();
if (mouseactive)
setmouseactive (0);
} else {
}
#endif /* _MBCS */
- } while ( (c != NULCHAR && (inquote || (c !=SPACECHAR && c != TABCHAR))) );
+ } while ( (c != NULCHAR && (inquote || (c != SPACECHAR && c != TABCHAR))) );
if ( c == NULCHAR ) {
p--;
numa++;
p = (TCHAR**)xcalloc (uae_u8, numa * sizeof (TCHAR*) + numc * sizeof (TCHAR));
wparse_cmdline (s, (wchar_t **)p, (wchar_t *)(((char *)p) + numa * sizeof(wchar_t *)), &numa, &numc);
- if (numa > MAX_ARGUMENTS)
+ if (numa > MAX_ARGUMENTS) {
p[MAX_ARGUMENTS] = NULL;
- return p;
+ numa = MAX_ARGUMENTS;
+ }
+ TCHAR **dstp = xcalloc (TCHAR*, MAX_ARGUMENTS + 1);
+ for (int i = 0; p[i]; i++)
+ dstp[i] = my_strdup (p[i]);
+ xfree (p);
+ return dstp;
}
xfree (exec);
xfree (cmd);
}
+ for (i = 0; arg && arg[i]; i++)
+ xfree (arg[i]);
xfree (arg);
}
p->win32_ctrl_F11_is_quit = 0;
p->win32_soundcard = 0;
p->win32_soundexclusive = 0;
+ p->win32_minimize_inactive = 0;
p->win32_active_priority = 1;
p->win32_inactive_priority = 2;
p->win32_iconified_priority = 3;
cfgfile_target_dwrite (f, L"iconified_priority", L"%d", priorities[p->win32_iconified_priority].value);
cfgfile_target_dwrite_bool (f, L"iconified_nosound", p->win32_iconified_nosound);
cfgfile_target_dwrite_bool (f, L"iconified_pause", p->win32_iconified_pause);
+ cfgfile_target_dwrite_bool (f, L"inactive_iconify", p->win32_minimize_inactive);
cfgfile_target_dwrite_bool (f, L"ctrl_f11_is_quit", p->win32_ctrl_F11_is_quit);
cfgfile_target_dwrite (f, L"midiout_device", L"%d", p->win32_midioutdev);
p->win32_iconified_priority = fetchpri (v, 2);
return 1;
}
+
+ if (cfgfile_yesno (option, value, L"inactive_iconify", &p->win32_minimize_inactive))
+ return 1;
if (cfgfile_string (option, value, L"serial_port", &p->sername[0], 256)) {
sernametodev(p->sername);
xfree (argv2[i]);
xfree (argv2);
}
+ for (i = 0; argv3 && argv3[i]; i++)
+ xfree (argv3[i]);
+ xfree (argv3);
return FALSE;
}
#define WINUAEPUBLICBETA 1
#define LANG_DLL 1
-#define WINUAEBETA L"17"
-#define WINUAEDATE MAKEBD(2010, 3, 14)
+#define WINUAEBETA L"18"
+#define WINUAEDATE MAKEBD(2010, 3, 20)
#define WINUAEEXTRA L""
#define WINUAEREV L""
bufmem_ptr = sptr;
if (d3d) {
- surfstart = D3D_locktexture (&pitch);
+ surfstart = D3D_locktexture (&pitch, true);
if (surfstart == NULL)
return;
} else {
{
if (!currprefs.gfx_api)
return;
+ if (currentmode->flags & DM_SWSCALE)
+ return;
if (flushymin > lineno) {
if (flushymin - lineno > FLUSH_DIFF && flushymax != 0) {
D3D_flushtexture (flushymin, flushymax);
return gfxvidinfo.bufmem;
}
-int lockscr (void)
+int lockscr (int fullupdate)
{
int ret = 0;
if (!isscreen ())
ret = 1;
if (currentmode->flags & DM_D3D) {
#ifdef D3D
- if ((currentmode->flags & DM_SWSCALE) && usedfilter->type != UAE_FILTER_NULL) {
+ if (currentmode->flags & DM_SWSCALE) {
ret = 1;
} else {
ret = 0;
- gfxvidinfo.bufmem = D3D_locktexture (&gfxvidinfo.rowbytes);
+ gfxvidinfo.bufmem = D3D_locktexture (&gfxvidinfo.rowbytes, fullupdate);
if (gfxvidinfo.bufmem) {
init_row_map ();
ret = 1;
void unlockscr (void)
{
if (currentmode->flags & DM_D3D) {
- if ((currentmode->flags & DM_SWSCALE) && usedfilter->type != UAE_FILTER_NULL)
+ if (currentmode->flags & DM_SWSCALE)
S2X_render ();
-#ifdef D3D
- D3D_flushtexture (flushymin, flushymax);
+ else
+ D3D_flushtexture (flushymin, flushymax);
D3D_unlocktexture ();
-#endif
} else if (currentmode->flags & DM_SWSCALE) {
return;
} else if (currentmode->flags & DM_DDRAW) {
void flush_clear_screen (void)
{
- if (lockscr ()) {
+ if (lockscr (true)) {
int y;
for (y = 0; y < gfxvidinfo.height; y++) {
memset (gfxvidinfo.bufmem + y * gfxvidinfo.rowbytes, 0, gfxvidinfo.width * gfxvidinfo.pixbytes);
picasso_offset_my = picasso96_state.Height * 1000 / (dr->bottom - dr->top);
}
-uae_u8 *gfx_lock_picasso (void)
+uae_u8 *gfx_lock_picasso (int fullupdate)
{
if (currprefs.gfx_api) {
int pitch;
- uae_u8 *p = D3D_locktexture (&pitch);
+ uae_u8 *p = D3D_locktexture (&pitch, fullupdate);
picasso_vidinfo.rowbytes = pitch;
return p;
} else {
: currprefs.color_mode == 2 ? 16 : 32;
if (screen_is_picasso && currprefs.win32_rtgmatchdepth && isfullscreen () > 0) {
int pbits = picasso96_state.BytesPerPixel * 8;
+ if (pbits <= 8)
+ pbits = 16;
if (pbits == 24)
pbits = 32;
currentmode->current_depth = pbits;
currprefs.keyboard_leds[0] != changed_prefs.keyboard_leds[0] ||
currprefs.keyboard_leds[1] != changed_prefs.keyboard_leds[1] ||
currprefs.keyboard_leds[2] != changed_prefs.keyboard_leds[2] ||
+ currprefs.win32_minimize_inactive != changed_prefs.win32_minimize_inactive ||
currprefs.win32_middle_mouse != changed_prefs.win32_middle_mouse ||
currprefs.win32_active_priority != changed_prefs.win32_active_priority ||
currprefs.win32_inactive_priority != changed_prefs.win32_inactive_priority ||
currprefs.win32_iconified_pause != changed_prefs.win32_iconified_pause ||
currprefs.win32_ctrl_F11_is_quit != changed_prefs.win32_ctrl_F11_is_quit)
{
+ currprefs.win32_minimize_inactive = changed_prefs.win32_minimize_inactive;
currprefs.leds_on_screen = changed_prefs.leds_on_screen;
currprefs.keyboard_leds[0] = changed_prefs.keyboard_leds[0];
currprefs.keyboard_leds[1] = changed_prefs.keyboard_leds[1];
if (isfullscreen () > 0) {
/* fullscreen to fullscreen */
if (screen_is_picasso) {
- if (picasso96_state.BytesPerPixel * 8 != wc->current_depth && currprefs.win32_rtgmatchdepth)
+ if (picasso96_state.BytesPerPixel > 1 && picasso96_state.BytesPerPixel * 8 != wc->current_depth && currprefs.win32_rtgmatchdepth)
return -1;
if (picasso96_state.Width < wc->current_width && picasso96_state.Height < wc->current_height) {
if (currprefs.win32_rtgscaleifsmall && !currprefs.win32_rtgmatchdepth)
return 1;
if (picasso96_state.Width == wc->current_width &&
picasso96_state.Height == wc->current_height) {
- if (picasso96_state.BytesPerPixel * 8 == wc->current_depth)
+ if (picasso96_state.BytesPerPixel * 8 == wc->current_depth || picasso96_state.BytesPerPixel == 1)
return 0;
- if (!currprefs.win32_rtgmatchdepth && wc->current_depth >= 16)
+ if (!currprefs.win32_rtgmatchdepth)
return 0;
}
return 1;
gfxvidinfo.pixbytes = currentmode->current_depth >> 3;
gfxvidinfo.bufmem = 0;
gfxvidinfo.linemem = 0;
- gfxvidinfo.emergmem = scrlinebuf; // memcpy from system-memory to video-memory
gfxvidinfo.width = (currentmode->amiga_width + 7) & ~7;
gfxvidinfo.height = currentmode->amiga_height;
gfxvidinfo.maxblocklines = 0; // flush_screen actually does everything
picasso_vidinfo.depth = currentmode->current_depth;
picasso_vidinfo.offset = 0;
#endif
+ gfxvidinfo.emergmem = scrlinebuf; // memcpy from system-memory to video-memory
xfree (gfxvidinfo.realbufmem);
gfxvidinfo.realbufmem = NULL;
if (currentpage == MISC1_ID) {
+ CheckDlgButton (hDlg, IDC_FOCUSMINIMIZE, workprefs.win32_minimize_inactive);
CheckDlgButton (hDlg, IDC_ILLEGAL, workprefs.illegal_mem);
CheckDlgButton (hDlg, IDC_SHOWGUI, workprefs.start_gui);
CheckDlgButton (hDlg, IDC_JULIAN, workprefs.win32_middle_mouse);
case IDC_JULIAN:
workprefs.win32_middle_mouse = IsDlgButtonChecked(hDlg, IDC_JULIAN);
break;
+ case IDC_FOCUSMINIMIZE:
+ workprefs.win32_minimize_inactive = IsDlgButtonChecked (hDlg, IDC_FOCUSMINIMIZE);
+ break;
case IDC_SHOWLEDS:
workprefs.leds_on_screen &= ~STATUSLINE_CHIPSET;
if (IsDlgButtonChecked(hDlg, IDC_SHOWLEDS))
#include "options.h"
#include "events.h"
+#include "custom.h"
#include "dxwrap.h"
static LPDIRECTSOUNDCAPTUREBUFFER lpDSB2r = NULL;
static int inited;
static uae_u8 *samplebuffer;
+static int samplerate = 44100;
+static float clockspersample;
static int capture_init (void)
{
wavfmt.wFormatTag = WAVE_FORMAT_PCM;
wavfmt.nChannels = 2;
- wavfmt.nSamplesPerSec = 44100;
+ wavfmt.nSamplesPerSec = samplerate;
wavfmt.wBitsPerSample = 16;
wavfmt.nBlockAlign = wavfmt.wBitsPerSample / 8 * wavfmt.nChannels;
wavfmt.nAvgBytesPerSec = wavfmt.nBlockAlign * wavfmt.nSamplesPerSec;
sound_buffer_rec.lpwfxFormat = &wavfmt;
sound_buffer_rec.dwFlags = 0 ;
- hr = IDirectSoundCapture_CreateCaptureBuffer (lpDS2r, &sound_buffer_rec, &lpDSB2r, NULL);
+ hr = lpDS2r->CreateCaptureBuffer (&sound_buffer_rec, &lpDSB2r, NULL);
if (FAILED (hr)) {
write_log (L"SAMPLER: CreateCaptureSoundBuffer() failure: %s\n", DXError(hr));
return 0;
}
- hr = IDirectSoundCaptureBuffer_Start (lpDSB2r, DSCBSTART_LOOPING);
+ hr = lpDSB2r->Start (DSCBSTART_LOOPING);
if (FAILED (hr)) {
write_log (L"SAMPLER: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr));
return 0;
static void capture_free (void)
{
- if (lpDSB2r)
- IDirectSoundCaptureBuffer_Release (lpDSB2r);
+ if (lpDSB2r) {
+ lpDSB2r->Stop ();
+ lpDSB2r->Release ();
+ }
lpDSB2r = NULL;
if (lpDS2r)
- IDirectSound_Release (lpDS2r);
+ lpDS2r->Release ();
lpDS2r = NULL;
xfree (samplebuffer);
samplebuffer = NULL;
}
static evt oldcycles;
+static int oldoffset;
uae_u8 sampler_getsample (void)
{
DWORD len1, len2;
evt cycles;
int offset;
+ int sample, samplecnt;
+ uae_s16 *sbuf = (uae_s16*)samplebuffer;
if (!inited) {
if (!capture_init ())
return 0;
inited = 1;
}
- cycles = get_cycles ();
- offset = (cycles - oldcycles) / CYCLE_UNIT;
+ sample = 0;
+ samplecnt = 0;
+ cycles = get_cycles () - oldcycles;
+ offset = cycles / clockspersample;
if (offset >= SAMPLEBUFFER || offset < 0) {
+ if (offset >= SAMPLEBUFFER) {
+ while (oldoffset < SAMPLEBUFFER) {
+ sample += sbuf[oldoffset * 2];
+ oldoffset++;
+ samplecnt++;
+ }
+ }
oldcycles = cycles;
- offset = 0;
cap_pos = 0;
- hr = IDirectSoundCaptureBuffer_GetCurrentPosition (lpDSB2r, &t, &cur_pos);
+ hr = lpDSB2r->GetCurrentPosition (&t, &cur_pos);
if (FAILED (hr))
return 0;
- hr = IDirectSoundCaptureBuffer_Lock (lpDSB2r, cap_pos, SAMPLEBUFFER, &p1, &len1, &p2, &len2, 0);
+ hr = lpDSB2r->Lock (cap_pos, SAMPLEBUFFER, &p1, &len1, &p2, &len2, 0);
if (FAILED (hr))
return 0;
memcpy (samplebuffer, p1, len1);
if (p2)
memcpy (samplebuffer + len1, p2, len2);
- IDirectSoundCaptureBuffer_Unlock (lpDSB2r, p1, len1, p2, len2);
+ lpDSB2r->Unlock (p1, len1, p2, len2);
+ offset = 0;
+ }
+ while (oldoffset <= offset) {
+ sample += ((uae_s16*)samplebuffer)[oldoffset * 2];
+ oldoffset++;
+ samplecnt++;
}
- return samplebuffer[offset * 4 + 1];
+ oldoffset = offset;
+ if (samplecnt > 0)
+ sample /= samplecnt;
+ return sample >> 8;
}
int sampler_init (void)
{
+ clockspersample = (float)maxvpos * maxhpos * vblank_hz * CYCLE_UNIT / samplerate;
+ oldcycles = get_cycles ();
if (!currprefs.parallel_sampler)
return 0;
return 1;