From e6cbee5ad19597226fd0523488b156509c9d348e Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 1 May 2009 12:11:44 +0300 Subject: [PATCH] imported winuaesrc1600b27.zip --- archivers/lha/lha_macro.h | 2 +- cfgfile.c | 9 +- custom.c | 17 +- drawing.c | 8 +- gencpu.c | 6 +- include/gfxfilter.h | 36 +- include/options.h | 1 + include/parallel.h | 3 +- od-win32/ahidsound_dsonly.c | 872 ++++++++++++++++++ od-win32/{ahidsound.c => ahidsound_unified.c} | 0 od-win32/build68k_msvc/build68k_msvc.vcproj | 4 +- od-win32/direct3d.c | 46 +- od-win32/direct3d.h | 1 + od-win32/dxwrap.h | 3 +- .../genblitter_msvc/genblitter_msvc.vcproj | 4 +- od-win32/gencomp_msvc/gencomp_msvc.vcproj | 7 +- od-win32/gencpu_msvc/gencpu_msvc.vcproj | 10 +- od-win32/hq2x_d3d.c | 1 + od-win32/keyboard_win32.c | 4 +- od-win32/lcd.c | 28 +- od-win32/parser.c | 74 +- od-win32/picasso96_win.c | 6 +- od-win32/resources/resource | 5 + od-win32/resources/winuae.rc | 13 +- od-win32/screenshot.c | 2 +- od-win32/sounddep/sound.c | 11 +- od-win32/sys/mman.h | 3 - od-win32/sysconfig.h | 1 - od-win32/win32.c | 2 +- od-win32/win32.h | 4 +- od-win32/win32_scale2x.c | 41 +- od-win32/win32gfx.c | 122 ++- od-win32/win32gui.c | 76 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 607 ++++++------ od-win32/winuaechangelog.txt | 30 + prowizard/rippers/TitanicsPlayer.c | 2 +- 36 files changed, 1570 insertions(+), 491 deletions(-) create mode 100644 od-win32/ahidsound_dsonly.c rename od-win32/{ahidsound.c => ahidsound_unified.c} (100%) diff --git a/archivers/lha/lha_macro.h b/archivers/lha/lha_macro.h index a227a810..e5021aae 100644 --- a/archivers/lha/lha_macro.h +++ b/archivers/lha/lha_macro.h @@ -8,7 +8,7 @@ /* ------------------------------------------------------------------------ */ /* external variables */ -extern int errno; +//extern int errno; /* used by qsort() for alphabetic-sort */ #define STRING_COMPARE(a,b) strcmp((a),(b)) diff --git a/cfgfile.c b/cfgfile.c index b5803eee..6eb9eebe 100644 --- a/cfgfile.c +++ b/cfgfile.c @@ -594,6 +594,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, L"synchronize_clock", p->tod_hack); cfgfile_write (f, L"maprom", L"0x%x", p->maprom); + cfgfile_write_bool (f, L"parallel_matrix_emulation", p->parallel_ascii_emulation); cfgfile_write_bool (f, L"parallel_postscript_emulation", p->parallel_postscript_emulation); cfgfile_write_bool (f, L"parallel_postscript_detection", p->parallel_postscript_detection); cfgfile_write_str (f, L"ghostscript_parameters", p->ghostscript_parameters); @@ -1077,11 +1078,13 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) if (cfgfile_yesno (option, value, L"show_leds", &v)) { - p->leds_on_screen |= STATUSLINE_CHIPSET; + if (v) + p->leds_on_screen |= STATUSLINE_CHIPSET; return 1; } if (cfgfile_yesno (option, value, L"show_leds_rtg", &v)) { - p->leds_on_screen |= STATUSLINE_RTG; + if (v) + p->leds_on_screen |= STATUSLINE_RTG; return 1; } @@ -1522,6 +1525,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va || cfgfile_yesno (option, value, L"cpu_compatible", &p->cpu_compatible) || cfgfile_yesno (option, value, L"cpu_24bit_addressing", &p->address_space_24) || cfgfile_yesno (option, value, L"parallel_on_demand", &p->parallel_demand) + || cfgfile_yesno (option, value, L"parallel_matrix_emulation", &p->parallel_ascii_emulation) || cfgfile_yesno (option, value, L"parallel_postscript_emulation", &p->parallel_postscript_emulation) || cfgfile_yesno (option, value, L"parallel_postscript_detection", &p->parallel_postscript_detection) || cfgfile_yesno (option, value, L"serial_on_demand", &p->serial_demand) @@ -3083,6 +3087,7 @@ void default_prefs (struct uae_prefs *p, int type) p->serial_demand = 0; p->serial_hwctsrts = 1; p->parallel_demand = 0; + p->parallel_ascii_emulation = 0; p->parallel_postscript_emulation = 0; p->parallel_postscript_detection = 0; p->parallel_autoflush_time = 5; diff --git a/custom.c b/custom.c index 0bb7c542..187d03b5 100644 --- a/custom.c +++ b/custom.c @@ -63,6 +63,7 @@ #define MAX_SPRITES 8 #define SPRITE_COLLISIONS #define SPEEDUP +#define AUTOSCALE_SPRITES 1 #define NEW_BPL 1 @@ -2300,22 +2301,25 @@ static void decide_sprites (int hpos) int nr = nrs[i] & (MAX_SPRITES - 1); record_sprite (next_lineno, nr, posns[i], sprdata[nr], sprdatb[nr], sprctl[nr]); /* get left and right sprite edge if brdsprt enabled */ - if (bplcon3 & 2) { - int j; - for (j = 0; j < sprite_width; j+= 16) { +#if AUTOSCALE_SPRITES + if ((bplcon0 & 1) && (bplcon3 & 0x02) && !(bplcon3 & 0x20)) { + int j, jj; + for (j = 0, jj = 0; j < sprite_width; j+= 16, jj++) { int nx = fromspritexdiw (posns[i] + j); - if (sprdata[nr][j] || sprdata[nr][j]) { - if (diwfirstword_total > nx) + if (sprdata[nr][jj] || sprdatb[nr][jj]) { + if (diwfirstword_total > nx && nx >= (48 << currprefs.gfx_resolution)) diwfirstword_total = nx; - if (diwlastword_total < nx + 16) + if (diwlastword_total < nx + 16 && nx <= (448 << currprefs.gfx_resolution)) diwlastword_total = nx + 16; } } gotdata = 1; } +#endif } last_sprite_point = point; +#if AUTOSCALE_SPRITES /* get upper and lower sprite position if brdsprt enabled */ if (gotdata) { if (vpos < first_planes_vpos) @@ -2327,6 +2331,7 @@ static void decide_sprites (int hpos) if (vpos > plflastline_total) plflastline_total = vpos; } +#endif } STATIC_INLINE int sprites_differ (struct draw_info *dip, struct draw_info *dip_old) diff --git a/drawing.c b/drawing.c index 3367446c..84358ff4 100644 --- a/drawing.c +++ b/drawing.c @@ -403,12 +403,8 @@ int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy) w = MIN_DISPLAY_W << currprefs.gfx_resolution; } if ((h >> dbl1) < MIN_DISPLAY_H) { - if (gcloh > MIN_DISPLAY_H) { - h = gcloh; - } else { - dy += (h - (MIN_DISPLAY_H << dbl1)) / 2; - h = MIN_DISPLAY_H << dbl1; - } + dy += (h - (MIN_DISPLAY_H << dbl1)) / 2; + h = MIN_DISPLAY_H << dbl1; } if ((w >> currprefs.gfx_resolution) > MAX_DISPLAY_W) { dx += (w - (MAX_DISPLAY_W << currprefs.gfx_resolution)) / 2; diff --git a/gencpu.c b/gencpu.c index 7ed2e889..d7d3be91 100644 --- a/gencpu.c +++ b/gencpu.c @@ -3103,7 +3103,11 @@ static char *outopcode (int opcode) if (ins->mnemo == lookuptab[i].mnemo) break; } - strcpy (out, lookuptab[i].name); + { + char *s = ua (lookuptab[i].name); + strcpy (out, s); + xfree (s); + } if (ins->size == sz_byte) strcat (out,".B"); if (ins->size == sz_word) diff --git a/include/gfxfilter.h b/include/gfxfilter.h index b2a541bd..a5da1614 100644 --- a/include/gfxfilter.h +++ b/include/gfxfilter.h @@ -11,8 +11,8 @@ extern void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd); extern void S2X_free (void); extern void PAL_init (void); -extern void PAL_1x1_32(uae_u32 *src, int pitchs, uae_u32 *trg, int pitcht, int width, int height); -extern void PAL_1x1_16(uae_u16 *src, int pitchs, uae_u16 *trg, int pitcht, int width, int height); +extern void PAL_1x1_32 (uae_u32 *src, int pitchs, uae_u32 *trg, int pitcht, int width, int height); +extern void PAL_1x1_16 (uae_u16 *src, int pitchs, uae_u16 *trg, int pitcht, int width, int height); typedef unsigned char uint8; typedef unsigned short uint16; @@ -22,25 +22,25 @@ typedef int bool; #endif extern void S2X_configure (int rb, int gb, int bb, int rs, int gs, int bs); -extern int Init_2xSaI(int rb, int gb, int bb, int rs, int gs, int bs); -extern void Super2xSaI_16(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void Super2xSaI_32(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void SuperEagle_16(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void SuperEagle_32(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void _2xSaI_16(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void _2xSaI_32(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -extern void AdMame2x(u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ +extern int Init_2xSaI (int rb, int gb, int bb, int rs, int gs, int bs); +extern void Super2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void Super2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void SuperEagle_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void SuperEagle_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void _2xSaI_16 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void _2xSaI_32 (const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +extern void AdMame2x (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ u8 *dstPtr, u32 dstPitch, int width, int height); -extern void AdMame2x32(u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ +extern void AdMame2x32 (u8 *srcPtr, u32 srcPitch, /* u8 deltaPtr, */ u8 *dstPtr, u32 dstPitch, int width, int height); -extern void hq_init(int rb, int gb, int bb, int rs, int gs, int bs); -extern void hq2x_16(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void hq2x_32(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void hq3x_16(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void hq3x_32(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void hq4x_16(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); -extern void hq4x_32(unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void hq_init (int rb, int gb, int bb, int rs, int gs, int bs); +extern void _cdecl hq2x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void _cdecl hq2x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void _cdecl hq3x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void _cdecl hq3x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void _cdecl hq4x_16 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); +extern void _cdecl hq4x_32 (unsigned char*, unsigned char*, DWORD, DWORD, DWORD); #define UAE_FILTER_NULL 1 #define UAE_FILTER_DIRECT3D 2 diff --git a/include/options.h b/include/options.h index 16ac813a..2c396c4e 100644 --- a/include/options.h +++ b/include/options.h @@ -107,6 +107,7 @@ struct uae_prefs { int serial_hwctsrts; int serial_direct; int parallel_demand; + int parallel_ascii_emulation; int parallel_postscript_emulation; int parallel_postscript_detection; int parallel_autoflush_time; diff --git a/include/parallel.h b/include/parallel.h index c53fde22..70d30197 100644 --- a/include/parallel.h +++ b/include/parallel.h @@ -1,8 +1,7 @@ extern int isprinter (void); -extern int doprinter (uae_u8); +extern void doprinter (uae_u8); extern void flushprinter (void); extern void closeprinter (void); -extern void openprinter (void); extern int isprinteropen (void); extern void initparallel (void); \ No newline at end of file diff --git a/od-win32/ahidsound_dsonly.c b/od-win32/ahidsound_dsonly.c new file mode 100644 index 00000000..45881e13 --- /dev/null +++ b/od-win32/ahidsound_dsonly.c @@ -0,0 +1,872 @@ +/* + * UAE - The Un*x Amiga Emulator + * + * Win32 interface + * + * Copyright 1997 Mathias Ortmann + * Copyright 1997-2001 Brian King + * Copyright 2000-2002 Bernd Roesch + */ + +#define NATIVBUFFNUM 4 +#define RECORDBUFFER 50 //survive 9 sec of blocking at 44100 + +#include "sysconfig.h" + +#if defined(AHI) + +#include +#include + +#include +#include +#include +#include +#include + +#include "sysdeps.h" +#include "options.h" +#include "audio.h" +#include "memory.h" +#include "events.h" +#include "custom.h" +#include "newcpu.h" +#include "traps.h" +#include "od-win32/win32.h" +#include "sounddep/sound.h" +#include "dxwrap.h" +#include "win32.h" +#include "parser.h" +#include "enforcer.h" +#include "ahidsound.h" + +static long samples, playchannel, intcount; +static int record_enabled; +int ahi_on; +static uae_u8 *sndptrmax; +static uae_u8 soundneutral; + +static LPSTR lpData,sndptrout; +extern uae_u32 chipmem_mask; +unsigned int *sndbufrecpt; +static uae_u8 *ahisndbuffer, *sndrecbuffer; +static int ahisndbufsize, *ahisndbufpt, ahitweak;; +int ahi_pollrate = 40; + +int sound_freq_ahi, sound_channels_ahi, sound_bits_ahi; + +static int vin, devicenum; +static int amigablksize; + +static DWORD sound_flushes2 = 0; + +extern HWND hAmigaWnd; + +static LPDIRECTSOUND lpDS2 = NULL; +static LPDIRECTSOUNDBUFFER lpDSBprimary2 = NULL; +static LPDIRECTSOUNDBUFFER lpDSB2 = NULL; +static LPDIRECTSOUNDNOTIFY lpDSBN2 = NULL; + +// for record +static LPDIRECTSOUNDCAPTURE lpDS2r = NULL; +static LPDIRECTSOUNDCAPTUREBUFFER lpDSBprimary2r = NULL; +static LPDIRECTSOUNDCAPTUREBUFFER lpDSB2r = NULL; + +struct winuae //this struct is put in a6 if you call + //execute native function +{ + HWND amigawnd; //adress of amiga Window Windows Handle + unsigned int changenum; //number to detect screen close/open + unsigned int z3offset; //the offset to add to acsess Z3 mem from Dll side +}; +static struct winuae uaevar; +static struct winuae *a6; + +#if defined(X86_MSVC_ASSEMBLY) + +#define CREATE_NATIVE_FUNC_PTR2 uae_u32 (*native_func)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,\ + uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,uae_u32,uae_u32) +#define SET_NATIVE_FUNC2(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,uae_u32,uae_u32))(x) +#define CALL_NATIVE_FUNC2(d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7) if(native_func) return native_func(d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7,regs_) + +static uae_u32 REGPARAM2 emulib_ExecuteNativeCode2 (TrapContext *context) +{ + unsigned int espstore; + uae_u8* object_UAM = (uae_u8*) m68k_areg (&context->regs, 0); + uae_u32 d1 = m68k_dreg (&context->regs, 1); + uae_u32 d2 = m68k_dreg (&context->regs, 2); + uae_u32 d3 = m68k_dreg (&context->regs, 3); + uae_u32 d4 = m68k_dreg (&context->regs, 4); + uae_u32 d5 = m68k_dreg (&context->regs, 5); + uae_u32 d6 = m68k_dreg (&context->regs, 6); + uae_u32 d7 = m68k_dreg (&context->regs, 7); + uae_u32 a1 = m68k_areg (&context->regs, 1); + uae_u32 a2 = m68k_areg (&context->regs, 2); + uae_u32 a3 = m68k_areg (&context->regs, 3); + uae_u32 a4 = m68k_areg (&context->regs, 4); + uae_u32 a5 = m68k_areg (&context->regs, 5); + uae_u32 a7 = m68k_areg (&context->regs, 7); + uae_u32 regs_ = (uae_u32)&context->regs; + CREATE_NATIVE_FUNC_PTR2; + uaevar.z3offset = (uae_u32)(get_real_address (0x10000000) - 0x10000000); + uaevar.amigawnd = hAmigaWnd; + a6 = &uaevar; + if (object_UAM) { + SET_NATIVE_FUNC2 (object_UAM); + __asm + { mov espstore,esp + push regs_ + push a7 + push a6 + push a5 + push a4 + push a3 + push a2 + push a1 + push d7 + push d6 + push d5 + push d4 + push d3 + push d2 + push d1 + call native_func + mov esp,espstore + } + //CALL_NATIVE_FUNC2( d1, d2,d3, d4, d5, d6, d7, a1, a2, a3, a4 , a5 , a6 , a7); + } else { + return 0; + } +} + +#endif + +void ahi_close_sound (void) +{ + HRESULT hr = DS_OK; + + if (!ahi_on) + return; + ahi_on = 0; + record_enabled = 0; + ahisndbufpt = (int*)ahisndbuffer; + + if (lpDSB2) { + hr = IDirectSoundBuffer_Stop (lpDSB2); + if(FAILED (hr)) + write_log (L"AHI: SoundStop() failure: %s\n", DXError (hr)); + } else { + write_log (L"AHI: Sound Stopped...\n"); + } + + if (lpDSB2) + IDirectSoundBuffer_Release (lpDSB2); + lpDSB2 = NULL; + if (lpDSBprimary2) + IDirectSoundBuffer_Release (lpDSBprimary2); + lpDSBprimary2 = NULL; + if (lpDS2) + IDirectSound_Release (lpDS2); + lpDS2 = NULL; + + if (lpDSB2r) + IDirectSoundCaptureBuffer_Release (lpDSB2r); + lpDSB2r = NULL; + if (lpDS2r) + IDirectSound_Release (lpDS2r); + lpDS2r = NULL; + if (ahisndbuffer) + free (ahisndbuffer); + ahisndbuffer = NULL; +} + +void ahi_updatesound(int force) +{ + HRESULT hr; + int pos; + unsigned int dwBytes1, dwBytes2; + LPVOID dwData1, dwData2; + static int oldpos; + + if (sound_flushes2 == 1) { + oldpos = 0; + intcount = 1; + INTREQ_f (0x8000 | 0x2000); + hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING); + if(hr == DSERR_BUFFERLOST) { + IDirectSoundBuffer_Restore (lpDSB2); + hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING); + } + } + + hr = IDirectSoundBuffer_GetCurrentPosition (lpDSB2, &pos, 0); + if (hr != DSERR_BUFFERLOST) { + pos -= ahitweak; + if (pos < 0) + pos += ahisndbufsize; + if (pos >= ahisndbufsize) + pos -= ahisndbufsize; + pos = (pos / (amigablksize * 4)) * (amigablksize * 4); + if (force == 1) { + if (oldpos != pos) { + intcount = 1; + INTREQ_f (0x8000 | 0x2000); + return; //to generate amiga ints every amigablksize + } else { + return; + } + } + } + + hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); + if(hr == DSERR_BUFFERLOST) { + write_log (L"AHI: lostbuf %d %x\n", pos, amigablksize); + IDirectSoundBuffer_Restore (lpDSB2); + hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0); + } + if(FAILED(hr)) + return; + + if (currprefs.sound_stereo_swap_ahi) { + int i; + uae_s16 *p = (uae_s16*)ahisndbuffer; + for (i = 0; i < (dwBytes1 + dwBytes2) / 2; i += 2) { + uae_s16 tmp; + tmp = p[i + 0]; + p[i + 0] = p[i + 1]; + p[i + 1] = tmp; + } + } + + memcpy (dwData1, ahisndbuffer, dwBytes1); + if (dwData2) + memcpy (dwData2, (uae_u8*)ahisndbuffer + dwBytes1, dwBytes2); + + sndptrmax = ahisndbuffer + ahisndbufsize; + ahisndbufpt = (int*)ahisndbuffer; + + IDirectSoundBuffer_Unlock (lpDSB2, dwData1, dwBytes1, dwData2, dwBytes2); + + oldpos += amigablksize * 4; + if (oldpos >= ahisndbufsize) + oldpos -= ahisndbufsize; + if (oldpos != pos) { + intcount = 1; + INTREQ_f (0x8000 | 0x2000); + } +} + + +void ahi_finish_sound_buffer (void) +{ + sound_flushes2++; + ahi_updatesound(2); +} + +static WAVEFORMATEX wavfmt; + +static int ahi_init_record_win32 (void) +{ + HRESULT hr; + DSCBUFFERDESC sound_buffer_rec; + // Record begin + hr = DirectSoundCaptureCreate (NULL, &lpDS2r, NULL); + if (FAILED (hr)) { + write_log (L"AHI: DirectSoundCaptureCreate() failure: %s\n", DXError (hr)); + record_enabled = -1; + return 0; + } + memset (&sound_buffer_rec, 0, sizeof (DSCBUFFERDESC)); + sound_buffer_rec.dwSize = sizeof (DSCBUFFERDESC); + sound_buffer_rec.dwBufferBytes = amigablksize * 4 * RECORDBUFFER; + sound_buffer_rec.lpwfxFormat = &wavfmt; + sound_buffer_rec.dwFlags = 0 ; + + hr = IDirectSoundCapture_CreateCaptureBuffer (lpDS2r, &sound_buffer_rec, &lpDSB2r, NULL); + if (FAILED (hr)) { + write_log (L"AHI: CreateCaptureSoundBuffer() failure: %s\n", DXError(hr)); + record_enabled = -1; + return 0; + } + + hr = IDirectSoundCaptureBuffer_Start (lpDSB2r, DSCBSTART_LOOPING); + if (FAILED (hr)) { + write_log (L"AHI: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr)); + record_enabled = -1; + return 0; + } + record_enabled = 1; + write_log (L"AHI: Init AHI Audio Recording \n"); + return 1; +} + +void setvolume_ahi (LONG vol) +{ + HRESULT hr; + if (!lpDS2) + return; + hr = IDirectSoundBuffer_SetVolume (lpDSB2, vol); + if (FAILED (hr)) + write_log (L"AHI: SetVolume(%d) failed: %s\n", vol, DXError (hr)); +} + +static int ahi_init_sound_win32 (void) +{ + HRESULT hr; + DSBUFFERDESC sound_buffer; + DSCAPS DSCaps; + + if (lpDS2) + return 0; + + enumerate_sound_devices (); + wavfmt.wFormatTag = WAVE_FORMAT_PCM; + wavfmt.nChannels = sound_channels_ahi; + wavfmt.nSamplesPerSec = sound_freq_ahi; + wavfmt.wBitsPerSample = sound_bits_ahi; + wavfmt.nBlockAlign = wavfmt.wBitsPerSample / 8 * wavfmt.nChannels; + wavfmt.nAvgBytesPerSec = wavfmt.nBlockAlign * sound_freq_ahi; + wavfmt.cbSize = 0; + + write_log (L"AHI: Init AHI Sound Rate %d, Channels %d, Bits %d, Buffsize %d\n", + sound_freq_ahi, sound_channels_ahi, sound_bits_ahi, amigablksize); + + if (!amigablksize) + return 0; + soundneutral = 0; + ahisndbufsize = (amigablksize * 4) * NATIVBUFFNUM; // use 4 native buffer + ahisndbuffer = malloc (ahisndbufsize + 32); + if (!ahisndbuffer) + return 0; + if (sound_devices[currprefs.win32_soundcard].type != SOUND_DEVICE_DS) + hr = DirectSoundCreate (NULL, &lpDS2, NULL); + else + hr = DirectSoundCreate (&sound_devices[currprefs.win32_soundcard].guid, &lpDS2, NULL); + if (FAILED (hr)) { + write_log (L"AHI: DirectSoundCreate() failure: %s\n", DXError (hr)); + return 0; + } + memset (&sound_buffer, 0, sizeof (DSBUFFERDESC)); + sound_buffer.dwSize = sizeof (DSBUFFERDESC); + sound_buffer.dwFlags = DSBCAPS_PRIMARYBUFFER; + sound_buffer.dwBufferBytes = 0; + sound_buffer.lpwfxFormat = NULL; + + DSCaps.dwSize = sizeof(DSCAPS); + hr = IDirectSound_GetCaps (lpDS2, &DSCaps); + if (SUCCEEDED (hr)) { + if (DSCaps.dwFlags & DSCAPS_EMULDRIVER) + write_log (L"AHI: Your DirectSound Driver is emulated via WaveOut - yuck!\n"); + } + if (FAILED (IDirectSound_SetCooperativeLevel (lpDS2, hMainWnd, DSSCL_PRIORITY))) + return 0; + hr = IDirectSound_CreateSoundBuffer (lpDS2, &sound_buffer, &lpDSBprimary2, NULL); + if (FAILED (hr)) { + write_log (L"AHI: CreateSoundBuffer() failure: %s\n", DXError(hr)); + return 0; + } + hr = IDirectSoundBuffer_SetFormat (lpDSBprimary2, &wavfmt); + if (FAILED (hr)) { + write_log (L"AHI: SetFormat() failure: %s\n", DXError (hr)); + return 0; + } + sound_buffer.dwBufferBytes = ahisndbufsize; + sound_buffer.lpwfxFormat = &wavfmt; + sound_buffer.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME + | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCSOFTWARE; + sound_buffer.guid3DAlgorithm = GUID_NULL; + hr = IDirectSound_CreateSoundBuffer (lpDS2, &sound_buffer, &lpDSB2, NULL); + if (FAILED (hr)) { + write_log (L"AHI: CreateSoundBuffer() failure: %s\n", DXError (hr)); + return 0; + } + + setvolume_ahi (0); + + hr = IDirectSoundBuffer_GetFormat (lpDSBprimary2,&wavfmt,500,0); + if (FAILED (hr)) { + write_log (L"AHI: GetFormat() failure: %s\n", DXError (hr)); + return 0; + } + + ahisndbufpt =(int*)ahisndbuffer; + sndptrmax = ahisndbuffer + ahisndbufsize; + memset (ahisndbuffer, soundneutral, amigablksize * 8); + ahi_on = 1; + return sound_freq_ahi; +} + +int ahi_open_sound (void) +{ + int rate; + + uaevar.changenum++; + if (!sound_freq_ahi) + return 0; + if (ahi_on) + ahi_close_sound (); + sound_flushes2 = 1; + if ((rate = ahi_init_sound_win32 ())) + return rate; + return 0; +} + + +static void *bswap_buffer = NULL; +static uae_u32 bswap_buffer_size = 0; +static double syncdivisor; + +uae_u32 REGPARAM2 ahi_demux (TrapContext *context) +{ +//use the extern int (6 #13) +// d0 0=opensound d1=unit d2=samplerate d3=blksize ret: sound frequency +// d0 6=opensound_new d1=unit d2=samplerate d3=blksize ret d4=channels d5=bits d6=zero: sound frequency +// d0 1=closesound d1=unit +// d0 2=writesamples d1=unit a0=addr write blksize samples to card +// d0 3=readsamples d1=unit a0=addr read samples from card ret: d0=samples read + // make sure you have from amigaside blksize*4 mem alloced + // d0=-1 no data available d0=-2 no recording open + // d0 > 0 there are more blksize Data in the que + // do the loop until d0 get 0 + // if d0 is greater than 200 bring a message + // that show the user that data is lost + // maximum blocksbuffered are 250 (8,5 sec) +// d0 4=writeinterrupt d1=unit d0=0 no interrupt happen for this unit + // d0=-2 no playing open + //note units for now not support use only unit 0 +// d0 5=? + // d0=10 get clipboard size d0=size in bytes +// d0=11 get clipboard data a0=clipboarddata + //Note: a get clipboard size must do before +// d0=12 write clipboard data a0=clipboarddata +// d0=13 setp96mouserate d1=hz value +// d0=100 open dll d1=dll name in windows name conventions +// d0=101 get dll function addr d1=dllhandle a0 function/var name +// d0=102 exec dllcode a0=addr of function (see 101) +// d0=103 close dll +// d0=104 screenlost +// d0=105 mem offset +// d0=106 16Bit byteswap +// d0=107 32Bit byteswap +// d0=108 free swap array +// d0=200 ahitweak d1=offset for dsound position pointer + + int opcode = m68k_dreg (&context->regs, 0); + + switch (opcode) + { + uae_u32 src, num_vars; + static int cap_pos, clipsize; + static TCHAR *clipdat; + + case 0: + cap_pos = 0; + sound_bits_ahi = 16; + sound_channels_ahi = 2; + sound_freq_ahi = m68k_dreg (&context->regs, 2); + amigablksize = m68k_dreg (&context->regs, 3); + sound_freq_ahi = ahi_open_sound(); + uaevar.changenum--; + return sound_freq_ahi; + case 6: /* new open function */ + cap_pos = 0; + sound_freq_ahi = m68k_dreg (&context->regs, 2); + amigablksize = m68k_dreg (&context->regs, 3); + sound_channels_ahi = m68k_dreg (&context->regs, 4); + sound_bits_ahi = m68k_dreg (&context->regs, 5); + sound_freq_ahi = ahi_open_sound(); + uaevar.changenum--; + return sound_freq_ahi; + + case 1: + ahi_close_sound(); + sound_freq_ahi = 0; + return 0; + + case 2: + { + int i; + uaecptr addr = m68k_areg (&context->regs, 0); + for (i = 0; i < amigablksize * 4; i += 4) + *ahisndbufpt++ = get_long (addr + i); + ahi_finish_sound_buffer(); + } + return amigablksize; + + case 3: + { + LPTSTR pos1,pos2; + uaecptr addr; + HRESULT hr; + int i, t, todo, byte1, byte2, cur_pos; + + if (!ahi_on) + return -2; + if (record_enabled == 0) + ahi_init_record_win32(); + if (record_enabled < 0) + return -2; + hr = IDirectSoundCaptureBuffer_GetCurrentPosition(lpDSB2r, &t, &cur_pos); + if (FAILED(hr)) + return -1; + + t = amigablksize * 4; + if (cap_pos <= cur_pos) + todo = cur_pos - cap_pos; + else + todo = cur_pos + (RECORDBUFFER * t) - cap_pos; + if (todo < t) //if no complete buffer ready exit + return -1; + hr = IDirectSoundCaptureBuffer_Lock(lpDSB2r, cap_pos, t, &pos1, &byte1, &pos2, &byte2, 0); + if (FAILED(hr)) + return -1; + if ((cap_pos + t) < (t * RECORDBUFFER)) + cap_pos = cap_pos + t; + else + cap_pos = 0; + addr = m68k_areg (&context->regs, 0); + sndbufrecpt = (unsigned int*)pos1; + t /= 4; + for (i = 0; i < t; i++) { + put_long (addr, *sndbufrecpt++); + addr += 4; + } + t *= 4; + IDirectSoundCaptureBuffer_Unlock(lpDSB2r, pos1, byte1, pos2, byte2); + return (todo - t) / t; + } + + case 4: + { + int i; + if (!ahi_on) + return -2; + i = intcount; + intcount = 0; + return i; + } + + case 5: + if (!ahi_on) + return 0; + ahi_updatesound ( 1 ); + return 1; + + case 10: +#if 1 + if (OpenClipboard (0)) { + clipdat = GetClipboardData (CF_TEXT); + if (clipdat) { + clipsize = _tcslen (clipdat); + clipsize++; + return clipsize; + } + } +#endif + return 0; + + case 11: + { +#if 1 + int i; + for (i = 0; i < clipsize; i++) + put_byte (m68k_areg (&context->regs, 0) + i, clipdat[i]); + CloseClipboard (); +#endif + } + return 0; + + case 12: + { +#if 1 + TCHAR *s = au (get_real_address (m68k_areg (®s, 0))); + static LPTSTR p; + int slen; + + if (OpenClipboard (0)) { + EmptyClipboard(); + slen = _tcslen (s); + if (p) + GlobalFree (p); + p = GlobalAlloc (GMEM_MOVEABLE, (slen + 1) * sizeof (TCHAR)); + if (p) { + TCHAR *p2 = GlobalLock (p); + if (p2) { + _tcscpy (p2, s); + GlobalUnlock (p); + SetClipboardData (CF_TEXT, p); + } + } + CloseClipboard (); + } + xfree (s); +#endif + } + return 0; + + case 13: /* HACK */ + { //for higher P96 mouse draw rate + extern int p96hack_vpos2, hack_vpos ,p96refresh_active; + extern uae_u16 vtotal; + extern unsigned int new_beamcon0; + p96hack_vpos2 = 0; + if (m68k_dreg (&context->regs, 1) > 0) + p96hack_vpos2 = 15625 / m68k_dreg (&context->regs, 1); + if (!currprefs.cs_ciaatod) + changed_prefs.cs_ciaatod = currprefs.cs_ciaatod = currprefs.ntscmode ? 2 : 1; + p96refresh_active=1; + picasso_refresh (); + } //end for higher P96 mouse draw rate + return 0; + + case 20: + return enforcer_enable(m68k_dreg (&context->regs, 1)); + + case 21: + return enforcer_disable(); + + case 25: + flushprinter (); + return 0; + +#if defined(X86_MSVC_ASSEMBLY) + + case 100: // open dll + { + TCHAR *dlldir = TEXT ("winuae_dll"); + TCHAR *dllname; + uaecptr dllptr; + HMODULE h = NULL; + TCHAR dpath[MAX_DPATH]; + TCHAR newdllpath[MAX_DPATH]; + int ok = 0; + TCHAR *filepart; + + dllptr = m68k_areg (&context->regs, 0); + dllname = au ((uae_char*)get_real_address (dllptr)); + dpath[0] = 0; + GetFullPathName (dllname, sizeof dpath / sizeof (TCHAR), dpath, &filepart); + if (_tcslen (dpath) > _tcslen (start_path_data) && !_tcsncmp (dpath, start_path_data, _tcslen (start_path_data))) { + /* path really is relative to winuae directory */ + ok = 1; + _tcscpy (newdllpath, dpath + _tcslen (start_path_data)); + if (!_tcsncmp (newdllpath, dlldir, _tcslen (dlldir))) /* remove "winuae_dll" */ + _tcscpy (newdllpath, dpath + _tcslen (start_path_data) + 1 + _tcslen (dlldir)); + _stprintf (dpath, L"%s%s%s", start_path_data, WIN32_PLUGINDIR, newdllpath); + h = LoadLibrary (dpath); + if (h == NULL) + write_log (L"native open: '%s' = %d\n", dpath, GetLastError ()); + if (h == NULL) { + _stprintf (dpath, L"%s%s\\%s", start_path_data, dlldir, newdllpath); + h = LoadLibrary (dllname); + if (h == NULL) + write_log (L"fallback native open: '%s' = %d\n", dpath, GetLastError ()); + } + } else { + write_log (L"native open outside of installation dir '%s'!\n", dpath); + } + xfree (dllname); +#if 0 + if (h == NULL) { + h = LoadLibrary (filepart); + write_log (L"native file open: '%s' = %p\n", filepart, h); + if (h == NULL) { + _stprintf (dpath, "%s%s%s", start_path_data, WIN32_PLUGINDIR, filepart); + h = LoadLibrary (dpath); + write_log (L"native path open: '%s' = %p\n", dpath, h); + } + } +#endif + syncdivisor = (3580000.0 * CYCLE_UNIT) / (double)syncbase; + return (uae_u32)h; + } + + case 101: //get dll label + { + HMODULE m; + uaecptr funcaddr; + char *funcname; + m = (HMODULE) m68k_dreg (&context->regs, 1); + funcaddr = m68k_areg (&context->regs, 0); + funcname = get_real_address (funcaddr); + return (uae_u32) GetProcAddress (m, funcname); + } + + case 102: //execute native code + { + uae_u32 ret; + unsigned long rate1; + double v; + rate1 = read_processor_time (); + ret = emulib_ExecuteNativeCode2 (context); + rate1 = read_processor_time () - rate1; + v = syncdivisor * rate1; + if (v > 0) { + if (v > 1000000 * CYCLE_UNIT) + v = 1000000 * CYCLE_UNIT; + do_extra_cycles ((unsigned long)(syncdivisor * rate1)); //compensate the time stay in native func + } + return ret; + } + + case 103: //close dll + { + HMODULE libaddr; + libaddr = (HMODULE) m68k_dreg (&context->regs, 1); + FreeLibrary (libaddr); + return 0; + } +#endif + + case 104: //screenlost + { + static int oldnum = 0; + if (uaevar.changenum == oldnum) + return 0; + oldnum = uaevar.changenum; + return 1; + } + +#if defined(X86_MSVC_ASSEMBLY) + + case 105: //returns memory offset + return (uae_u32) get_real_address (0); + + case 106: //byteswap 16bit vars + //a0 = start address + //d1 = number of 16bit vars + //returns address of new array + src = m68k_areg (&context->regs, 0); + num_vars = m68k_dreg (&context->regs, 1); + + if (bswap_buffer_size < num_vars * 2) { + bswap_buffer_size = (num_vars + 1024) * 2; + free(bswap_buffer); + bswap_buffer = (void*)malloc(bswap_buffer_size); + } + __asm { + mov esi, dword ptr [src] + mov edi, dword ptr [bswap_buffer] + mov ecx, num_vars + + mov ebx, ecx + and ecx, 3 + je BSWAP_WORD_4X + + BSWAP_WORD_LOOP: + mov ax, [esi] + mov dl, al + mov al, ah + mov ah, dl + mov [edi], ax + add esi, 2 + add edi, 2 + loopne BSWAP_WORD_LOOP + + BSWAP_WORD_4X: + mov ecx, ebx + shr ecx, 2 + je BSWAP_WORD_END + BSWAP_WORD_4X_LOOP: + mov ax, [esi] + mov dl, al + mov al, ah + mov ah, dl + mov [edi], ax + mov ax, [esi+2] + mov dl, al + mov al, ah + mov ah, dl + mov [edi+2], ax + mov ax, [esi+4] + mov dl, al + mov al, ah + mov ah, dl + mov [edi+4], ax + mov ax, [esi+6] + mov dl, al + mov al, ah + mov ah, dl + mov [edi+6], ax + add esi, 8 + add edi, 8 + loopne BSWAP_WORD_4X_LOOP + BSWAP_WORD_END: + } + return (uae_u32) bswap_buffer; + + case 107: //byteswap 32bit vars - see case 106 + //a0 = start address + //d1 = number of 32bit vars + //returns address of new array + src = m68k_areg (&context->regs, 0); + num_vars = m68k_dreg (&context->regs, 1); + if (bswap_buffer_size < num_vars * 4) { + bswap_buffer_size = (num_vars + 16384) * 4; + free(bswap_buffer); + bswap_buffer = (void*)malloc(bswap_buffer_size); + } + __asm { + mov esi, dword ptr [src] + mov edi, dword ptr [bswap_buffer] + mov ecx, num_vars + + mov ebx, ecx + and ecx, 3 + je BSWAP_DWORD_4X + + BSWAP_DWORD_LOOP: + mov eax, [esi] + bswap eax + mov [edi], eax + add esi, 4 + add edi, 4 + loopne BSWAP_DWORD_LOOP + + BSWAP_DWORD_4X: + mov ecx, ebx + shr ecx, 2 + je BSWAP_DWORD_END + BSWAP_DWORD_4X_LOOP: + mov eax, [esi] + bswap eax + mov [edi], eax + mov eax, [esi+4] + bswap eax + mov [edi+4], eax + mov eax, [esi+8] + bswap eax + mov [edi+8], eax + mov eax, [esi+12] + bswap eax + mov [edi+12], eax + add esi, 16 + add edi, 16 + loopne BSWAP_DWORD_4X_LOOP + + BSWAP_DWORD_END: + } + return (uae_u32) bswap_buffer; + + case 108: //frees swap array + bswap_buffer_size = 0; + free (bswap_buffer); + bswap_buffer = NULL; + return 0; +#endif + + case 200: + ahitweak = m68k_dreg (&context->regs, 1); + ahi_pollrate = m68k_dreg (&context->regs, 2); + if (ahi_pollrate < 10) + ahi_pollrate = 10; + if (ahi_pollrate > 60) + ahi_pollrate = 60; + return 1; + + default: + return 0x12345678; // Code for not supportet function + } +} + +#endif diff --git a/od-win32/ahidsound.c b/od-win32/ahidsound_unified.c similarity index 100% rename from od-win32/ahidsound.c rename to od-win32/ahidsound_unified.c diff --git a/od-win32/build68k_msvc/build68k_msvc.vcproj b/od-win32/build68k_msvc/build68k_msvc.vcproj index ed747f26..a783e62f 100644 --- a/od-win32/build68k_msvc/build68k_msvc.vcproj +++ b/od-win32/build68k_msvc/build68k_msvc.vcproj @@ -21,7 +21,7 @@ ConfigurationType="1" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" + CharacterSet="1" > 0 || d3d_good > 0) + return 1; + if (d3d_good < 0) + return 0; + d3d_good = -1; + d3dx = Direct3DCreate9 (D3D_SDK_VERSION); + if (d3dx != NULL) { + if (SUCCEEDED (IDirect3D9_GetDeviceCaps (d3dx, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps))) { + if(d3dCaps.PixelShaderVersion >= D3DPS_VERSION(2,0)) + d3d_good = 1; + } + IDirect3D9_Release (d3dx); + } + return d3d_good > 0 ? 1 : 0; +} + int D3D_canshaders (void) { - static int yesno = 0; HANDLE h; LPDIRECT3D9 d3dx; D3DCAPS9 d3dCaps; - if (yesno < 0) + if (d3d_yesno < 0) return 0; - if (yesno > 0) + if (d3d_yesno > 0) return 1; - yesno = -1; + d3d_yesno = -1; h = LoadLibrary (L"d3dx9_41.dll"); if (h != NULL) { FreeLibrary (h); @@ -327,13 +350,13 @@ int D3D_canshaders (void) if (SUCCEEDED (IDirect3D9_GetDeviceCaps (d3dx, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps))) { if(d3dCaps.PixelShaderVersion >= D3DPS_VERSION(2,0)) { write_log (L"D3D: Pixel shader 2.0+ support detected, shader filters enabled.\n"); - yesno = 1; + d3d_yesno = 1; } } IDirect3D9_Release (d3dx); } } - return yesno > 0 ? 1 : 0; + return d3d_yesno > 0 ? 1 : 0; } static int psEffect_LoadEffect (const TCHAR *shaderfile) @@ -1020,7 +1043,8 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth hr = -1; if (d3d_ex && D3DEX) { hr = Direct3DCreate9Ex (D3D_SDK_VERSION, &d3dex); - write_log (L"Direct3D: failed to create D3DEx object: %s\n", D3D_ErrorString (hr)); + if (FAILED (hr)) + write_log (L"Direct3D: failed to create D3DEx object: %s\n", D3D_ErrorString (hr)); d3d = (IDirect3D9*)d3dex; } if (FAILED (hr)) { @@ -1040,8 +1064,11 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth adapter = 0; modeex.Size = sizeof modeex; - if (d3dex && D3DEX) - IDirect3D9Ex_GetAdapterDisplayModeEx (d3dex, adapter, &modeex, NULL); + if (d3dex && D3DEX) { + LUID luid; + hr = IDirect3D9Ex_GetAdapterLUID (d3dex, adapter, &luid); + hr = IDirect3D9Ex_GetAdapterDisplayModeEx (d3dex, adapter, &modeex, NULL); + } if (FAILED (hr = IDirect3D9_GetAdapterDisplayMode (d3d, adapter, &mode))) write_log (L"D3D: IDirect3D9_GetAdapterDisplayMode failed %s\n", D3D_ErrorString (hr)); if (FAILED (hr = IDirect3D9_GetDeviceCaps (d3d, adapter, D3DDEVTYPE_HAL, &d3dCaps))) @@ -1187,6 +1214,7 @@ int D3D_needreset (void) hr = IDirect3DDevice9_Reset (d3ddev, &dpp); if (FAILED (hr)) { write_log (L"D3D: Reset failed %s\n", D3D_ErrorString (hr)); + changed_prefs.gfx_filter = 0; return 1; } } diff --git a/od-win32/direct3d.h b/od-win32/direct3d.h index 9601cd92..6cf5c0ee 100644 --- a/od-win32/direct3d.h +++ b/od-win32/direct3d.h @@ -13,3 +13,4 @@ extern int D3D_isenabled (void); extern int D3D_needreset (void); extern void D3D_clear (void); extern int D3D_canshaders (void); +extern int D3D_goodenough (void); diff --git a/od-win32/dxwrap.h b/od-win32/dxwrap.h index 6ae88172..919461bb 100644 --- a/od-win32/dxwrap.h +++ b/od-win32/dxwrap.h @@ -69,8 +69,7 @@ extern GUID *displayGUID; struct MultiDisplay { int primary, disabled, gdi; GUID guid; - TCHAR *name; - TCHAR *name2; + TCHAR *name, *name2, *name3; struct PicassoResolution *DisplayModes; RECT rect; }; diff --git a/od-win32/genblitter_msvc/genblitter_msvc.vcproj b/od-win32/genblitter_msvc/genblitter_msvc.vcproj index f02fc41f..e179c9d1 100644 --- a/od-win32/genblitter_msvc/genblitter_msvc.vcproj +++ b/od-win32/genblitter_msvc/genblitter_msvc.vcproj @@ -21,7 +21,7 @@ ConfigurationType="1" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" + CharacterSet="1" > + + diff --git a/od-win32/hq2x_d3d.c b/od-win32/hq2x_d3d.c index f48ab021..583ac28f 100644 --- a/od-win32/hq2x_d3d.c +++ b/od-win32/hq2x_d3d.c @@ -20,6 +20,7 @@ */ #include "hq2x_d3d.h" +#include #define fmax(x,y) ((x)>(y)?(x):(y)) #define fmin(x,y) ((x)<(y)?(x):(y)) diff --git a/od-win32/keyboard_win32.c b/od-win32/keyboard_win32.c index 34988ec8..06bfa325 100644 --- a/od-win32/keyboard_win32.c +++ b/od-win32/keyboard_win32.c @@ -218,9 +218,7 @@ int getcapslock (void) { int newstate; - BYTE keyState[256]; - GetKeyboardState (keyState); - newstate = keyState[VK_CAPITAL] & 1; + newstate = GetKeyState (VK_CAPITAL) & 1; // this returns bogus state if caps change when in exclusive mode.. if (newstate != capslockstate) inputdevice_translatekeycode (0, DIK_CAPITAL, newstate); capslockstate = newstate; diff --git a/od-win32/lcd.c b/od-win32/lcd.c index 7bf6aacf..480d6dee 100644 --- a/od-win32/lcd.c +++ b/od-win32/lcd.c @@ -14,7 +14,7 @@ extern HINSTANCE hInst; static int inited; static lgLcdConnectContext cctx; -static lgLcdDeviceDesc desc; +static lgLcdDeviceDescEx desc; static int device; static lgLcdBitmapHeader *lbh; static uae_u8 *bitmap, *origbitmap; @@ -22,7 +22,7 @@ static uae_u8 *numbers; static int numbers_width = 7, numbers_height = 10; static int old_pri; -void lcd_close(void) +void lcd_close (void) { lgLcdDeInit (); xfree (lbh); @@ -31,7 +31,7 @@ void lcd_close(void) inited = 0; } -static int lcd_init(void) +static int lcd_init (void) { DWORD ret; lgLcdOpenContext octx; @@ -57,13 +57,13 @@ static int lcd_init(void) ret = lgLcdConnect (&cctx); if (ret != ERROR_SUCCESS) { write_log (L"LCD: lgLcdConnect() returned %d\n", ret); - lcd_close(); + lcd_close (); return 0; } - ret = lgLcdEnumerate (cctx.connection, 0, &desc); + ret = lgLcdEnumerateEx (cctx.connection, 0, &desc); if (ret != ERROR_SUCCESS) { - write_log (L"LCD: lgLcdEnumerate() returned %d\n", ret); - lcd_close(); + write_log (L"LCD: lgLcdEnumerateEx() returned %d\n", ret); + lcd_close (); return 0; } lbh = xcalloc (1, sizeof (lgLcdBitmapHeader) + desc.Width * (desc.Height + 20)); @@ -76,14 +76,14 @@ static int lcd_init(void) ret = lgLcdOpen (&octx); if (ret != ERROR_SUCCESS) { write_log (L"LCD: lgLcdOpen() returned %d\n", ret); - lcd_close(); + lcd_close (); return 0; } device = octx.device; bmp = LoadBitmap (hInst, MAKEINTRESOURCE(IDB_LCD160X43)); dc = CreateCompatibleDC (NULL); - SelectObject(dc, bmp); + SelectObject (dc, bmp); GetObject (bmp, sizeof (binfo), &binfo); for (y = 0; y < binfo.bmHeight; y++) { for (x = 0; x < binfo.bmWidth; x++) { @@ -98,7 +98,7 @@ static int lcd_init(void) return 1; } -static void dorect(int *crd, int inv) +static void dorect (int *crd, int inv) { int yy, xx; int x = crd[0], y = crd[1], w = crd[2], h = crd[3]; @@ -112,7 +112,7 @@ static void dorect(int *crd, int inv) } } -static void putnumber(int x, int y, int n, int inv) +static void putnumber (int x, int y, int n, int inv) { int xx, yy; uae_u8 *dst, *src; @@ -135,7 +135,7 @@ static void putnumber(int x, int y, int n, int inv) } } -static void putnumbers(int x, int y, int num, int inv) +static void putnumbers (int x, int y, int num, int inv) { putnumber (x, y, num < 0 ? num : ((num / 10) > 0 ? num / 10 : -1), inv); putnumber (x + numbers_width, y, num < 0 ? num : num % 10, inv); @@ -157,7 +157,7 @@ void lcd_priority (int priority) old_pri = priority; } -void lcd_update(int led, int on) +void lcd_update (int led, int on) { int track, x, y; @@ -196,7 +196,7 @@ void lcd_update(int led, int on) lgLcdUpdateBitmap (device, lbh, LGLCD_ASYNC_UPDATE (LGLCD_PRIORITY_NORMAL + 1)); } -int lcd_open(void) +int lcd_open (void) { if (!inited) { if (!lcd_init ()) diff --git a/od-win32/parser.c b/od-win32/parser.c index 4548c1e3..6caaa6eb 100644 --- a/od-win32/parser.c +++ b/od-win32/parser.c @@ -53,6 +53,8 @@ #include #include +#define MIN_PRTBYTES 10 + static uae_char prtbuf[PRTBUFSIZE]; static int prtbufbytes,wantwrite; static HANDLE hPrt = INVALID_HANDLE_VALUE; @@ -213,6 +215,18 @@ static void *prt_thread (void *p) return 0; } +static int doflushprinter (void) +{ + if (prtopen == 0 && prtbufbytes < MIN_PRTBYTES) { + if (prtbufbytes > 0) + write_log (L"PRINTER: %d bytes received, less than %d bytes, not printing.\n", prtbufbytes, MIN_PRTBYTES); + prtbufbytes = 0; + return 0; + } + return 1; +} + +static void openprinter (void); static void flushprtbuf (void) { DWORD written = 0; @@ -224,6 +238,7 @@ static void flushprtbuf (void) zfile_fwrite (prtbuf, prtbufbytes, 1, prtdump); if (currprefs.parallel_postscript_emulation) { + if (psmode) { uae_u8 *p; psbuffer = realloc (psbuffer, (psbuffers + 2) * sizeof (uae_u8*)); @@ -236,15 +251,24 @@ static void flushprtbuf (void) } prtbufbytes = 0; return; - } else if (hPrt != INVALID_HANDLE_VALUE) { - if (WritePrinter (hPrt, prtbuf, prtbufbytes, &written)) { - if (written != prtbufbytes) - write_log (L"PRINTER: Only wrote %d of %d bytes!\n", written, prtbufbytes); - } else { - write_log (L"PRINTER: Couldn't write data!\n"); + + } else if (prtbufbytes > 0) { + int pbyt = prtbufbytes; + + if (hPrt == INVALID_HANDLE_VALUE) { + if (!doflushprinter ()) + return; + openprinter (); } - } else { - write_log (L"PRINTER: Not open!\n"); + if (hPrt != INVALID_HANDLE_VALUE) { + if (WritePrinter (hPrt, prtbuf, pbyt, &written)) { + if (written != pbyt) + write_log (L"PRINTER: Only wrote %d of %d bytes!\n", written, pbyt); + } else { + write_log (L"PRINTER: Couldn't write data!\n"); + } + } + } prtbufbytes = 0; } @@ -287,6 +311,7 @@ static void DoSomeWeirdPrintingStuff (uae_char val) } freepsbuffers (); return; + } else if (!psmode && !stricmp (prev, "%!PS")) { if (postscript_print_debugging) @@ -325,7 +350,7 @@ int isprinter (void) int isprinteropen (void) { - if (prtopen) + if (prtopen || prtbufbytes > 0) return 1; return 0; } @@ -420,7 +445,7 @@ void unload_ghostscript (void) psmode = 0; } -void openprinter( void ) +static void openprinter (void) { DOC_INFO_1 DocInfo; static int first; @@ -436,14 +461,14 @@ void openprinter( void ) flushprtbuf (); if (OpenPrinter (currprefs.prtname, &hPrt, NULL)) { // Fill in the structure with info about this "document." - DocInfo.pDocName = L"My Document"; + DocInfo.pDocName = L"WinUAE Document"; DocInfo.pOutputFile = NULL; - DocInfo.pDatatype = L"RAW"; + DocInfo.pDatatype = currprefs.parallel_ascii_emulation ? L"TEXT" : L"RAW"; // Inform the spooler the document is beginning. - if ((dwJob = StartDocPrinter(hPrt, 1, (LPSTR)&DocInfo)) == 0) { - ClosePrinter(hPrt ); + if ((dwJob = StartDocPrinter (hPrt, 1, (LPSTR)&DocInfo)) == 0) { + ClosePrinter (hPrt ); hPrt = INVALID_HANDLE_VALUE; - } else if(StartPagePrinter (hPrt)) { + } else if (StartPagePrinter (hPrt)) { prtopen = 1; } } else { @@ -459,6 +484,8 @@ void openprinter( void ) void flushprinter (void) { + if (!doflushprinter ()) + return; closeprinter (); } @@ -486,21 +513,13 @@ void closeprinter (void) Sleep (10); } freepsbuffers (); + prtbufbytes = 0; } -static void putprinter (uae_char val) -{ - DoSomeWeirdPrintingStuff (val); -} - -int doprinter (uae_u8 val) +void doprinter (uae_u8 val) { parflush = 0; - if (!prtopen) - openprinter (); - if (prtopen) - putprinter (val); - return prtopen; + DoSomeWeirdPrintingStuff (val); } struct uaeserialdatawin32 @@ -1115,7 +1134,8 @@ void hsyncstuff(void) keycheck++; if(keycheck >= 1000) { - flushprtbuf (); + if (prtopen) + flushprtbuf (); { #if defined(AHI) //extern int warned_JIT_0xF10000; diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 0eb34cef..4e09038c 100644 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -2359,10 +2359,14 @@ static void inituaegfx (uaecptr ABI) flags |= BIF_HARDWARESPRITE; #endif if (flags & BIF_NOBLITTER) - write_log (L"P96: blitter disabled in devs:monitors/uaegfx!\n"); + write_log (L"P96: Blitter disabled in devs:monitors/uaegfx!\n"); if (currprefs.win32_rtgvblankrate >= -1) flags |= BIF_VBLANKINTERRUPT; + if (!(flags & BIF_INDISPLAYCHAIN)) { + write_log (L"P96: BIF_INDISPLAYCHAIN force-enabled!\n"); + flags |= BIF_INDISPLAYCHAIN; + } put_long (ABI + PSSO_BoardInfo_Flags, flags); diff --git a/od-win32/resources/resource b/od-win32/resources/resource index 3ccc5557..17697b6b 100644 --- a/od-win32/resources/resource +++ b/od-win32/resources/resource @@ -307,6 +307,9 @@ #define IDS_TABLET_BOTH_CURSORS 345 #define IDS_TABLET_NATIVE_CURSOR 346 #define IDS_TABLET_HOST_CURSOR 347 +#define IDS_AUTOSCALE_DISABLED 348 +#define IDS_AUTOSCALE_SCALING 349 +#define IDS_AUTOSCALE_RESIZE 350 #define IDS_QS_MODELS 1000 #define IDS_QS_MODEL_A500 1001 #define IDS_QS_MODEL_A500P 1002 @@ -619,6 +622,8 @@ #define IDC_PSPRINTER 1556 #define IDC_PSPRINTERDETECT 1557 #define IDC_UAESERIAL 1558 +#define IDC_PSPRINTERDETECT2 1559 +#define IDC_ASCIIPRINTER 1559 #define IDC_VIEWINFO 1568 #define IDC_SETINFO 1569 #define IDC_FLOPPYSLIDER 1570 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 49996325..3eadb21a 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -349,8 +349,8 @@ BEGIN RTEXT "Printer:",IDC_STATIC,12,15,25,15,SS_CENTERIMAGE COMBOBOX IDC_PRINTERLIST,49,15,232,134,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Flush print job",IDC_FLUSHPRINTER,114,51,58,12 - CONTROL "PostScript detection",IDC_PSPRINTERDETECT,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,65,35,79,12 - CONTROL "PostScript printer emulation",IDC_PSPRINTER,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,175,35,110,12 + CONTROL "PostScript detection",IDC_PSPRINTERDETECT,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,91,35,84,12 + CONTROL "PostScript printer emulation",IDC_PSPRINTER,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,180,35,111,12 RTEXT "Autoflush [] Time in seconds after a pending print job is automatically flushed.",IDC_PRINTERAUTOFLUSHTXT,173,49,86,15,SS_NOTIFY | SS_CENTERIMAGE EDITTEXT IDC_PRINTERAUTOFLUSH,263,50,25,12,ES_NUMBER RTEXT "Ghostscript extra parameters:",IDC_STATIC,12,66,102,15,SS_CENTERIMAGE @@ -367,6 +367,7 @@ BEGIN CONTROL "Direct []Use when emulating serial-link games on two PCs running WinUAE",IDC_SER_DIRECT, "Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,135,123,65,12 CONTROL "uaeserial.device",IDC_UAESERIAL,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,200,123,78,12 + CONTROL "ASCII Printer",IDC_ASCIIPRINTER,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,13,35,69,12 END IDD_GAMEPORTS DIALOGEX 0, 0, 300, 236 @@ -1112,11 +1113,6 @@ IDB_LCD160X43 BITMAP "lcd.bmp" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN - IDD_IOPORTS, DIALOG - BEGIN - BOTTOMMARGIN, 180 - END - IDD_FILTER, DIALOG BEGIN BOTTOMMARGIN, 237 @@ -1445,6 +1441,9 @@ BEGIN IDS_TABLET_BOTH_CURSORS "Show both cursors" IDS_TABLET_NATIVE_CURSOR "Show native cursor only" IDS_TABLET_HOST_CURSOR "Show host cursor only" + IDS_AUTOSCALE_DISABLED "Disabled" + IDS_AUTOSCALE_SCALING "Automatic scaling" + IDS_AUTOSCALE_RESIZE "Automatic resize" END #endif // English (U.S.) resources diff --git a/od-win32/screenshot.c b/od-win32/screenshot.c index 54234e19..09bd5d34 100644 --- a/od-win32/screenshot.c +++ b/od-win32/screenshot.c @@ -153,7 +153,7 @@ oops: #if PNG_SCREENSHOTS > 0 -static void pngtest_blah (png_structp png_ptr, png_const_charp message) +static void _cdecl pngtest_blah (png_structp png_ptr, png_const_charp message) { TCHAR *name = L"unknown"; if (png_ptr != NULL && png_ptr->error_ptr != NULL) diff --git a/od-win32/sounddep/sound.c b/od-win32/sounddep/sound.c index fedb61a3..b7cf4a17 100644 --- a/od-win32/sounddep/sound.c +++ b/od-win32/sounddep/sound.c @@ -306,7 +306,7 @@ const static GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010, static struct dsaudiomodes supportedmodes[16]; -DWORD fillsupportedmodes (LPDIRECTSOUND8 lpDS, int freq, struct dsaudiomodes *dsam) +static DWORD fillsupportedmodes (struct sound_data *sd, int freq, struct dsaudiomodes *dsam) { DWORD speakerconfig; DSBUFFERDESC sound_buffer; @@ -315,7 +315,8 @@ DWORD fillsupportedmodes (LPDIRECTSOUND8 lpDS, int freq, struct dsaudiomodes *ds HRESULT hr; int ch, round, mode, skip; DWORD rn[4]; - struct sound_dp *s = sdp->data; + struct sound_dp *s = sd->data; + LPDIRECTSOUND8 lpDS = s->lpDS; mode = 2; dsam[0].ch = 1; @@ -383,7 +384,7 @@ static void finish_sound_buffer_pa (struct sound_data *sd, uae_u16 *sndbuffer) memcpy (s->pasoundbuffer[s->patoggle], sndbuffer, sd->sndbufsize); } -static int portAudioCallback (const void *inputBuffer, void *outputBuffer, +static int _cdecl portAudioCallback (const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, @@ -636,7 +637,7 @@ static int open_audio_ds (struct sound_data *sd, int index) } } - speakerconfig = fillsupportedmodes (s->lpDS, freq, supportedmodes); + speakerconfig = fillsupportedmodes (sd, freq, supportedmodes); write_log (L"DSSOUND: %08X ", speakerconfig); for (i = 0; supportedmodes[i].ch; i++) write_log (L"%d:%08X ", supportedmodes[i].ch, supportedmodes[i].ksmode); @@ -1536,7 +1537,7 @@ int enumerate_sound_devices (void) write_log (L"Enumerating DirectSound devices..\n"); DirectSoundEnumerate ((LPDSENUMCALLBACK)DSEnumProc, sound_devices); DirectSoundCaptureEnumerate ((LPDSENUMCALLBACK)DSEnumProc, record_devices); - if (isdllversion (L"openal32.dll", 6, 14, 357, 22)) { + if (0 && isdllversion (L"openal32.dll", 6, 14, 357, 22)) { write_log (L"Enumerating OpenAL devices..\n"); if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT")) { const char* ppDefaultDevice = alcGetString (NULL, ALC_DEFAULT_DEVICE_SPECIFIER); diff --git a/od-win32/sys/mman.h b/od-win32/sys/mman.h index ad1d8a7d..c79359e6 100644 --- a/od-win32/sys/mman.h +++ b/od-win32/sys/mman.h @@ -35,9 +35,6 @@ int shmget (key_t key, size_t size, int shmflg, const TCHAR*); int shmctl (int shmid, int cmd, struct shmid_ds *buf); int init_shm (void); -int isinf(double x); -int isnan(double x); - #define PROT_READ 0x01 #define PROT_WRITE 0x02 #define PROT_EXEC 0x04 diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index dccea6db..d66949cd 100644 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -265,7 +265,6 @@ #define HAVE_ISNAN #define HAVE_ISINF #define isnan _isnan -extern int isinf(double); /* Define if you have the bcopy function. */ /* #undef HAVE_BCOPY */ diff --git a/od-win32/win32.c b/od-win32/win32.c index 7a556794..aec64d6c 100644 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -266,7 +266,7 @@ frame_time_t read_processor_time (void) #include static volatile int dummythread_die; -static void dummythread (void *dummy) +static void _cdecl dummythread (void *dummy) { SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_LOWEST); while (!dummythread_die); diff --git a/od-win32/win32.h b/od-win32/win32.h index 55ad3132..503c1548 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -17,8 +17,8 @@ #define WINUAEPUBLICBETA 1 -#define WINUAEBETA L"26" -#define WINUAEDATE MAKEBD(2009, 4, 26) +#define WINUAEBETA L"27" +#define WINUAEDATE MAKEBD(2009, 5, 1) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32_scale2x.c b/od-win32/win32_scale2x.c index 6ccf44e2..a83562b8 100644 --- a/od-win32/win32_scale2x.c +++ b/od-win32/win32_scale2x.c @@ -74,7 +74,6 @@ uae_u8 *getfilterrect1 (RECT *sr, RECT *dr, int dst_depth, int aw, int ah, int s { int aws, ahs; - ah = vblscale (ah); aws = aw * scale; ahs = ah * scale; @@ -95,16 +94,14 @@ static void sizeoffset (RECT *dr, RECT *zr, int w, int h) void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height, int aw, int ah, int scale, int temp_width, int temp_height) { - int aws, ahs, ahs2, hdiff; + int aws, ahs, ahs2; int xs, ys; int xmult, ymult; int v; - ahs2 = ah * scale; - ah = vblscale (ah); + ahs2 = vblscale (ah) * scale; aws = aw * scale; ahs = ah * scale; - hdiff = (ahs2 - ahs) / 2; SetRect (sr, 0, 0, dst_width, dst_height); SetRect (zr, 0, 0, 0, 0); @@ -112,7 +109,6 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height dr->top = (temp_height - ahs) / 2; dr->left -= (dst_width - aws) / 2; dr->top -= (dst_height - ahs) / 2; - dr->top -= hdiff; dr->right = dr->left + dst_width; dr->bottom = dr->top + dst_height; @@ -184,7 +180,6 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height SetRect (sr, 0, 0, cw * scale, ch * scale); dr->left = (temp_width - aws) /2; dr->top = (temp_height - ahs) / 2; - dr->top -= hdiff; dr->right = dr->left + cw * scale; dr->bottom = dr->top + ch * scale; OffsetRect (zr, cx * scale, cy * scale); @@ -200,7 +195,6 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height dr->left = (temp_width - aws) /2; dr->top = (temp_height - ahs) / 2; - dr->top -= hdiff; dr->right = dr->left + dst_width * scale; dr->bottom = dr->top + dst_height * scale; @@ -214,7 +208,7 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height filteroffsetx = -zr->left / scale; filteroffsety = -zr->top / scale; - if (currprefs.gfx_filter_keep_aspect || currprefs.gfx_filter_aspect > 0) { + if (currprefs.gfx_filter_keep_aspect || currprefs.gfx_filter_aspect != 0) { int dw = dst_width; int dh = dst_height; int xratio, yratio; @@ -223,10 +217,16 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height xratio = dw * 256 / cw; yratio = dh * 256 / ch; - if (currprefs.gfx_filter_aspect > 0) { - int xm = (currprefs.gfx_filter_aspect >> 8) * 256; - int ym = (currprefs.gfx_filter_aspect & 0xff) * 256; - int mult = currprefs.gfx_resolution - (currprefs.gfx_linedbl ? 1 : 0); + if (currprefs.gfx_filter_aspect != 0) { + int xm, ym, mult; + if (currprefs.gfx_filter_aspect > 0) { + xm = (currprefs.gfx_filter_aspect >> 8) * 256; + ym = (currprefs.gfx_filter_aspect & 0xff) * 256; + } else { + xm = dst_width * 256; + ym = dst_height * 256; + } + mult = currprefs.gfx_resolution - (currprefs.gfx_linedbl ? 1 : 0); if (mult < 0) xm *= 1 << (-mult); else @@ -259,7 +259,6 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height xmult = ymult; else ymult = xmult; - ymult = vblscale (ymult); } else { if (xmult <= 0) xmult = aws * 1000 / dst_width; @@ -271,12 +270,17 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height ymult = ymult + ymult * currprefs.gfx_filter_vert_zoom / 2000; } - if (currprefs.gfx_filter_aspect > 0) { + if (currprefs.gfx_filter_aspect != 0) { int srcratio, dstratio; int xmult2 = xmult; int ymult2 = ymult; - dstratio = (currprefs.gfx_filter_aspect >> 8) * 256 / (currprefs.gfx_filter_aspect & 0xff); - srcratio = dst_width * 256 / dst_height; + if (currprefs.gfx_filter_aspect > 0) { + dstratio = (currprefs.gfx_filter_aspect >> 8) * 256 / (currprefs.gfx_filter_aspect & 0xff); + srcratio = dst_width * 256 / dst_height; + } else { + dstratio = 4 * 256 / 3; + srcratio = dst_width * 256 / dst_height; + } if (srcratio > dstratio) { xmult = xmult * srcratio / dstratio; } else { @@ -284,6 +288,8 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height } } + ymult = vblscale (ymult); + v = currprefs.gfx_filter ? currprefs.gfx_filter_horiz_offset : 0; OffsetRect (zr, (int)(-v * aws / 1000.0), 0); v = currprefs.gfx_filter ? currprefs.gfx_filter_vert_offset : 0; @@ -291,6 +297,7 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height xs = dst_width - dst_width * xmult / 1000; ys = dst_height - dst_height * ymult / 1000; + OffsetRect (dr, 0, (ahs2 - ahs) / 2); sizeoffset (dr, zr, xs, ys); filterxmult = xmult; diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index 7417752e..b26f72da 100644 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -374,40 +374,36 @@ oops: return 0; } -static HRESULT CALLBACK modesCallback (LPDDSURFACEDESC2 modeDesc, LPVOID context) +static void addmode (struct MultiDisplay *md, int w, int h, int d, int rate, int nondx) { - RGBFTYPE colortype; - int i, j, ct, depth; - struct MultiDisplay *md = context; + int ct; + int i, j; - colortype = DirectDraw_GetSurfacePixelFormat (modeDesc); - if (colortype == RGBFB_NONE) - return DDENUMRET_OK; - if (modeDesc->dwWidth > 2560 || modeDesc->dwHeight > 2048) - return DDENUMRET_OK; - ct = 1 << colortype; - depth = 0; - if (ct & RGBMASK_8BIT) - depth = 1; - else if (ct & (RGBMASK_15BIT | RGBMASK_16BIT)) - depth = 2; - else if (ct & RGBMASK_24BIT) - depth = 3; - else if (ct & RGBMASK_32BIT) - depth = 4; - if (depth == 0) - return DDENUMRET_OK; + ct = 0; + if (d == 8) + ct = RGBMASK_8BIT; + if (d == 15) + ct = RGBMASK_15BIT; + if (d == 16) + ct = RGBMASK_16BIT; + if (d == 24) + ct = RGBMASK_24BIT; + if (d == 32) + ct = RGBMASK_32BIT; + if (ct == 0) + return; + d /= 8; i = 0; while (md->DisplayModes[i].depth >= 0) { - if (md->DisplayModes[i].depth == depth && md->DisplayModes[i].res.width == modeDesc->dwWidth && md->DisplayModes[i].res.height == modeDesc->dwHeight) { + if (md->DisplayModes[i].depth == d && md->DisplayModes[i].res.width == w && md->DisplayModes[i].res.height == h) { for (j = 0; j < MAX_REFRESH_RATES; j++) { - if (md->DisplayModes[i].refresh[j] == 0 || md->DisplayModes[i].refresh[j] == modeDesc->dwRefreshRate) + if (md->DisplayModes[i].refresh[j] == 0 || md->DisplayModes[i].refresh[j] == rate) break; } if (j < MAX_REFRESH_RATES) { - md->DisplayModes[i].refresh[j] = modeDesc->dwRefreshRate; + md->DisplayModes[i].refresh[j] = rate; md->DisplayModes[i].refresh[j + 1] = 0; - return DDENUMRET_OK; + return; } } i++; @@ -416,20 +412,48 @@ static HRESULT CALLBACK modesCallback (LPDDSURFACEDESC2 modeDesc, LPVOID context while (md->DisplayModes[i].depth >= 0) i++; if (i >= MAX_PICASSO_MODES - 1) - return DDENUMRET_OK; - md->DisplayModes[i].res.width = modeDesc->dwWidth; - md->DisplayModes[i].res.height = modeDesc->dwHeight; - md->DisplayModes[i].depth = depth; - md->DisplayModes[i].refresh[0] = modeDesc->dwRefreshRate; + return; + md->DisplayModes[i].res.width = w; + md->DisplayModes[i].res.height = h; + md->DisplayModes[i].depth = d; + md->DisplayModes[i].refresh[0] = rate; md->DisplayModes[i].refresh[1] = 0; md->DisplayModes[i].colormodes = ct; md->DisplayModes[i + 1].depth = -1; _stprintf (md->DisplayModes[i].name, L"%dx%d, %d-bit", md->DisplayModes[i].res.width, md->DisplayModes[i].res.height, md->DisplayModes[i].depth * 8); +} + +static HRESULT CALLBACK modesCallback (LPDDSURFACEDESC2 modeDesc, LPVOID context) +{ + struct MultiDisplay *md = context; + RGBFTYPE colortype; + int depth, ct; + + colortype = DirectDraw_GetSurfacePixelFormat (modeDesc); + ct = 1 << colortype; + depth = 0; + if (ct & RGBMASK_8BIT) + depth = 8; + else if (ct & RGBMASK_15BIT) + depth = 15; + else if (ct & RGBMASK_16BIT) + depth = 16; + else if (ct & RGBMASK_24BIT) + depth = 24; + else if (ct & RGBMASK_32BIT) + depth = 32; + if (depth == 0) + return DDENUMRET_OK; + if (colortype == RGBFB_NONE) + return DDENUMRET_OK; + if (modeDesc->dwWidth > 2560 || modeDesc->dwHeight > 2048) + return DDENUMRET_OK; + addmode (md, modeDesc->dwWidth, modeDesc->dwHeight, depth, modeDesc->dwRefreshRate, 0); return DDENUMRET_OK; } -static int resolution_compare (const void *a, const void *b) +static int _cdecl resolution_compare (const void *a, const void *b) { struct PicassoResolution *ma = (struct PicassoResolution *)a; struct PicassoResolution *mb = (struct PicassoResolution *)b; @@ -509,6 +533,7 @@ BOOL CALLBACK displaysCallback (GUID *guid, char *adesc, char *aname, LPVOID ctx _stprintf (tmp, L"%s (%d*%d) [%d*%d]", desc, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top, md->rect.left, md->rect.top); md->name = my_strdup (tmp); md->name2 = my_strdup (desc); + md->name3 = my_strdup (name); write_log (L"'%s' '%s' %s\n", desc, name, outGUID(guid)); ret = 1; end: @@ -560,7 +585,7 @@ static int makesort (struct MultiDisplay *md) void sortdisplays (void) { struct MultiDisplay *md1, *md2, tmp; - int i; + int i, idx, idx2; md1 = Displays; while (md1->name) { @@ -590,7 +615,36 @@ void sortdisplays (void) int b = DirectDraw_GetCurrentDepth (); write_log (L"Desktop: W=%d H=%d B=%d. CXVS=%d CYVS=%d\n", w, h, b, GetSystemMetrics (SM_CXVIRTUALSCREEN), GetSystemMetrics (SM_CYVIRTUALSCREEN)); - DirectDraw_EnumDisplayModes (DDEDM_REFRESHRATES , modesCallback, md1); + DirectDraw_EnumDisplayModes (DDEDM_REFRESHRATES, modesCallback, md1); + idx = 0; + for (;;) { + int found; + DEVMODE dm; + + dm.dmSize = sizeof dm; + dm.dmDriverExtra = 0; + if (!EnumDisplaySettings (md1->primary ? NULL : md1->name3, idx, &dm)) + break; + idx2 = 0; + found = 0; + while (md1->DisplayModes[idx2].depth >= 0 && !found) { + struct PicassoResolution *pr = &md1->DisplayModes[idx2]; + if (pr->res.width == dm.dmPelsWidth && pr->res.height == dm.dmPelsHeight && pr->depth == dm.dmBitsPerPel / 8) { + for (i = 0; pr->refresh[i]; i++) { + if (pr->refresh[i] == dm.dmDisplayFrequency) { + found = 1; + break; + } + } + } + idx2++; + } + if (!found) { + write_log (L"EnumDisplaySettings(%dx%dx%d %dHz)\n", dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency); + addmode (md1, dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency, 1); + } + idx++; + } //dhack(); sortmodes (md1); modesList (md1); @@ -1304,11 +1358,13 @@ int check_prefs_changed_gfx (void) if (_tcscmp (currprefs.prtname, changed_prefs.prtname) || currprefs.parallel_autoflush_time != changed_prefs.parallel_autoflush_time || + currprefs.parallel_ascii_emulation != changed_prefs.parallel_ascii_emulation || currprefs.parallel_postscript_emulation != changed_prefs.parallel_postscript_emulation || currprefs.parallel_postscript_detection != changed_prefs.parallel_postscript_detection || _tcscmp (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters)) { _tcscpy (currprefs.prtname, changed_prefs.prtname); currprefs.parallel_autoflush_time = changed_prefs.parallel_autoflush_time; + currprefs.parallel_ascii_emulation = changed_prefs.parallel_ascii_emulation; currprefs.parallel_postscript_emulation = changed_prefs.parallel_postscript_emulation; currprefs.parallel_postscript_detection = changed_prefs.parallel_postscript_detection; _tcscpy (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters); diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 4d9cf146..93af48d9 100644 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -4739,6 +4739,7 @@ static int display_toselect(int fs, int vsync, int p96) } static void display_fromselect(int val, int *fs, int *vsync, int p96) { + int ofs = *fs; if (val == CB_ERR) return; *fs = 0; @@ -4746,6 +4747,10 @@ static void display_fromselect(int val, int *fs, int *vsync, int p96) if (p96) { *fs = val / 2; *vsync = val & 1; + if (*fs == 2 && *fs != ofs) { + workprefs.win32_rtgscaleifsmall = 1; + workprefs.win32_rtgmatchdepth = 0; + } return; } switch (val) @@ -4762,6 +4767,22 @@ static void display_fromselect(int val, int *fs, int *vsync, int p96) break; case 3: *fs = 2; + if (workprefs.gfx_filter == 0 && *fs != ofs) { + if (D3D_goodenough ()) { + workprefs.gfx_filter = 2; + workprefs.gfx_filter_filtermode = 2; + } else { + workprefs.gfx_filter = 1; + } + workprefs.gfx_filter_horiz_zoom = 0; + workprefs.gfx_filter_vert_zoom = 0; + workprefs.gfx_filter_horiz_zoom_mult = 0; + workprefs.gfx_filter_vert_zoom_mult = 0; + workprefs.gfx_filter_aspect = -1; + workprefs.gfx_filter_horiz_offset = 0; + workprefs.gfx_filter_vert_offset = 0; + workprefs.gfx_filter_keep_aspect = 0; + } break; } } @@ -9304,6 +9325,7 @@ static void values_to_portsdlg (HWND hDlg) } } SetDlgItemInt (hDlg, IDC_PRINTERAUTOFLUSH, workprefs.parallel_autoflush_time, FALSE); + CheckDlgButton (hDlg, IDC_ASCIIPRINTER, workprefs.parallel_ascii_emulation); CheckDlgButton (hDlg, IDC_PSPRINTER, workprefs.parallel_postscript_emulation); CheckDlgButton (hDlg, IDC_PSPRINTERDETECT, workprefs.parallel_postscript_detection); SetDlgItemText (hDlg, IDC_PS_PARAMS, workprefs.ghostscript_parameters); @@ -9573,14 +9595,20 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR if (isprinter ()) { closeprinter (); } + } else if (wParam == IDC_ASCIIPRINTER) { + workprefs.parallel_ascii_emulation = IsDlgButtonChecked (hDlg, IDC_ASCIIPRINTER) ? 1 : 0; + if (workprefs.parallel_ascii_emulation) + workprefs.parallel_postscript_detection = 0; } else if (wParam == IDC_PSPRINTER) { workprefs.parallel_postscript_emulation = IsDlgButtonChecked (hDlg, IDC_PSPRINTER) ? 1 : 0; if (workprefs.parallel_postscript_emulation) CheckDlgButton (hDlg, IDC_PSPRINTERDETECT, 1); } else if (wParam == IDC_PSPRINTERDETECT) { workprefs.parallel_postscript_detection = IsDlgButtonChecked (hDlg, IDC_PSPRINTERDETECT) ? 1 : 0; - if (!workprefs.parallel_postscript_detection) + if (!workprefs.parallel_postscript_detection) { CheckDlgButton (hDlg, IDC_PSPRINTER, 0); + workprefs.parallel_ascii_emulation = 0; + } } else if (wParam == IDC_UAESERIAL || wParam == IDC_SER_SHARED || wParam == IDC_SER_DIRECT || wParam == IDC_SER_CTSRTS || wParam == IDC_PRINTERAUTOFLUSH) { values_from_portsdlg (hDlg); } else { @@ -10174,7 +10202,9 @@ struct filterpreset { }; static struct filterpreset filterpresets[] = { - { L"PAL example", 8, 0, 0, 0, 1000, 1000, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 }, + { L"PAL", 8, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 }, + { L"D3D Autoscale", 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1 }, + { L"D3D Full Scaling", 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { NULL } }; @@ -10242,16 +10272,20 @@ static void values_to_hw3ddlg (HWND hDlg) CheckDlgButton (hDlg, IDC_FILTERKEEPASPECT, workprefs.gfx_filter_keep_aspect); SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_SETCURSEL, (workprefs.gfx_filter_aspect == 0) ? 0 : - (workprefs.gfx_filter_aspect == 4 * 256 + 3) ? 1 : - (workprefs.gfx_filter_aspect == 5 * 256 + 4) ? 2 : - (workprefs.gfx_filter_aspect == 15 * 256 + 9) ? 3 : - (workprefs.gfx_filter_aspect == 16 * 256 + 9) ? 4 : - (workprefs.gfx_filter_aspect == 16 * 256 + 10) ? 5 : 0, 0); + (workprefs.gfx_filter_aspect < 0) ? 1 : + (workprefs.gfx_filter_aspect == 4 * 256 + 3) ? 2 : + (workprefs.gfx_filter_aspect == 5 * 256 + 4) ? 3 : + (workprefs.gfx_filter_aspect == 15 * 256 + 9) ? 4 : + (workprefs.gfx_filter_aspect == 16 * 256 + 9) ? 5 : + (workprefs.gfx_filter_aspect == 16 * 256 + 10) ? 6 : 0, 0); SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_RESETCONTENT, 0, 0L); - SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Disabled"); - SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Automatic scaling"); - SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Automatic resize"); + WIN32GUI_LoadUIString (IDS_AUTOSCALE_DISABLED, txt, sizeof (txt) / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)txt); + WIN32GUI_LoadUIString (IDS_AUTOSCALE_SCALING, txt, sizeof (txt) / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)txt); + WIN32GUI_LoadUIString (IDS_AUTOSCALE_RESIZE, txt, sizeof (txt) / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)txt); SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_SETCURSEL, workprefs.gfx_filter_autoscale, 0); SendDlgItemMessage (hDlg, IDC_FILTERHZ, TBM_SETRANGE, TRUE, MAKELONG (-999, +999)); @@ -10582,6 +10616,8 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_RESETCONTENT, 0, 0); WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp / sizeof (TCHAR)); SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)tmp); + WIN32GUI_LoadUIString (IDS_AUTOMATIC, tmp, sizeof tmp / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)tmp); SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"4:3"); SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"5:4"); SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"15:9"); @@ -10632,8 +10668,14 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM item = SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_GETCURSEL, 0, 0L); if (item != CB_ERR) { workprefs.gfx_filter_autoscale = item; - if (workprefs.gfx_filter_autoscale && workprefs.gfx_filter == 0) - workprefs.gfx_filter = 1; + if (workprefs.gfx_filter_autoscale && workprefs.gfx_filter == 0) { + if (D3D_goodenough ()) { + workprefs.gfx_filter = 2; // D3D + workprefs.gfx_filter_filtermode = 2; + } else { + workprefs.gfx_filter = 1; // NULL + } + } values_to_hw3ddlg (hDlg); enable_for_hw3ddlg (hDlg); } @@ -10674,14 +10716,16 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if (v == 0) v2 = 0; if (v == 1) - v2 = 4 * 256 + 3; + v2 = -1; if (v == 2) - v2 = 5 * 256 + 4; + v2 = 4 * 256 + 3; if (v == 3) - v2 = 15 * 256 + 9; + v2 = 5 * 256 + 4; if (v == 4) - v2 = 16 * 256 + 9; + v2 = 15 * 256 + 9; if (v == 5) + v2 = 16 * 256 + 9; + if (v == 6) v2 = 16 * 256 + 10; } currprefs.gfx_filter_aspect = workprefs.gfx_filter_aspect = v2; diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 28fb5b51..31f24732 100644 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -68,7 +68,8 @@ SuppressStartupBanner="true" Detect64BitPortabilityProblems="false" DebugInformationFormat="4" - CompileAs="0" + CallingConvention="2" + CompileAs="1" DisableSpecificWarnings="4996" EnablePREfast="false" /> @@ -126,13 +127,13 @@ /> @@ -521,13 +467,14 @@ />