This commit is contained in:
Toni Wilen 2010-04-03 18:23:17 +03:00
parent 2a32dc5024
commit 9e4a0b5d94
22 changed files with 690 additions and 355 deletions

View File

@ -1675,6 +1675,7 @@ void akiko_reset (void)
akiko_thread_running = 0;
}
akiko_cdrom_free ();
mediacheckcounter = 0;
}

View File

@ -1837,7 +1837,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va
}
if (strcasecmp (option, L"quickstart") == 0) {
int model = -1;
int model = 0;
TCHAR *tmpp = _tcschr (value, ',');
if (tmpp) {
*tmpp++ = 0;

View File

@ -643,7 +643,7 @@ static uae_u8 ReadCIAA (unsigned int addr)
#endif
} else if (currprefs.win32_samplersoundcard >= 0) {
tmp = sampler_getsample ();
tmp = sampler_getsample ((ciabpra & 4) ? 1 : 0);
} else
#endif

View File

@ -5066,6 +5066,8 @@ static void vsync_handler (void)
}
if ((beamcon0 & (0x20 | 0x80)) != (new_beamcon0 & (0x20 | 0x80)) || (abs (vpos_count - vpos_count_prev) > 1))
init_hz ();
if (lof_changed)
compute_vsynctime ();
vpos_count_prev = vpos_count;
lof_changed = 0;

File diff suppressed because it is too large Load Diff

View File

@ -58,6 +58,11 @@
#define QUALITY_DRAFT 0x01
#define QUALITY_LQ 0x02
#define JUST_LEFT 0
#define JUST_CENTER 1
#define JUST_RIGHT 2
#define JUST_FULL 3
enum Typeface
{
roman = 0,

View File

@ -72,6 +72,7 @@ extern int input_get_default_mouse (struct uae_input_device *uid, int num, int p
extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port);
extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int cd32);
extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port);
extern int input_get_default_keyboard (int num);
#define DEFEVENT(A, B, C, D, E, F) INPUTEVENT_ ## A,
enum inputevents {

View File

@ -1,5 +1,5 @@
extern uae_u8 sampler_getsample (void);
extern uae_u8 sampler_getsample (int);
extern int sampler_init (void);
extern void sampler_free (void);
extern void sampler_vsync (void);

View File

@ -3678,7 +3678,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs)
config_changed = 1;
}
static void set_kbr_default (struct uae_prefs *p, int index, int num)
static void set_kbr_default (struct uae_prefs *p, int index)
{
int i, j, k, l;
struct uae_input_device_kbr_default *trans = keyboard_default;
@ -3695,10 +3695,10 @@ static void set_kbr_default (struct uae_prefs *p, int index, int num)
kbr->extra[i][0] = -1;
}
if (j < id->get_num ()) {
if (j == 0)
if (input_get_default_keyboard (j))
kbr->enabled = 1;
for (i = 0; i < id->get_widget_num (num); i++) {
id->get_widget_type (num, i, 0, &scancode);
for (i = 0; i < id->get_widget_num (j); i++) {
id->get_widget_type (j, i, 0, &scancode);
kbr->extra[i][0] = scancode;
l = 0;
while (trans[l].scancode >= 0) {
@ -3737,7 +3737,7 @@ void inputdevice_default_prefs (struct uae_prefs *p)
p->input_mouse_speed = 100;
p->input_autofire_framecnt = 10;
for (i = 0; i <= MAX_INPUT_SETTINGS; i++) {
set_kbr_default (p, i, 0);
set_kbr_default (p, i);
for (j = 0; j < MAX_INPUT_DEVICES; j++) {
if (input_get_default_mouse (p->mouse_settings[i], j, j & 1))
p->mouse_settings[i]->enabled = 1;
@ -4653,6 +4653,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum,
p->jports[portnum].id = idnum + i;
if (mode >= 0)
p->jports[portnum].mode = mode;
config_changed = 1;
return 1;
}
}
@ -4694,6 +4695,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum,
p->jports[portnum].id = start;
if (mode >= 0)
p->jports[portnum].mode = mode;
config_changed = 1;
return 1;
}
}

View File

@ -104,7 +104,7 @@ static int oldleds, oldusedleds, newleds, oldusbleds;
static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber, winmousemode, winmousewheelbuttonstart;
static int normalkb, superkb, rawkb;
int rawkeyboard;
int rawkeyboard = -1;
int no_rawinput;
int dinput_enum_all;
@ -896,11 +896,11 @@ static int initialize_rawinput (void)
} else {
int j;
PRID_DEVICE_INFO_KEYBOARD rdik = &rdi->keyboard;
write_log (L"type=%d sub=%d mode=%d fkeys=%d indicators=%d tkeys=%d",
write_log (L"type=%d sub=%d mode=%d fkeys=%d indicators=%d tkeys=%d\n",
rdik->dwType, rdik->dwSubType, rdik->dwKeyboardMode,
rdik->dwNumberOfFunctionKeys, rdik->dwNumberOfIndicators, rdik->dwNumberOfKeysTotal);
j = 0;
for (i = 0; i < 254; i++) {
for (int k = 0; k < 254; k++) {
TCHAR tmp[100];
tmp[0] = 0;
if (rawkeyboardlabels[j] != NULL) {
@ -912,10 +912,10 @@ static int initialize_rawinput (void)
j++;
}
if (!tmp[0])
_stprintf (tmp, L"Key %02X", i + 1);
did->buttonname[i] = my_strdup (tmp);
did->buttonmappings[i] = i + 1;
did->buttonsort[i] = i + 1;
_stprintf (tmp, L"Key %02X", k + 1);
did->buttonname[k] = my_strdup (tmp);
did->buttonmappings[k] = k + 1;
did->buttonsort[k] = k + 1;
did->buttons++;
}
}
@ -1067,17 +1067,15 @@ static void handle_rawinput_2 (RAWINPUT *raw)
if (scancode == 0xaa)
return;
#if 0
#if 1
for (num = 0; num < num_keyboard; num++) {
did = &di_keyboard[num];
if ((did->acquired || rawkeyboard > 0) && did->rawinput == raw->header.hDevice)
if (did->acquired && did->rawinput == raw->header.hDevice)
break;
}
if (num == num_keyboard) {
if (scancode == DIK_F12 && pressed) {
if (scancode == DIK_F12 && pressed)
inputdevice_add_inputcode (AKS_ENTERGUI, 1);
return;
}
return;
}
#endif
@ -1330,7 +1328,7 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
if (pdidoi->dwType & DIDFT_BUTTON) {
if (did->buttons >= MAX_MAPPINGS)
return DIENUM_CONTINUE;
did->buttonname[did->buttons] = my_strdup (pdidoi->tszName);
TCHAR *bname = did->buttonname[did->buttons] = my_strdup (pdidoi->tszName);
if (did->type == DID_JOYSTICK) {
//did->buttonmappings[did->buttons] = DIJOFS_BUTTON(DIDFT_GETINSTANCE (pdidoi->dwType));
did->buttonmappings[did->buttons] = DIJOFS_BUTTON(did->buttons);
@ -1339,9 +1337,15 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
//did->buttonmappings[did->buttons] = FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + DIDFT_GETINSTANCE (pdidoi->dwType);
did->buttonmappings[did->buttons] = FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + did->buttons;
did->buttonsort[did->buttons] = makesort_mouse (&pdidoi->guidType, &did->buttonmappings[did->buttons]);
} else {
} else if (did->type == DID_KEYBOARD) {
//did->buttonmappings[did->buttons] = pdidoi->dwOfs;
did->buttonmappings[did->buttons] = DIDFT_GETINSTANCE (pdidoi->dwType);
if (rawkeyboard && (!_tcsicmp (bname, L"kana") || 0)) { // buggy layout?
if (rawkeyboard != 2) {
write_log (L"Possible buggy directinput keyboard layout detected, switching to raw keyboard mode\n");
rawkeyboard = 2;
}
}
}
did->buttons++;
}
@ -1481,10 +1485,8 @@ static int di_do_init (void)
write_log (L"DirectInput enumeration..\n");
g_lpdi->EnumDevices (DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
} else {
if (rawkeyboard <= 0) {
write_log (L"DirectInput enumeration.. Keyboards..\n");
g_lpdi->EnumDevices (DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
}
write_log (L"DirectInput enumeration.. Keyboards..\n");
g_lpdi->EnumDevices (DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
write_log (L"DirectInput enumeration.. Pointing devices..\n");
g_lpdi->EnumDevices (DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
write_log (L"DirectInput enumeration.. Game controllers..\n");
@ -2532,6 +2534,19 @@ int dinput_wmkey (uae_u32 key)
return 0;
}
int input_get_default_keyboard (int i)
{
if (rawkeyboard > 0) {
if (i == 0)
return 0;
return 1;
} else {
if (i == 0)
return 1;
return 0;
}
}
int input_get_default_mouse (struct uae_input_device *uid, int i, int port)
{
struct didata *did;

View File

@ -1498,7 +1498,7 @@ static int restoredeviceobjects (void)
write_log (L"%s: LED D3DXSprite failed: %s\n", D3DHEAD, D3D_ErrorString (hr));
}
int curw = 64, curh = 64;
int curw = CURSORMAXWIDTH, curh = CURSORMAXHEIGHT;
cursorsurfaced3d = createtext (curw, curh, D3DFMT_A8R8G8B8);
cursor_v = 0;

View File

@ -16,3 +16,6 @@ extern int D3D_canshaders (void);
extern int D3D_goodenough (void);
extern void D3D_setcursor (int x, int y, int visible);
extern LPDIRECT3DTEXTURE9 cursorsurfaced3d;
#define CURSORMAXWIDTH 64
#define CURSORMAXHEIGHT 64

View File

@ -262,7 +262,7 @@ static void flushprtbuf (void)
if (currprefs.parallel_matrix_emulation >= PARALLEL_MATRIX_EPSON) {
int i;
if (!prtopen) {
if (epson_init (currprefs.parallel_matrix_emulation))
if (epson_init (currprefs.prtname, currprefs.parallel_matrix_emulation))
prtopen = 1;
}
for (i = 0; i < prtbufbytes; i++)
@ -472,7 +472,7 @@ static void openprinter (void)
prtopen = 1;
return;
} else if (currprefs.parallel_matrix_emulation >= PARALLEL_MATRIX_EPSON) {
epson_init (currprefs.parallel_matrix_emulation);
epson_init (currprefs.prtname, currprefs.parallel_matrix_emulation);
} else if (hPrt == INVALID_HANDLE_VALUE) {
flushprtbuf ();
if (OpenPrinter (currprefs.prtname, &hPrt, NULL)) {

View File

@ -47,7 +47,7 @@ extern void sernametodev (TCHAR*);
extern void serdevtoname (TCHAR*);
extern void epson_printchar(uae_u8 c);
extern int epson_init(int pins);
extern int epson_init(const TCHAR *printername, int pins);
extern void epson_close(void);
#define PARALLEL_MATRIX_TEXT 1

View File

@ -62,6 +62,8 @@
#define NOBLITTER 0
#define NOBLITTER_BLIT 0
#define P96TRACING_ENABLED 0
#define P96SPRTRACING_ENABLED 0
static int hwsprite = 0;
static int picasso96_BT = BT_uaegfx;
@ -71,9 +73,6 @@ static int picasso96_PCT = PCT_Unknown;
int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, PULONG_PTR lpdwCount, PULONG lpdwGranularity);
void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize);
#define P96TRACING_ENABLED 0
#define P96SPRTRACING_ENABLED 0
int p96refresh_active;
int have_done_picasso = 1; /* For the JIT compiler */
static int p96syncrate;
@ -580,14 +579,22 @@ static void setupcursor (void)
HRESULT hr;
setupcursor_needed = 1;
if (cursorsurfaced3d && cursordata && cursorwidth && cursorheight) {
if (cursorsurfaced3d) {
if (SUCCEEDED (hr = cursorsurfaced3d->LockRect (0, &locked, NULL, 0))) {
dptr = (uae_u8*)locked.pBits;
pitch = locked.Pitch;
for (int y = 0; y < cursorheight; y++) {
uae_u8 *p1 = cursordata + cursorwidth * bpp * y;
for (int y = 0; y < CURSORMAXHEIGHT; y++) {
uae_u8 *p2 = dptr + pitch * y;
memcpy (p2, p1, cursorwidth * bpp);
memset (p2, 0, CURSORMAXWIDTH * bpp);
}
if (cursordata && cursorwidth && cursorheight) {
dptr = (uae_u8*)locked.pBits;
pitch = locked.Pitch;
for (int y = 0; y < cursorheight; y++) {
uae_u8 *p1 = cursordata + cursorwidth * bpp * y;
uae_u8 *p2 = dptr + pitch * y;
memcpy (p2, p1, cursorwidth * bpp);
}
}
cursorsurfaced3d->UnlockRect (0);
setupcursor_needed = 0;
@ -1608,7 +1615,11 @@ static uae_u32 setspriteimage (uaecptr bi)
}
cursorwidth = w;
if (cursorwidth > CURSORMAXWIDTH)
cursorwidth = CURSORMAXWIDTH;
cursorheight = h;
if (cursorheight > CURSORMAXHEIGHT)
cursorheight = CURSORMAXHEIGHT;
setupcursor ();
ret = 1;

View File

@ -110,6 +110,7 @@ static const TCHAR *getmsg (int msg)
case RPIPCHM_PING: return L"RPIPCHM_PING";
case RPIPCHM_SAVESTATE: return L"RPIPCHM_SAVESTATE";
case RPIPCHM_LOADSTATE: return L"RPIPCHM_LOADSTATE";
case RPIPCHM_FLUSH: return L"RPIPCHM_FLUSH";
default: return L"UNKNOWN";
}
@ -303,7 +304,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
int m;
int full = 0;
int vres = 0;
int totalhdbl, totalvdbl;
int totalhdbl = -1, totalvdbl = -1;
hres = p->gfx_resolution;
if (p->gfx_filter && p->gfx_filter_horiz_zoom_mult)
@ -339,9 +340,9 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
if (log_rp)
write_log (L"GET_RPSM: hres=%d (%d) vres=%d (%d) full=%d xcpos=%d ycpos=%d w=%d h=%d\n",
totalhdbl, hres, totalvdbl, vres, full,
p->gfx_xcenter_pos, p->gfx_ycenter_pos,
p->gfx_size_win.width, p->gfx_size_win.height);
totalhdbl, hres, totalvdbl, vres, full,
p->gfx_xcenter_pos, p->gfx_ycenter_pos,
p->gfx_size_win.width, p->gfx_size_win.height);
sm->lClipLeft = p->gfx_xcenter_pos <= 0 ? -1 : p->gfx_xcenter_pos;
sm->lClipTop = p->gfx_ycenter_pos <= 0 ? -1 : p->gfx_ycenter_pos;
if (full) {
@ -369,8 +370,8 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
if (log_rp)
write_log (L"GET_RPSM: %08X %dx%d %dx%d hres=%d (%d) vres=%d (%d) disp=%d fs=%d\n",
sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
totalhdbl, hres, totalvdbl, vres, p->gfx_display, full);
sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
totalhdbl, hres, totalvdbl, vres, p->gfx_display, full);
}
static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)

View File

@ -171,8 +171,12 @@ void update_sound (int freq, int longframe, int linetoggle)
lines += 1.0;
hpos = maxhpos_short;
}
#if 0
write_log (L"%d.%d %d.%d\n",
maxhpos_short, linetoggle ? 5 : 0,
maxvpos_nom + (lines == 1.0 ? 1 : 0), lines > 0 && lines < 1 ? 5 : 0);
#endif
lines += maxvpos_nom;
scaled_sample_evtime_orig = hpos * lines * freq * CYCLE_UNIT / (float)sdp->obtainedfreq;
scaled_sample_evtime = scaled_sample_evtime_orig;
}

View File

@ -4347,12 +4347,12 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR
enumerate_sound_devices ();
for (i = 0; sound_devices[i].name; i++) {
int type = sound_devices[i].type;
write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : L"PA"), sound_devices[i].name);
write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : (type == SOUND_DEVICE_WASAPI ? L"WA" : L"PA")), sound_devices[i].name);
}
write_log (L"Enumerating recording devices:\n");
for (i = 0; record_devices[i].name; i++) {
int type = record_devices[i].type;
write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : L"PA"), record_devices[i].name);
write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : (type == SOUND_DEVICE_WASAPI ? L"WA" : L"PA")), record_devices[i].name);
}
write_log (L"done\n");
memset (&devmode, 0, sizeof (devmode));

View File

@ -18,8 +18,8 @@
#define WINUAEPUBLICBETA 1
#define LANG_DLL 1
#define WINUAEBETA L"19"
#define WINUAEDATE MAKEBD(2010, 3, 27)
#define WINUAEBETA L"20"
#define WINUAEDATE MAKEBD(2010, 4, 3)
#define WINUAEEXTRA L""
#define WINUAEREV L""

View File

@ -49,6 +49,7 @@
#include "gfxfilter.h"
#include "parser.h"
#include "lcd.h"
#include "sampler.h"
#ifdef RETROPLATFORM
#include "rp.h"
#endif
@ -317,20 +318,22 @@ static int set_ddraw_2 (void)
for (;;) {
int i, j, got = FALSE;
HRESULT olderr;
struct MultiDisplay *md = getdisplay (&currprefs);
for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
struct PicassoResolution *pr = &md->DisplayModes[i];
if (pr->res.width == width && pr->res.height == height) {
for (j = 0; pr->refresh[j] > 0; j++) {
if (pr->refresh[j] == freq)
got = TRUE;
if (freq > 0) {
struct MultiDisplay *md = getdisplay (&currprefs);
for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
struct PicassoResolution *pr = &md->DisplayModes[i];
if (pr->res.width == width && pr->res.height == height) {
for (j = 0; pr->refresh[j] > 0; j++) {
if (pr->refresh[j] == freq)
got = TRUE;
}
break;
}
break;
}
}
if (got == FALSE) {
write_log (L"set_ddraw: refresh rate %d not supported\n", freq);
freq = 0;
if (got == FALSE) {
write_log (L"set_ddraw: refresh rate %d not supported\n", freq);
freq = 0;
}
}
write_log (L"set_ddraw: trying %dx%d, bits=%d, refreshrate=%d\n", width, height, bits, freq);
ddrval = DirectDraw_SetDisplayMode (width, height, bits, freq);
@ -1474,6 +1477,11 @@ int check_prefs_changed_gfx (void)
return 1;
}
if (currprefs.win32_samplersoundcard != changed_prefs.win32_samplersoundcard) {
currprefs.win32_samplersoundcard = changed_prefs.win32_samplersoundcard;
sampler_free ();
}
if (_tcscmp (currprefs.prtname, changed_prefs.prtname) ||
currprefs.parallel_autoflush_time != changed_prefs.parallel_autoflush_time ||
currprefs.parallel_matrix_emulation != changed_prefs.parallel_matrix_emulation ||

View File

@ -163,7 +163,7 @@
<OutputFile>d:\amiga\winuae.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<DelayLoadDLLs>wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;freetype6.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;avrt.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\Debug/winuae.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
@ -289,7 +289,7 @@
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalManifestDependencies>%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<DelayLoadDLLs>wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;freetype6.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;avrt.dll;wininet.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;wininet.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\Release/winuae.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>

View File

@ -18,8 +18,9 @@
#include "win32.h"
#define RECORDBUFFER (10000 * 4)
#define SAMPLEBUFFER (2048 * 4)
#define SAMPLESIZE 4
#define RECORDBUFFER 40000
#define SAMPLEBUFFER 4000
static LPDIRECTSOUNDCAPTURE lpDS2r = NULL;
static LPDIRECTSOUNDCAPTUREBUFFER lpDSBprimary2r = NULL;
@ -51,7 +52,7 @@ static int capture_init (void)
}
memset (&sound_buffer_rec, 0, sizeof (DSCBUFFERDESC));
sound_buffer_rec.dwSize = sizeof (DSCBUFFERDESC);
sound_buffer_rec.dwBufferBytes = RECORDBUFFER;
sound_buffer_rec.dwBufferBytes = RECORDBUFFER * SAMPLESIZE;
sound_buffer_rec.lpwfxFormat = &wavfmt;
sound_buffer_rec.dwFlags = 0 ;
@ -66,7 +67,7 @@ static int capture_init (void)
write_log (L"SAMPLER: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr));
return 0;
}
samplebuffer = xcalloc (uae_u8, SAMPLEBUFFER);
samplebuffer = xcalloc (uae_u8, SAMPLEBUFFER * SAMPLESIZE);
write_log (L"SAMPLER: Parallel port sampler initialized\n");
return 1;
}
@ -89,17 +90,20 @@ static void capture_free (void)
static evt oldcycles;
static int oldoffset;
uae_u8 sampler_getsample (void)
uae_u8 sampler_getsample (int channel)
{
HRESULT hr;
DWORD t, cur_pos, cap_pos;
static DWORD cap_pos;
DWORD t, cur_pos;
void *p1, *p2;
DWORD len1, len2;
evt cycles;
int offset;
int sample, samplecnt, diff;
int channel = 0;
uae_s16 *sbuf = (uae_s16*)samplebuffer;
// if (channel)
// return 0;
channel = 0;
if (!inited) {
if (!capture_init ()) {
@ -115,6 +119,8 @@ uae_u8 sampler_getsample (void)
return 0;
}
}
uae_s16 *sbuf = (uae_s16*)samplebuffer;
vsynccnt = 0;
sample = 0;
samplecnt = 0;
@ -123,52 +129,59 @@ uae_u8 sampler_getsample (void)
if (oldoffset < 0 || offset >= SAMPLEBUFFER || offset < 0) {
if (oldoffset >= 0 && offset >= SAMPLEBUFFER) {
while (oldoffset < SAMPLEBUFFER) {
sample += sbuf[oldoffset * 2 + channel];
sample += sbuf[oldoffset * SAMPLESIZE / 2 + channel];
oldoffset++;
samplecnt++;
}
}
oldcycles = cycles;
cap_pos = 0;
hr = lpDSB2r->GetCurrentPosition (&t, &cur_pos);
if (FAILED (hr))
return 0;
write_log (L"%d\n", cur_pos - cap_pos);
if (cur_pos >= cap_pos)
diff = cur_pos - cap_pos;
else
diff = RECORDBUFFER - cap_pos + cur_pos;
if (diff > SAMPLEBUFFER * 4) {
cap_pos = cur_pos;
oldoffset = 0;
oldcycles = get_cycles ();
}
hr = lpDSB2r->Lock (cap_pos, SAMPLEBUFFER, &p1, &len1, &p2, &len2, 0);
//write_log (L"%d\n", cur_pos - cap_pos);
hr = lpDSB2r->Lock (cap_pos, SAMPLEBUFFER * SAMPLESIZE, &p1, &len1, &p2, &len2, 0);
if (FAILED (hr))
return 0;
memcpy (samplebuffer, p1, len1);
if (p2)
memcpy (samplebuffer + len1, p2, len2);
lpDSB2r->Unlock (p1, len1, p2, len2);
cap_pos += SAMPLEBUFFER;
cap_pos += SAMPLEBUFFER * SAMPLESIZE;
hr = lpDSB2r->GetCurrentPosition (&t, &cur_pos);
if (FAILED (hr))
return 0;
if (cur_pos >= cap_pos)
diff = cur_pos - cap_pos;
else
diff = RECORDBUFFER * SAMPLESIZE - cap_pos + cur_pos;
if (diff > RECORDBUFFER * SAMPLESIZE - 4 * SAMPLEBUFFER * SAMPLESIZE) {
write_log (L"!");
diff -= RECORDBUFFER * SAMPLESIZE;
} else if (diff > RECORDBUFFER * SAMPLESIZE / 2) {
cap_pos = cur_pos;
write_log (L"*");
diff = 0;
}
cap_pos += diff;
if (cap_pos >= RECORDBUFFER)
cap_pos -= RECORDBUFFER;
if (cap_pos < 0)
cap_pos = 0;
offset = 0;
if (oldoffset < 0)
oldoffset = 0;
cap_pos += RECORDBUFFER * SAMPLESIZE;
if (cap_pos >= RECORDBUFFER * SAMPLESIZE)
cap_pos -= RECORDBUFFER * SAMPLESIZE;
if (offset < 0)
offset = 0;
if (offset >= SAMPLEBUFFER)
offset -= SAMPLEBUFFER;
oldoffset = 0;
oldcycles = get_cycles ();
}
while (oldoffset <= offset) {
sample += ((uae_s16*)samplebuffer)[oldoffset * 2 + channel];
oldoffset++;
sample += sbuf[oldoffset * SAMPLESIZE / 2 + channel];
samplecnt++;
oldoffset++;
}
oldoffset = offset;
if (samplecnt > 0)
sample /= samplecnt;
return sample >> 8;
return (sample / 256) - 128;
}
int sampler_init (void)