]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1330b3.zip
authorToni Wilen <twilen@winuae.net>
Sun, 24 Sep 2006 10:15:32 +0000 (13:15 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:29:43 +0000 (21:29 +0200)
15 files changed:
audio.c
custom.c
drawing.c
include/gui.h
od-win32/WinUAE_Install.nsi
od-win32/WinUAE_Install.tmp.nsi [deleted file]
od-win32/dxwrap.c
od-win32/posixemu.c
od-win32/sounddep/sound.c
od-win32/sounddep/sound.h
od-win32/win32.c
od-win32/win32.h
od-win32/win32gfx.c
od-win32/win32gui.c
savestate.c

diff --git a/audio.c b/audio.c
index 1e7437b6ca646c2eab443aca9c07dadb4deb57ad..3cf13ba635c0b44c42bca66f1db3a76323d74f93 100755 (executable)
--- a/audio.c
+++ b/audio.c
@@ -937,6 +937,30 @@ void sample16si_rh_handler (void)
 }
 #endif
 
+static int audio_work_to_do;
+
+static void audio_deactivate(void)
+{
+    write_log ("Audio stopped\n");
+    gui_data.sndbuf_status = 3;
+    gui_data.sndbuf = 0;
+    clear_sound_buffers();
+}
+
+STATIC_INLINE void audio_active(void)
+{
+    if (!audio_work_to_do) {
+       write_log ("Audio started\n");
+       restart_sound_buffer();
+    }
+    audio_work_to_do = 2 * maxvpos * 50;
+}
+STATIC_INLINE int is_audio_active(void)
+{
+    return audio_work_to_do;
+}
+
+
 void schedule_audio (void)
 {
     unsigned long best = MAX_EV;
@@ -1020,6 +1044,7 @@ static void audio_handler (int nr, int timed)
     int napnav = (!audav && !audap) || audav;
     int evtime = cdp->evtime;
 
+    audio_active();
     cdp->evtime = MAX_EV;
     switch (cdp->state)
     {
@@ -1331,12 +1356,14 @@ void set_audio(void)
 
 void update_audio (void)
 {
-    unsigned long int n_cycles;
+    unsigned long int n_cycles = 0;
 
     if (!isaudio())
-       return;
+       goto end;
     if (savestate_state == STATE_RESTORE)
-       return;
+       goto end;
+    if (!is_audio_active())
+       goto end;
 
     n_cycles = get_cycles () - last_cycles;
     for (;;) {
@@ -1386,6 +1413,7 @@ void update_audio (void)
        if (audio_channel[3].evtime == 0)
            audio_handler (3, 1);
     }
+end:
     last_cycles = get_cycles () - n_cycles;
 }
 
@@ -1403,10 +1431,25 @@ uae_u16 dmacon;
 void audio_hsync (int dmaaction)
 {
     int nr, handle;
+    static int old_dma;
+
+    if (old_dma != (dmacon & (DMA_MASTER | 15))) {
+       old_dma = dmacon & (DMA_MASTER | 15);
+       audio_active();
+    }
 
     if (!isaudio())
        return;
 
+    if (audio_work_to_do > 0) {
+       audio_work_to_do--;
+       if (audio_work_to_do == 0)
+           audio_deactivate();
+    }
+
+    if (!is_audio_active())
+       return;
+
     update_audio ();
     handle = 0;
     /* Sound data is fetched at the beginning of each line */
@@ -1474,6 +1517,7 @@ void AUDxDAT (int nr, uae_u16 v)
        write_log ("AUD%dDAT: %04.4X STATE=%d IRQ=%d %08.8X\n", nr,
            v, cdp->state, isirq(nr) ? 1 : 0, M68K_GETPC);
 #endif
+    audio_active();
     update_audio ();
     cdp->dat2 = v;
     cdp->request_word = -1;
@@ -1488,6 +1532,7 @@ void AUDxDAT (int nr, uae_u16 v)
 
 void AUDxLCH (int nr, uae_u16 v)
 {
+    audio_active();
     update_audio ();
     audio_channel[nr].lc = (audio_channel[nr].lc & 0xffff) | ((uae_u32)v << 16);
 #ifdef DEBUG_AUDIO
@@ -1498,6 +1543,7 @@ void AUDxLCH (int nr, uae_u16 v)
 
 void AUDxLCL (int nr, uae_u16 v)
 {
+    audio_active();
     update_audio ();
     audio_channel[nr].lc = (audio_channel[nr].lc & ~0xffff) | (v & 0xFFFE);
 #ifdef DEBUG_AUDIO
@@ -1511,6 +1557,7 @@ void AUDxPER (int nr, uae_u16 v)
     unsigned long per = v * CYCLE_UNIT;
     update_audio ();
 
+    audio_active();
     if (per == 0)
        per = PERIOD_MAX - 1;
 
@@ -1545,6 +1592,7 @@ void AUDxLEN (int nr, uae_u16 v)
 void AUDxVOL (int nr, uae_u16 v)
 {
     int v2 = v & 64 ? 63 : v & 63;
+    audio_active();
     update_audio ();
     audio_channel[nr].vol = v2;
 #ifndef        MULTIPLICATION_PROFITABLE
@@ -1579,20 +1627,20 @@ void audio_update_irq (uae_u16 v)
 
 void audio_update_adkmasks (void)
 {
+    static int prevcon = -1;
     unsigned long t = adkcon | (adkcon >> 4);
+
     audio_channel[0].adk_mask = (((t >> 0) & 1) - 1);
     audio_channel[1].adk_mask = (((t >> 1) & 1) - 1);
     audio_channel[2].adk_mask = (((t >> 2) & 1) - 1);
     audio_channel[3].adk_mask = (((t >> 3) & 1) - 1);
+    if ((prevcon & 0xff) != (adkcon & 0xff)) {
+       audio_active();
 #ifdef DEBUG_AUDIO
-    {
-       static int prevcon = -1;
-       if ((prevcon & 0xff) != (adkcon & 0xff)) {
-           write_log("ADKCON=%02.2x %08.8X\n", adkcon & 0xff, M68K_GETPC);
-           prevcon = adkcon;
-       }
-    }
+        write_log("ADKCON=%02.2x %08.8X\n", adkcon & 0xff, M68K_GETPC);
 #endif
+       prevcon = adkcon;
+    }
 }
 
 int init_audio (void)
index 2064ea60f882fabc6ccd67efe3e5b5d9592d13d7..ea74b0c4fdd13aad3ffda3887b1240112ec3d816 100755 (executable)
--- a/custom.c
+++ b/custom.c
@@ -4185,7 +4185,6 @@ static void vsync_handler (void)
 
 #ifdef PICASSO96
     /* And now let's update the Picasso palette, if required */
-    DX_SetPalette_vsync();
     if (picasso_on)
        picasso_handle_vsync ();
 #endif
@@ -4282,7 +4281,6 @@ static void hsync_handler (void)
 
     if (!nocustom()) {
        sync_copper_with_cpu (maxhpos, 0);
-        //copper_check (1);
         finish_decisions ();
        if (thisline_decision.plfleft != -1) {
            if (currprefs.collision_level > 1)
index df9586af4175852807125344ece69bba20b675cd..6e4efe5f6a68c0dd67adc183ac420340ed37244a 100755 (executable)
--- a/drawing.c
+++ b/drawing.c
@@ -1881,12 +1881,20 @@ static void draw_status_line (int line)
            if (snd > 99)
                snd = 99;
            pos = 0;
-           on = framecnt;
-           on_rgb = 0xc00;
+           on = gui_data.sndbuf_status;
+           if (on < 3) {
+               num1 = gui_data.sndbuf < 0 ? 15 : 14;
+               num2 = snd / 10;
+               num3 = snd % 10;
+           }
+           on_rgb = 0x000;
+           if (on < 0)
+               on_rgb = 0xc00; // underflow
+           else if (on == 2)
+               on_rgb = 0xcc0; // really big overflow
+           else if (on == 1)
+               on_rgb = 0x00c; // "normal" overflow
            off_rgb = 0x000;
-           num1 = gui_data.sndbuf < 0 ? 15 : 14;
-           num2 = snd / 10;
-           num3 = snd % 10;
            am = 3;
        }
        c = xcolors[on ? on_rgb : off_rgb];
index 3ea5be943bcbbdb76a00f0ee70f05d0a07216a2e..7ff76b76e261f089ab90c73795555a9653d3373d 100755 (executable)
@@ -33,7 +33,8 @@ struct gui_info
     uae_u8 drive_side;             /* floppy side */
     uae_u8 hd;                     /* harddrive */
     uae_u8 cd;                     /* CD */
-    int fps, idle, sndbuf;
+    int fps, idle;
+    int sndbuf, sndbuf_status;
     char df[4][256];               /* inserted image */
     uae_u32 crc32[4];              /* crc32 of image */
 };
index def65d6f4ef6b2888bbb6bc14cb0e2732c42606b..6cd1613b9f4609a5e24743e87922b693cfbe2f43 100755 (executable)
@@ -292,6 +292,9 @@ Section Uninstall
   RMDir "$INSTDIR\SaveImages"
   RMDir "$INSTDIR\SaveStates"
   RMDir "$INSTDIR\ScreenShots"
+  RMDir "$INSTDIR\InputRecordings"
+  RMDir "$INSTDIR\plugins\codecs"
+  RMDir "$INSTDIR\plugins"
 
   RMDir "$SMPROGRAMS\WinUAE"
   RMDir "$INSTDIR\"
diff --git a/od-win32/WinUAE_Install.tmp.nsi b/od-win32/WinUAE_Install.tmp.nsi
deleted file mode 100755 (executable)
index 2d88da3..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-!define PRODUCT_NAME "WinUAE"
-!define PRODUCT_VERSION "1.0"
-!define PRODUCT_PUBLISHER "Toni Wilen"
-!define PRODUCT_WEB_SITE "http://www.winuae.net/"
-!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\winuae.exe"
-!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_ROOT_KEY "HKLM"
-
-;-- Your path here
-!define DISTPATH "e:\projects\winuae\distribution"
-
-SetCompressor lzma
-
-!include "StrFunc.nsh"
-!include "WinMessages.nsh"
-
-; MUI begins ---
-!include "MUI.nsh"
-; MUI Settings
-!define MUI_ABORTWARNING
-!define MUI_COMPONENTSPAGE_SMALLDESC
-;!define MUI_FINISHPAGE_NOAUTOCLOSE
-!define MUI_FINISHPAGE_RUN_NOTCHECKED
-!define MUI_ICON "graphics\installer_icon.ico"
-!define MUI_UNICON "graphics\installer_icon.ico"
-; MUI Bitmaps
-!define MUI_HEADERIMAGE
-!define MUI_HEADERIMAGE_BITMAP "graphics\amiga_header.bmp"
-!define MUI_WELCOMEFINISHPAGE_BITMAP "graphics\amiga_welcome.bmp"
-; Welcome page
-!insertmacro MUI_PAGE_WELCOME
-; Components page
-!insertmacro MUI_PAGE_COMPONENTS
-; Directory page
-!insertmacro MUI_PAGE_DIRECTORY
-; Instfiles page
-!insertmacro MUI_PAGE_INSTFILES
-; Finish page
-!define MUI_FINISHPAGE_RUN "$INSTDIR\winuae.exe"
-!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Docs\Readme.txt"
-!insertmacro MUI_PAGE_FINISH
-; Uninstaller pages
-!insertmacro MUI_UNPAGE_INSTFILES
-; Language files
-!insertmacro MUI_LANGUAGE "English"
-; MUI end ---
-
-Function .onInit
-  ;Find WinUAE Properties Window and close it when it's open
-  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "WinUAE Instantiated") i .r1 ?e'
-  Pop $1
-  StrCmp $1 183 0 Continue
-  MessageBox MB_OK|MB_ICONEXCLAMATION "WinUAE is still running in the background, the installer will terminate it.$\nYou can do this by yourself as well before proceeding with the installation."
-  FindWindow $2 "" "WinUAE Properties"
-  FindWindow $3 "" "WinUAE"
-  SendMessage $2 ${WM_CLOSE} 0 0
-  SendMessage $3 ${WM_CLOSE} 0 0
-
- Continue:
-  ReadRegStr $0 HKCU "Software\Arabuusimiehet\WinUAE" "InstallDir"
-  StrCmp $0 "" No_WinUAE
-  ;Code if WinUAE is installed
-  StrCpy $INSTDIR $0
-  Goto +2
- No_WinUAE:
-  ;Code if WinUAE is not installed
-  StrCpy $INSTDIR "$PROGRAMFILES\WinUAE"
-FunctionEnd
-
-Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-OutFile "InstallWinUAE.exe"
-InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
-ShowInstDetails show
-ShowUnInstDetails show
-
-InstType "Complete" ;1
-InstType "Basic"    ;2
-InstType "Basic with Shortcuts" ;3
-
-Section "WinUAE (required)" secWinUAE_files
-  SectionIn 1 2 3 RO
-  SetOutPath "$INSTDIR\"
-  ;SetOverwrite ifnewer
- ;-- Copy WinUAE and zlib.dll
-  File "${DISTPATH}\zlib1.dll"
-  File "${DISTPATH}\winuae.exe"
-  SetOutPath "$INSTDIR\Docs"
-  File "${DISTPATH}\Docs\Readme.txt"
- ;-- Creates the necessary registry entrys
-  WriteRegStr HKCU "Software\Arabuusimiehet\WinUAE" "InstallDir" "$INSTDIR"
-SectionEnd
-
-Section "Host-Configurations" secExConfig
-  SectionIn 1
-  SetOutPath "$INSTDIR\Configurations\Host"
-  SetOverwrite ifnewer
- ;-- Copy Example Host Configurations
-  File "${DISTPATH}\Configurations\Host\Fullscreen (640x480).uae"
-  File "${DISTPATH}\Configurations\Host\Fullscreen (800x600).uae"
-  File "${DISTPATH}\Configurations\Host\Windowed.uae"
-SectionEnd
-
-SubSection "Additional files" secAdditionalFiles
- Section "Docs" secDocs
-  SectionIn 1
-  SetOutPath "$INSTDIR\Docs"
-  SetOverwrite ifnewer
- ;-- Copy Docs
-  File "${DISTPATH}\Docs\Whatsnew-jit"
-  File "${DISTPATH}\Docs\README.umisef"
-  File "${DISTPATH}\Docs\README.pci"
-  File "${DISTPATH}\Docs\README.JIT-tuning"
-  File "${DISTPATH}\Docs\README.compemu"
-  File "${DISTPATH}\Docs\History_old.txt"
- ;-- Copy Docs for Windows
-  SetOutPath "$INSTDIR\Docs\Windows"
-  File "${DISTPATH}\Docs\Windows\UAEHowTo.txt"
-  File "${DISTPATH}\Docs\Windows\Translation.txt"
-  File "${DISTPATH}\Docs\Windows\AmigaProg.txt"
- SectionEnd
-
- Section "Amiga programs" secAmigaprograms
-  SectionIn 1
-  SetOutPath "$INSTDIR\Amiga Programs"
-  SetOverwrite ifnewer
- ;-- Copy the Amiga Programs
-  File "${DISTPATH}\Amiga Programs\winxpprinthelper.info"
-  File "${DISTPATH}\Amiga Programs\winxpprinthelper"
-  File "${DISTPATH}\Amiga Programs\winuaeenforcer.txt"
-  File "${DISTPATH}\Amiga Programs\winuaeenforcer"
-  File "${DISTPATH}\Amiga Programs\winuaeclip.txt"
-  File "${DISTPATH}\Amiga Programs\winuaeclip.info"
-  File "${DISTPATH}\Amiga Programs\winuaeclip"
-  File "${DISTPATH}\Amiga Programs\uaectrl"
-  File "${DISTPATH}\Amiga Programs\uae-control.info"
-  File "${DISTPATH}\Amiga Programs\uae-control"
-  File "${DISTPATH}\Amiga Programs\uae-configuration"
-  File "${DISTPATH}\Amiga Programs\uae-configuration.s"
-  File "${DISTPATH}\Amiga Programs\uae-configuration.c"
-  File "${DISTPATH}\Amiga Programs\uae_rcli"
-  File "${DISTPATH}\Amiga Programs\UAE_German.info"
-  File "${DISTPATH}\Amiga Programs\UAE_German"
-  File "${DISTPATH}\Amiga Programs\transrom"
-  File "${DISTPATH}\Amiga Programs\transdisk"
-  File "${DISTPATH}\Amiga Programs\timehack"
-  File "${DISTPATH}\Amiga Programs\rtg.library"
-  File "${DISTPATH}\Amiga Programs\picasso96fix.bb"
-  File "${DISTPATH}\Amiga Programs\picasso96fix"
-  File "${DISTPATH}\Amiga Programs\p96refresh.ab2"
-  File "${DISTPATH}\Amiga Programs\p96refresh"
-  File "${DISTPATH}\Amiga Programs\p96_uae_tweak"
-  File "${DISTPATH}\Amiga Programs\mousehack"
-  File "${DISTPATH}\Amiga Programs\german_KeyMap_new.zip"
-  File "${DISTPATH}\Amiga Programs\amigaprog.txt"
-  File "${DISTPATH}\Amiga Programs\ahidriver.zip"
- SectionEnd
-SubSectionEnd
-
-#SubSection "Translations" secTranslations
-# Section "German" secTransGerman
-#  SectionIn 1
-#  SetOutPath "$INSTDIR\"
-#  File "${DISTPATH}\WinUAE_German.dll"
-# SectionEnd
-; Section "Foo" secTransFoo
-;  SectionIn 1
-;  SetOutPath "$INSTDIR\"
-;  File "${DISTPATH}\WinUAE_Foo.dll"
-; SectionEnd
-SubSectionEnd
-
-SubSection "Shortcuts" secShortcuts
- Section "Startmenu" secStartmenu
-  SectionIn 1 3
-  CreateDirectory "$SMPROGRAMS\WinUAE"
-  CreateShortCut "$SMPROGRAMS\WinUAE\WinUAE.lnk" "$INSTDIR\winuae.exe"
-  CreateShortCut "$SMPROGRAMS\WinUAE\ReadMe.lnk" "$INSTDIR\Docs\Readme.txt"
-  CreateShortCut "$SMPROGRAMS\WinUAE\Uninstall.lnk" "$INSTDIR\uninstall_winuae.exe"
- SectionEnd
-
- Section "Desktop" secDesktop
-  SectionIn 1 3
-  CreateShortCut "$DESKTOP\WinUAE.lnk" "$INSTDIR\winuae.exe"
- SectionEnd
-
- Section "Quick Launch" secQuickLaunch
-  SectionIn 1 3
-  CreateShortcut "$QUICKLAUNCH\WinUAE.lnk" "$INSTDIR\winuae.exe"
- SectionEnd
-SubSectionend
-
-Section -Post
-  WriteUninstaller "$INSTDIR\uninstall_winuae.exe"
-  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\winuae.exe"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall_winuae.exe"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\winuae.exe"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
-SectionEnd
-
-; Section descriptions
-!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
-  !insertmacro MUI_DESCRIPTION_TEXT ${secWinUAE_files} "WinUAE (WinUAE.exe, zlib1.dll, readme.txt)"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secExConfig} "Example Host-Configurations"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secAdditionalFiles} "Additional files (Docs, Amiga programs)"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secAmigaprograms} "Amiga programs"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secDocs} "Documentation"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secShortcuts} "Shortcuts (Startmenu, Desktop, Quick Launch)"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secStartmenu} "Create a startmenu entry"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secDesktop} "Create a desktop icon"
-  !insertmacro MUI_DESCRIPTION_TEXT ${secQuickLaunch} "Create a Quick Launch icon"
-;  !insertmacro MUI_DESCRIPTION_TEXT ${secTranslations} "WinUAE Translations"
-!insertmacro MUI_FUNCTION_DESCRIPTION_END
-
-
-Function un.onUninstSuccess
-  HideWindow
-  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
-FunctionEnd
-
-Function un.onInit
-  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
-  Abort
-FunctionEnd
-
-Section Uninstall
-  Delete "$INSTDIR\uninstall_winuae.exe"
-  Delete "$INSTDIR\Docs\Windows\AmigaProg.txt"
-  Delete "$INSTDIR\Docs\Windows\Translation.txt"
-  Delete "$INSTDIR\Docs\Windows\UAEHowTo.txt"
-  Delete "$INSTDIR\Docs\History_old.txt"
-  Delete "$INSTDIR\Docs\README.compemu"
-  Delete "$INSTDIR\Docs\README.JIT-tuning"
-  Delete "$INSTDIR\Docs\README.pci"
-  Delete "$INSTDIR\Docs\Readme.txt"
-  Delete "$INSTDIR\Docs\Readme.txt.bak"
-  Delete "$INSTDIR\Docs\README.umisef"
-  Delete "$INSTDIR\Docs\Whatsnew-jit"
-  Delete "$INSTDIR\Amiga Programs\ahidriver.zip"
-  Delete "$INSTDIR\Amiga Programs\amigaprog.txt"
-  Delete "$INSTDIR\Amiga Programs\german_KeyMap_new.zip"
-  Delete "$INSTDIR\Amiga Programs\mousehack"
-  Delete "$INSTDIR\Amiga Programs\p96_uae_tweak"
-  Delete "$INSTDIR\Amiga Programs\p96refresh"
-  Delete "$INSTDIR\Amiga Programs\p96refresh.ab2"
-  Delete "$INSTDIR\Amiga Programs\picasso96fix"
-  Delete "$INSTDIR\Amiga Programs\picasso96fix.bb"
-  Delete "$INSTDIR\Amiga Programs\rtg.library"
-  Delete "$INSTDIR\Amiga Programs\timehack"
-  Delete "$INSTDIR\Amiga Programs\transdisk"
-  Delete "$INSTDIR\Amiga Programs\transrom"
-  Delete "$INSTDIR\Amiga Programs\UAE_German"
-  Delete "$INSTDIR\Amiga Programs\UAE_German.info"
-  Delete "$INSTDIR\Amiga Programs\uae_rcli"
-  Delete "$INSTDIR\Amiga Programs\uae-configuration"
-  Delete "$INSTDIR\Amiga Programs\uae-configuration.s"
-  Delete "$INSTDIR\Amiga Programs\uae-configuration.c"
-  Delete "$INSTDIR\Amiga Programs\uae-control"
-  Delete "$INSTDIR\Amiga Programs\uae-control.info"
-  Delete "$INSTDIR\Amiga Programs\uaectrl"
-  Delete "$INSTDIR\Amiga Programs\winuaeclip"
-  Delete "$INSTDIR\Amiga Programs\winuaeclip.info"
-  Delete "$INSTDIR\Amiga Programs\winuaeclip.txt"
-  Delete "$INSTDIR\Amiga Programs\winuaeenforcer"
-  Delete "$INSTDIR\Amiga Programs\winuaeenforcer.txt"
-  Delete "$INSTDIR\Amiga Programs\winxpprinthelper"
-  Delete "$INSTDIR\Amiga Programs\winxpprinthelper.info"
-  Delete "$INSTDIR\Configurations\Host\Fullscreen (640x480).uae"
-  Delete "$INSTDIR\Configurations\Host\Fullscreen (800x600).uae"
-  Delete "$INSTDIR\Configurations\Host\Windowed.uae"
-  Delete "$INSTDIR\winuaebootlog.txt"
-  Delete "$INSTDIR\winuaelog.txt"
-  Delete "$INSTDIR\winuae.exe"
-  Delete "$INSTDIR\zlib1.dll"
-  Delete "$INSTDIR\WinUAE_German.dll"
-
-  Delete "$SMPROGRAMS\WinUAE\Uninstall.lnk"
-  Delete "$SMPROGRAMS\WinUAE\WinUAE.lnk"
-  Delete "$SMPROGRAMS\WinUAE\ReadMe.lnk"
-  Delete "$DESKTOP\WinUAE.lnk"
-  Delete "$QUICKLAUNCH\WinUAE.lnk"
-
-  RMDir "$INSTDIR\Docs\Windows"
-  RMDir "$INSTDIR\Docs"
-  RMDir "$INSTDIR\Amiga Programs"
-  RMDir "$INSTDIR\Configurations\Host"
-  RMDir "$INSTDIR\Configurations\Hardware"
-  RMDir "$INSTDIR\Configurations"
-  RMDir "$INSTDIR\Roms"
-  RMDir "$INSTDIR\SaveImages"
-  RMDir "$INSTDIR\SaveStates"
-  RMDir "$INSTDIR\ScreenShots"
-
-  RMDir "$SMPROGRAMS\WinUAE"
-  RMDir "$INSTDIR\"
-  RMDir ""
-
-  DeleteRegKey HKCU "Software\Arabuusimiehet"
-  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
-  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
-  SetAutoClose true
-SectionEnd
index 01f6cb4160a8cc1c158b120d227b5b7c76ef9f4b..93f9cb6c776d68e95a1f281b0e8aff93e0f21aff 100755 (executable)
@@ -306,34 +306,34 @@ static int LockStub( surface_type_e type )
  *   1999.08.02  Brian King             Creation
  *
  */
-int DirectDraw_SurfaceLock( surface_type_e surface_type )
+int DirectDraw_SurfaceLock(surface_type_e surface_type)
 {
     int result = 0;
 
-    if( surface_type == lockable_surface )
+    if (surface_type == lockable_surface)
        surface_type = DirectDraw_GetLockableType();
 
     switch( surface_type )
     {
        case primary_surface:
-           DirectDrawState.primary.desc.dwSize = sizeof( DDSURFACEDESC2 );
-           result = LockStub( surface_type );
+           DirectDrawState.primary.desc.dwSize = sizeof(DDSURFACEDESC2);
+           result = LockStub(surface_type);
        break;
        case secondary_surface:
-           DirectDrawState.secondary.desc.dwSize = sizeof( DDSURFACEDESC2 );
-           result = LockStub( surface_type );
+           DirectDrawState.secondary.desc.dwSize = sizeof(DDSURFACEDESC2);
+           result = LockStub(surface_type);
        break;
        case tertiary_surface:
-           DirectDrawState.tertiary.desc.dwSize = sizeof( DDSURFACEDESC2 );
-           result = LockStub( surface_type );
+           DirectDrawState.tertiary.desc.dwSize = sizeof(DDSURFACEDESC2);
+           result = LockStub(surface_type);
        break;
        case temporary_surface:
-           DirectDrawState.temporary.desc.dwSize = sizeof( DDSURFACEDESC2 );
-           result = LockStub( surface_type );
+           DirectDrawState.temporary.desc.dwSize = sizeof(DDSURFACEDESC2);
+           result = LockStub(surface_type);
        break;
        case overlay_surface:
-           DirectDrawState.overlay.desc.dwSize = sizeof( DDSURFACEDESC2 );
-           result = LockStub( surface_type );
+           DirectDrawState.overlay.desc.dwSize = sizeof(DDSURFACEDESC2);
+           result = LockStub(surface_type);
        case lockable_surface:
        case invalid_surface:
        default:
@@ -360,15 +360,13 @@ int DirectDraw_SurfaceLock( surface_type_e surface_type )
  *   1999.08.02  Brian King             Creation
  *
  */
-char *DirectDraw_GetSurfacePointer( void )
+char *DirectDraw_GetSurfacePointer(void)
 {
     char *pixels = NULL;
 
     /* Make sure that somebody has done a lock before returning the lpSurface member */
     if(lockcnt)
-    {
        pixels = DirectDrawState.lockable.lpdesc->lpSurface;
-    }
     return pixels;
 }
 
@@ -387,7 +385,7 @@ char *DirectDraw_GetSurfacePointer( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-LONG DirectDraw_GetSurfacePitch( void )
+LONG DirectDraw_GetSurfacePitch(void)
 {
     LONG pitch = 0;
 
@@ -410,7 +408,7 @@ LONG DirectDraw_GetSurfacePitch( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_GetPixelFormatFlags( void )
+DWORD DirectDraw_GetPixelFormatFlags(void)
 {
     DWORD flags = 0;
     flags = DirectDrawState.lockable.lpdesc->ddpfPixelFormat.dwFlags;
@@ -432,7 +430,7 @@ DWORD DirectDraw_GetPixelFormatFlags( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_GetSurfaceFlags( void )
+DWORD DirectDraw_GetSurfaceFlags(void)
 {
     DWORD flags = 0;
     flags = DirectDrawState.lockable.lpdesc->dwFlags;
@@ -454,11 +452,11 @@ DWORD DirectDraw_GetSurfaceFlags( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_GetSurfaceBitCount( void )
+DWORD DirectDraw_GetSurfaceBitCount(void)
 {
     DWORD bits = 0;
     //?????JGI begin:
-    if( DirectDrawState.lockable.lpdesc )
+    if(DirectDrawState.lockable.lpdesc)
        bits = DirectDrawState.lockable.lpdesc->ddpfPixelFormat.dwRGBBitCount;
     else
        bits = DirectDrawState.current.desc.ddpfPixelFormat.dwRGBBitCount;
@@ -481,7 +479,7 @@ DWORD DirectDraw_GetSurfaceBitCount( void )
  *   2001.08.25  Brian King             Creation
  *
  */
-DWORD DirectDraw_GetPrimaryBitCount( void )
+DWORD DirectDraw_GetPrimaryBitCount(void)
 {
     DWORD bits = 0;
     memset(&DirectDrawState.primary.desc,0,sizeof(DirectDrawState.primary.desc));
@@ -517,10 +515,10 @@ void DirectDraw_GetPrimaryWidthHeight(int *w, int *h)
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_GetPixelFormatBitMask( DirectDraw_Mask_e mask )
+DWORD DirectDraw_GetPixelFormatBitMask(DirectDraw_Mask_e mask)
 {
     DWORD result = 0;
-    switch( mask )
+    switch(mask)
     {
        case red_mask:
            result = DirectDrawState.lockable.lpdesc->ddpfPixelFormat.dwRBitMask;
@@ -550,7 +548,7 @@ DWORD DirectDraw_GetPixelFormatBitMask( DirectDraw_Mask_e mask )
  *   1999.08.02  Brian King             Creation
  *
  */
-surface_type_e DirectDraw_GetLockableType( void )
+surface_type_e DirectDraw_GetLockableType(void)
 {
     return DirectDrawState.surface_type;
 }
@@ -570,7 +568,7 @@ surface_type_e DirectDraw_GetLockableType( void )
  *   2000.04.30  Brian King             Creation
  *
  */
-BOOL DirectDraw_IsLocked( void )
+BOOL DirectDraw_IsLocked(void)
 {
     return DirectDrawState.locked ? TRUE : FALSE;
 }
@@ -590,34 +588,34 @@ BOOL DirectDraw_IsLocked( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-static surface_type_e try_surface_locks( int want_fullscreen )
+static surface_type_e try_surface_locks(int want_fullscreen)
 {
     surface_type_e result = invalid_surface;
 
-    if( DirectDrawState.isoverlay && DirectDraw_SurfaceLock( overlay_surface ) )
+    if(DirectDrawState.isoverlay && DirectDraw_SurfaceLock(overlay_surface))
     {
        result = overlay_surface;
-       write_log( "try_surface_locks() returning overlay\n" );
+       write_log("try_surface_locks() returning overlay\n");
     }
-    else if( want_fullscreen && WIN32GFX_IsPicassoScreen() )
+    else if(want_fullscreen && WIN32GFX_IsPicassoScreen())
     {
-       if( DirectDraw_SurfaceLock( primary_surface ) )
+       if(DirectDraw_SurfaceLock(primary_surface))
        {
            result = primary_surface;
-           write_log( "try_surface_locks() returning primary\n" );
+           write_log("try_surface_locks() returning primary\n");
        }
-       else if( DirectDraw_SurfaceLock( secondary_surface ) )
+       else if(DirectDraw_SurfaceLock(secondary_surface))
        {
            result = secondary_surface;
-           write_log( "try_surface_locks() returning secondary\n" );
+           write_log("try_surface_locks() returning secondary\n");
        }
     }
     else
     {
-       if( DirectDraw_SurfaceLock( secondary_surface ) )
+       if(DirectDraw_SurfaceLock(secondary_surface))
        {
            result = secondary_surface;
-           write_log( "try_surface_locks() returning secondary\n" );
+           write_log("try_surface_locks() returning secondary\n");
        }
     }
 
@@ -639,13 +637,12 @@ static surface_type_e try_surface_locks( int want_fullscreen )
  *   1999.08.02  Brian King             Creation
  *
  */
-void ddraw_unlockscr( void )
+void ddraw_unlockscr(void)
 {
-    if( lockcnt > 0 )
-    {
+    if(lockcnt > 0) {
        lockcnt--;
-       IDirectDrawSurface7_Unlock( DirectDrawState.lockable.surface,
-                                   DirectDrawState.lockable.lpdesc->lpSurface );
+       IDirectDrawSurface7_Unlock(DirectDrawState.lockable.surface,
+                                   DirectDrawState.lockable.lpdesc->lpSurface);
        DirectDrawState.locked = FALSE;
     }
 }
@@ -665,7 +662,7 @@ void ddraw_unlockscr( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-int DirectDraw_Start( GUID *guid )
+int DirectDraw_Start(GUID *guid)
 {
     HRESULT ddrval;
     /* Prepare our DirectDrawState structure */
@@ -685,8 +682,7 @@ int DirectDraw_Start( GUID *guid )
     DirectDrawState.initialized = TRUE;
 
     ddrval = IDirectDraw_QueryInterface(DirectDrawState.directdraw.ddx,
-                                        &IID_IDirectDraw7,
-                                        (LPVOID *)&DirectDrawState.directdraw.dd);
+               &IID_IDirectDraw7, (LPVOID *)&DirectDrawState.directdraw.dd);
     if(FAILED(ddrval)) {
        gui_message("start_ddraw(): DirectX 7 or newer required");
        DirectDraw_Release();
@@ -726,25 +722,24 @@ int DirectDraw_Start( GUID *guid )
  *   1999.08.02  Brian King             Creation
  *
  */
-void DirectDraw_Release( void )
+void DirectDraw_Release(void)
 {
-    releaser( DirectDrawState.lpDDC, IDirectDrawClipper_Release );
-    releaser( DirectDrawState.lpDDP, IDirectDrawPalette_Release );
+    releaser(DirectDrawState.lpDDC, IDirectDrawClipper_Release);
+    releaser(DirectDrawState.lpDDP, IDirectDrawPalette_Release);
 
-    if (DirectDrawState.directdraw.dd && DirectDrawState.modeset)
-    {
-       IDirectDraw7_SetCooperativeLevel( DirectDrawState.directdraw.dd, hAmigaWnd, DDSCL_NORMAL);
-       IDirectDraw7_RestoreDisplayMode( DirectDrawState.directdraw.dd );
+    if (DirectDrawState.directdraw.dd && DirectDrawState.modeset) {
+       IDirectDraw7_SetCooperativeLevel(DirectDrawState.directdraw.dd, hAmigaWnd, DDSCL_NORMAL);
+       IDirectDraw7_RestoreDisplayMode(DirectDrawState.directdraw.dd);
     }
     DirectDrawState.modeset = 0;
 
-    releaser( DirectDrawState.overlay.surface, IDirectDrawSurface7_Release );
-    releaser( DirectDrawState.primary.surface, IDirectDrawSurface7_Release );
+    releaser(DirectDrawState.overlay.surface, IDirectDrawSurface7_Release);
+    releaser(DirectDrawState.primary.surface, IDirectDrawSurface7_Release);
 
-    if( DirectDrawState.flipping == single_buffer)
-       releaser( DirectDrawState.secondary.surface, IDirectDrawSurface7_Release );
+    if(DirectDrawState.flipping == single_buffer)
+       releaser(DirectDrawState.secondary.surface, IDirectDrawSurface7_Release);
 
-    releaser( DirectDrawState.directdraw.dd, IDirectDraw_Release );
+    releaser(DirectDrawState.directdraw.dd, IDirectDraw_Release);
 
     DirectDrawState.lockable.lpdesc = NULL;
     DirectDrawState.lockable.lpdesc = NULL;
@@ -773,14 +768,13 @@ void DirectDraw_Release( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_SetCooperativeLevel( HWND window, int want_fullscreen )
+HRESULT DirectDraw_SetCooperativeLevel(HWND window, int want_fullscreen)
 {
     HRESULT ddrval;
 
-    ddrval = IDirectDraw7_SetCooperativeLevel( DirectDrawState.directdraw.dd,
-       window,
-       want_fullscreen ?
-       DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL );
+    ddrval = IDirectDraw7_SetCooperativeLevel(DirectDrawState.directdraw.dd,
+       window, want_fullscreen ?
+       DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL);
     if(SUCCEEDED(ddrval)) {
        DirectDrawState.fullscreen = want_fullscreen;
        DirectDrawState.window = window;
@@ -805,12 +799,11 @@ HRESULT DirectDraw_SetCooperativeLevel( HWND window, int want_fullscreen )
  *   1999.08.02  Brian King             Creation
  *
  */
-BOOL DirectDraw_GetCooperativeLevel( HWND *window, int *fullscreen )
+BOOL DirectDraw_GetCooperativeLevel(HWND *window, int *fullscreen)
 {
     BOOL result = FALSE;
 
-    if( DirectDrawState.initialized )
-    {
+    if(DirectDrawState.initialized) {
        *fullscreen = DirectDrawState.fullscreen;
        *window = DirectDrawState.window;
        result = TRUE;
@@ -838,12 +831,12 @@ BOOL DirectDraw_GetCooperativeLevel( HWND *window, int *fullscreen )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_SetDisplayMode( int width, int height, int bits, int freq )
+HRESULT DirectDraw_SetDisplayMode(int width, int height, int bits, int freq)
 {
     HRESULT ddrval;
 
-    ddrval = IDirectDraw7_SetDisplayMode( DirectDrawState.directdraw.dd,
-       width, height, bits, freq, 0 );
+    ddrval = IDirectDraw7_SetDisplayMode(DirectDrawState.directdraw.dd,
+       width, height, bits, freq, 0);
     DirectDrawState.modeset = 1;
     return ddrval;
 }
@@ -864,14 +857,14 @@ HRESULT DirectDraw_SetDisplayMode( int width, int height, int bits, int freq )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_GetDisplayMode( void )
+HRESULT DirectDraw_GetDisplayMode(void)
 {
     HRESULT ddrval;
 
     /* We fill in the current.desc in all cases */
-    DirectDrawState.current.desc.dwSize = sizeof( DDSURFACEDESC2 );
-    ddrval = IDirectDraw7_GetDisplayMode( DirectDrawState.directdraw.dd,
-       &DirectDrawState.current.desc );
+    DirectDrawState.current.desc.dwSize = sizeof(DDSURFACEDESC2);
+    ddrval = IDirectDraw7_GetDisplayMode(DirectDrawState.directdraw.dd,
+       &DirectDrawState.current.desc);
     return ddrval;
 }
 
@@ -890,12 +883,12 @@ HRESULT DirectDraw_GetDisplayMode( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_GetCaps( DDCAPS_DX7 *driver_caps, DDCAPS_DX7 *hel_caps )
+HRESULT DirectDraw_GetCaps(DDCAPS_DX7 *driver_caps, DDCAPS_DX7 *hel_caps)
 {
     HRESULT ddrval;
 
-    ddrval = IDirectDraw7_GetCaps( DirectDrawState.directdraw.dd,
-       driver_caps, hel_caps );
+    ddrval = IDirectDraw7_GetCaps(DirectDrawState.directdraw.dd,
+       driver_caps, hel_caps);
     return ddrval;
 }
 
@@ -914,15 +907,15 @@ HRESULT DirectDraw_GetCaps( DDCAPS_DX7 *driver_caps, DDCAPS_DX7 *hel_caps )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_CreateClipper( void )
+HRESULT DirectDraw_CreateClipper(void)
 {
     HRESULT ddrval;
-    ddrval = IDirectDraw7_CreateClipper( DirectDrawState.directdraw.dd,
-       0, &DirectDrawState.lpDDC, NULL );
+    ddrval = IDirectDraw7_CreateClipper(DirectDrawState.directdraw.dd,
+       0, &DirectDrawState.lpDDC, NULL);
     return ddrval;
 }
 
-static DWORD ConvertGDIColor( COLORREF dwGDIColor )
+static DWORD ConvertGDIColor(COLORREF dwGDIColor)
 {
     COLORREF rgbT;
     HDC hdc;
@@ -936,8 +929,7 @@ static DWORD ConvertGDIColor( COLORREF dwGDIColor )
     IDirectDrawSurface7_GetSurfaceDesc(DirectDrawState.primary.surface, &pdds);
 
     //  Use GDI SetPixel to color match for us
-    if(dwGDIColor != CLR_INVALID && SUCCEEDED(IDirectDrawSurface7_GetDC(DirectDrawState.primary.surface, &hdc)))
-    {
+    if(dwGDIColor != CLR_INVALID && SUCCEEDED(IDirectDrawSurface7_GetDC(DirectDrawState.primary.surface, &hdc))) {
        rgbT = GetPixel(hdc, 0, 0);     // Save current pixel value
        SetPixel(hdc, 0, 0, dwGDIColor);       // Set our value
        IDirectDrawSurface7_ReleaseDC(DirectDrawState.primary.surface,hdc);
@@ -946,21 +938,19 @@ static DWORD ConvertGDIColor( COLORREF dwGDIColor )
     // Now lock the surface so we can read back the converted color
     ddsd.dwSize = sizeof(ddsd);
     hr = IDirectDrawSurface7_Lock(DirectDrawState.primary.surface, NULL, &ddsd, DDLOCK_WAIT, NULL );
-    if(SUCCEEDED(hr))
-    {
+    if(SUCCEEDED(hr)) {
        dw = *(DWORD *) ddsd.lpSurface; 
-       if( ddsd.ddpfPixelFormat.dwRGBBitCount < 32 ) // Mask it to bpp
-           dw &= ( 1 << ddsd.ddpfPixelFormat.dwRGBBitCount ) - 1;
+       if(ddsd.ddpfPixelFormat.dwRGBBitCount < 32) // Mask it to bpp
+           dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount) - 1;
        IDirectDrawSurface7_Unlock(DirectDrawState.primary.surface,NULL);
     }
 
     //  Now put the color that was there back.
-    if(dwGDIColor != CLR_INVALID && SUCCEEDED(IDirectDrawSurface7_GetDC(DirectDrawState.primary.surface,&hdc)))
-    {
-       SetPixel( hdc, 0, 0, rgbT );
+    if(dwGDIColor != CLR_INVALID && SUCCEEDED(IDirectDrawSurface7_GetDC(DirectDrawState.primary.surface,&hdc))) {
+       SetPixel(hdc, 0, 0, rgbT);
        IDirectDrawSurface7_ReleaseDC(DirectDrawState.primary.surface,hdc);
     }
-    
+
     return dw;    
 }
 
@@ -1050,23 +1040,21 @@ HRESULT DirectDraw_CreateOverlaySurface(int width, int height, int bits, int typ
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_CreateSurface( int width, int height )
+HRESULT DirectDraw_CreateSurface(int width, int height)
 {
     HRESULT ddrval;
+    DWORD xtraflag = 0;
 
     DirectDrawState.flipping = single_buffer;
 
-    if (DirectDrawState.fullscreen) // Create a flipping pair!
-    {
+    if (DirectDrawState.fullscreen) { // Create a flipping pair!
        ZeroMemory (&DirectDrawState.primary.desc, sizeof(DDSURFACEDESC2));
        DirectDrawState.primary.desc.dwSize = sizeof (DDSURFACEDESC2);
        DirectDrawState.primary.desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
        DirectDrawState.primary.desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
        DirectDrawState.primary.desc.dwBackBufferCount = 2;
        ddrval = IDirectDraw7_CreateSurface(DirectDrawState.directdraw.dd, 
-                                           &DirectDrawState.primary.desc,
-                                           &DirectDrawState.primary.surface,
-                                           NULL);
+                   &DirectDrawState.primary.desc, &DirectDrawState.primary.surface, NULL);
        if (FAILED(ddrval)) {
            // Create a non-flipping pair, since the flipping pair creation failed...
            ZeroMemory (&DirectDrawState.primary.desc, sizeof(DDSURFACEDESC2));
@@ -1088,127 +1076,66 @@ HRESULT DirectDraw_CreateSurface( int width, int height )
        DirectDrawState.primary.desc.dwFlags = DDSD_CAPS;
        DirectDrawState.primary.desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
        ddrval = IDirectDraw7_CreateSurface(DirectDrawState.directdraw.dd, 
-                                           &DirectDrawState.primary.desc,
-                                           &DirectDrawState.primary.surface,
-                                           NULL);
+                       &DirectDrawState.primary.desc, &DirectDrawState.primary.surface, NULL);
     }
 
-    if(FAILED(ddrval)) {
-       goto out;
-    } else
-    {
-       write_log( "DDRAW: Primary %ssurface created in video-memory\n", DirectDrawState.flipping != single_buffer ? "flipping " : "" );
-    }
+    if(FAILED(ddrval))
+       goto errout;
+    else
+       write_log( "DDRAW: Primary %ssurface created in video-memory\n",
+           DirectDrawState.flipping != single_buffer ? "flipping " : "");
 
     // Check if we can access the back-buffer of our flipping-pair (if present)
-    if( DirectDrawState.flipping != single_buffer )
-    {
+    if(DirectDrawState.flipping != single_buffer) {
        DDSCAPS2 ddSCaps;
        ZeroMemory(&ddSCaps, sizeof(ddSCaps));
        ddSCaps.dwCaps = DDSCAPS_BACKBUFFER;
 
-       ddrval = IDirectDrawSurface7_GetAttachedSurface( DirectDrawState.primary.surface, &ddSCaps, &DirectDrawState.secondary.surface );
-       if(SUCCEEDED(ddrval))
-       {
+       ddrval = IDirectDrawSurface7_GetAttachedSurface(DirectDrawState.primary.surface, &ddSCaps, &DirectDrawState.secondary.surface);
+       if(SUCCEEDED(ddrval)) {
            /* get third buffer */
            ZeroMemory(&ddSCaps, sizeof(ddSCaps));
            ddSCaps.dwCaps = DDSCAPS_FLIP;
 
-           ddrval = IDirectDrawSurface7_GetAttachedSurface( DirectDrawState.secondary.surface, &ddSCaps, &DirectDrawState.tertiary.surface );
-           if(SUCCEEDED(ddrval))
-           {
+           ddrval = IDirectDrawSurface7_GetAttachedSurface(DirectDrawState.secondary.surface, &ddSCaps, &DirectDrawState.tertiary.surface);
+           if(SUCCEEDED(ddrval)) {
                clearsurface (tertiary_surface);
-    #if 0
-               // Get our IDirectDrawSurface7 pointer
-               ddrval = IDirectDrawSurface7_QueryInterface( DirectDrawState.tertiary.surface,
-                                                           &IID_IDirectDrawSurface7,
-                                                           (LPVOID *)&DirectDrawState.tertiary.surface );
-               if(FAILED(ddrval))
-               {
-                   goto out;
-               }
-    #endif
-           }
-           else
-           {
+           } else {
                DirectDrawState.flipping = single_buffer;
            }
-    #if 0
-           // Get our IDirectDrawSurface7 pointer
-           ddrval = IDirectDrawSurface_QueryInterface( DirectDrawState.secondary.surface,
-                                                       &IID_IDirectDrawSurface7,
-                                                       (LPVOID *)&DirectDrawState.secondary.surface );
-           if(FAILED(ddrval))
-           {
-               goto out;
-           }
-#endif
-       }
-       else
-       {
+       } else {
            DirectDrawState.flipping = single_buffer;
        }
     }
 
-#if 0
-    // Get our IDirectDrawSurface7 pointer
-    ddrval = IDirectDrawSurface7_QueryInterface( DirectDrawState.primary.surface,
-                                               &IID_IDirectDrawSurface7,
-                                               (LPVOID *)&DirectDrawState.primary.surface );
-
-    if(FAILED(ddrval))
-    {
-       goto out;
-    }
-#endif
-
     // We always want a secondary-buffer when creating our primary-surface.  If we're a flipping pair,
     // the secondary buffer is already allocated.  If we failed to create a flipping pair, or because
     // we're not full-screen, then lets create ourselves a back-buffer manually.
-    if( DirectDrawState.flipping == single_buffer )
-    {
-       ZeroMemory( &DirectDrawState.secondary.desc, sizeof( DDSURFACEDESC2 ) );
-       DirectDrawState.secondary.desc.dwSize = sizeof( DDSURFACEDESC2 );
+    if(DirectDrawState.flipping == single_buffer) {
+       ZeroMemory(&DirectDrawState.secondary.desc, sizeof(DDSURFACEDESC2));
+       DirectDrawState.secondary.desc.dwSize = sizeof(DDSURFACEDESC2);
        DirectDrawState.secondary.desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
-       DirectDrawState.secondary.desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+       DirectDrawState.secondary.desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | xtraflag;
        DirectDrawState.secondary.desc.dwWidth = width;
        DirectDrawState.secondary.desc.dwHeight = height;
-       ddrval = IDirectDraw7_CreateSurface( DirectDrawState.directdraw.dd, 
-                                           &DirectDrawState.secondary.desc,
-                                           &DirectDrawState.secondary.surface,
-                                           NULL );
-       if(FAILED(ddrval))
-       {
+       ddrval = IDirectDraw7_CreateSurface(DirectDrawState.directdraw.dd, 
+                       &DirectDrawState.secondary.desc, &DirectDrawState.secondary.surface, NULL);
+       if(FAILED(ddrval)) {
            write_log( "DDRAW:Secondary surface creation attempt #1 failed with %s\n", DXError(ddrval));
-           DirectDrawState.secondary.desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
-           ddrval = IDirectDraw7_CreateSurface( DirectDrawState.directdraw.dd, 
-                                               &DirectDrawState.secondary.desc,
-                                               &DirectDrawState.secondary.surface,
-                                               NULL );
+           DirectDrawState.secondary.desc.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
+           DirectDrawState.secondary.desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
+           ddrval = IDirectDraw7_CreateSurface(DirectDrawState.directdraw.dd, 
+                       &DirectDrawState.secondary.desc, &DirectDrawState.secondary.surface, NULL);
            if(SUCCEEDED(ddrval))
-               write_log( "DDRAW: Secondary surface created in plain system-memory\n" );
+               write_log("DDRAW: Secondary surface created in plain system-memory\n");
            else
-           {
-               goto out;
-           }
-       }
-       else
-       {
-           write_log( "DDRAW: Secondary surface created in video-memory\n" );
-       }
-#if 0
-       // Get our IDirectDrawSurface7 pointer
-       ddrval = IDirectDrawSurface7_QueryInterface( DirectDrawState.secondary.surface,
-                                                   &IID_IDirectDrawSurface7,
-                                                   (LPVOID *)&DirectDrawState.secondary.surface );
-       if(FAILED(ddrval))
-       {
-           goto out;
+               goto errout;
+       } else {
+           write_log("DDRAW: Secondary surface created in video-memory\n");
        }
-#endif
     }
-out:
     DirectDraw_ClearSurfaces ();
+errout:
     return ddrval;
 }
 
@@ -1231,7 +1158,7 @@ int DirectDraw_DetermineLocking( int wantfull )
 {
     int result = 0;
 
-    switch( DirectDrawState.surface_type = try_surface_locks( wantfull ) )
+    switch(DirectDrawState.surface_type = try_surface_locks(wantfull))
     {
     case invalid_surface:
     case lockable_surface:
@@ -1239,7 +1166,7 @@ int DirectDraw_DetermineLocking( int wantfull )
        DirectDrawState.lockable.lpdesc = NULL;
        DirectDrawState.lockable.surface = NULL;
        DirectDrawState.lockable.surface = NULL;
-       write_log( "set_ddraw: Couldn't lock primary, and no secondary available.\n" );
+       write_log("set_ddraw: Couldn't lock primary, and no secondary available.\n");
        break;
     case primary_surface:
        DirectDrawState.lockable.lpdesc = &DirectDrawState.primary.desc;
@@ -1271,7 +1198,7 @@ int DirectDraw_DetermineLocking( int wantfull )
        break;
     }
 
-    if( DirectDrawState.lockable.surface )
+    if(DirectDrawState.lockable.surface)
        DirectDraw_SurfaceUnlock();
 
     return result;
@@ -1292,16 +1219,14 @@ int DirectDraw_DetermineLocking( int wantfull )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_SetClipper( HWND hWnd )
+HRESULT DirectDraw_SetClipper(HWND hWnd)
 {
     HRESULT ddrval;
 
-    ddrval = IDirectDrawSurface7_SetClipper( DirectDrawState.primary.surface,
-       hWnd ? DirectDrawState.lpDDC : NULL );
-    if( hWnd && SUCCEEDED(ddrval))
-    {
-       ddrval = IDirectDrawClipper_SetHWnd( DirectDrawState.lpDDC, 0, hWnd );
-    }
+    ddrval = IDirectDrawSurface7_SetClipper(DirectDrawState.primary.surface,
+       hWnd ? DirectDrawState.lpDDC : NULL);
+    if(hWnd && SUCCEEDED(ddrval))
+       ddrval = IDirectDrawClipper_SetHWnd(DirectDrawState.lpDDC, 0, hWnd);
     return ddrval;
 }
 
@@ -1320,11 +1245,11 @@ HRESULT DirectDraw_SetClipper( HWND hWnd )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_GetClipList( LPRGNDATA cliplist, LPDWORD size )
+HRESULT DirectDraw_GetClipList(LPRGNDATA cliplist, LPDWORD size)
 {
     HRESULT ddrval;
 
-    ddrval = IDirectDrawClipper_GetClipList( DirectDrawState.lpDDC, NULL, cliplist, size );
+    ddrval = IDirectDrawClipper_GetClipList(DirectDrawState.lpDDC, NULL, cliplist, size);
 
     return ddrval;
 }
@@ -1344,10 +1269,10 @@ HRESULT DirectDraw_GetClipList( LPRGNDATA cliplist, LPDWORD size )
  *   1999.08.02  Brian King             Creation
  *
  */
-BYTE DirectDraw_GetBytesPerPixel( void )
+BYTE DirectDraw_GetBytesPerPixel(void)
 {
     int bpp;
-    bpp = ( DirectDrawState.lockable.lpdesc->ddpfPixelFormat.dwRGBBitCount + 7 ) >> 3;
+    bpp = (DirectDrawState.lockable.lpdesc->ddpfPixelFormat.dwRGBBitCount + 7) >> 3;
     return bpp;
 }
 
@@ -1366,7 +1291,7 @@ BYTE DirectDraw_GetBytesPerPixel( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_SetPalette( int remove )
+HRESULT DirectDraw_SetPalette(int remove)
 {
     HRESULT ddrval;
     if (DirectDrawState.primary.surface == NULL)
@@ -1398,15 +1323,13 @@ HRESULT DirectDraw_SetPalette( int remove )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_CreatePalette( LPPALETTEENTRY pal )
+HRESULT DirectDraw_CreatePalette(LPPALETTEENTRY pal)
 {
     HRESULT ddrval;
-    ddrval = IDirectDraw_CreatePalette( DirectDrawState.directdraw.dd,
+    ddrval = IDirectDraw_CreatePalette(DirectDrawState.directdraw.dd,
        DDPCAPS_8BIT | DDPCAPS_ALLOW256, pal, &DirectDrawState.lpDDP, NULL);
     if(SUCCEEDED(ddrval))
-    {
-       ddrval = DirectDraw_SetPalette(0);
-    }
+       ddrval = DirectDraw_SetPalette(0);
     return ddrval;
 }
 
@@ -1425,11 +1348,11 @@ HRESULT DirectDraw_CreatePalette( LPPALETTEENTRY pal )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_SetPaletteEntries( int start, int count, PALETTEENTRY *palette )
+HRESULT DirectDraw_SetPaletteEntries(int start, int count, PALETTEENTRY *palette)
 {
     HRESULT ddrval = DDERR_NOPALETTEATTACHED;
-    if( DirectDrawState.lpDDP )
-       ddrval = IDirectDrawPalette_SetEntries( DirectDrawState.lpDDP, 0, start, count, palette );
+    if(DirectDrawState.lpDDP)
+       ddrval = IDirectDrawPalette_SetEntries(DirectDrawState.lpDDP, 0, start, count, palette);
     return ddrval;
 }
 
@@ -1450,7 +1373,7 @@ HRESULT DirectDraw_SetPaletteEntries( int start, int count, PALETTEENTRY *palett
  *   1999.08.02  Brian King             Creation
  *
  */
-RGBFTYPE DirectDraw_GetSurfacePixelFormat( LPDDSURFACEDESC2 surface )
+RGBFTYPE DirectDraw_GetSurfacePixelFormat(LPDDSURFACEDESC2 surface)
 {
     int surface_is = 0;
     DDPIXELFORMAT *pfp = NULL;
@@ -1507,7 +1430,7 @@ RGBFTYPE DirectDraw_GetSurfacePixelFormat( LPDDSURFACEDESC2 surface )
        break;
        
      default:
-       write_log ("Unknown %d bit format %d %d %d\n", pfp->dwRGBBitCount, r, g, b); /* %%% - BERND, and here too... */
+       write_log ("Unknown %d bit format %d %d %d\n", pfp->dwRGBBitCount, r, g, b);
        break;
     }
     return RGBFB_NONE;
@@ -1528,13 +1451,13 @@ RGBFTYPE DirectDraw_GetSurfacePixelFormat( LPDDSURFACEDESC2 surface )
  *   1999.08.02  Brian King             Creation
  *
  */
-RGBFTYPE DirectDraw_GetPixelFormat( void )
+RGBFTYPE DirectDraw_GetPixelFormat(void)
 {
     RGBFTYPE type;
-    if( DirectDrawState.lockable.lpdesc )
-       type = DirectDraw_GetSurfacePixelFormat( DirectDrawState.lockable.lpdesc );
+    if(DirectDrawState.lockable.lpdesc)
+       type = DirectDraw_GetSurfacePixelFormat(DirectDrawState.lockable.lpdesc);
     else
-       type = DirectDraw_GetSurfacePixelFormat( &DirectDrawState.current.desc );
+       type = DirectDraw_GetSurfacePixelFormat(&DirectDrawState.current.desc);
     return type;
 }
 
@@ -1553,7 +1476,7 @@ RGBFTYPE DirectDraw_GetPixelFormat( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_CurrentWidth( void )
+DWORD DirectDraw_CurrentWidth(void)
 {
     DWORD width;
     width = DirectDrawState.current.desc.dwWidth;
@@ -1575,7 +1498,7 @@ DWORD DirectDraw_CurrentWidth( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-DWORD DirectDraw_CurrentHeight( void )
+DWORD DirectDraw_CurrentHeight(void)
 {
     DWORD height;
     height = DirectDrawState.current.desc.dwHeight;
@@ -1590,7 +1513,7 @@ int DirectDraw_GetVerticalBlankStatus (void)
     return status;
 }
 
-DWORD DirectDraw_CurrentRefreshRate( void )
+DWORD DirectDraw_CurrentRefreshRate(void)
 {
     DWORD height;
     height = DirectDrawState.current.desc.dwRefreshRate;
@@ -1617,16 +1540,12 @@ static int DirectDraw_BltFastStub4(LPDIRECTDRAWSURFACE7 dstsurf, DWORD x, DWORD
     int result = 0;
     HRESULT ddrval;
 
-    while(FAILED(ddrval = IDirectDrawSurface7_BltFast( dstsurf, x, y, srcsurf, srcrect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT )))
-    {
-       if (ddrval == DDERR_SURFACELOST) 
-       {
-           ddrval = restoresurface ( dstsurf );
+    while(FAILED(ddrval = IDirectDrawSurface7_BltFast(dstsurf, x, y, srcsurf, srcrect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT))) {
+       if (ddrval == DDERR_SURFACELOST) {
+           ddrval = restoresurface (dstsurf);
            if (FAILED(ddrval))
                break;
-       }
-       else if (ddrval != DDERR_SURFACEBUSY) 
-       {
+       } else if (ddrval != DDERR_SURFACEBUSY) {
            write_log("BltFastStub7(): DirectDrawSURFACE7_BltFast() failed with %s\n", DXError (ddrval));
            break;
        }
@@ -1651,34 +1570,24 @@ static int DirectDraw_BltFastStub4(LPDIRECTDRAWSURFACE7 dstsurf, DWORD x, DWORD
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_BltFast( surface_type_e dsttype, DWORD left, DWORD top, surface_type_e srctype, LPRECT srcrect )
+HRESULT DirectDraw_BltFast(surface_type_e dsttype, DWORD left, DWORD top, surface_type_e srctype, LPRECT srcrect)
 {
     LPDIRECTDRAWSURFACE7 lpDDS4_dst, lpDDS4_src;
-    if( dsttype == primary_surface )
-    {
+    if(dsttype == primary_surface) {
        lpDDS4_dst = DirectDrawState.primary.surface;
-    }
-    else if (dsttype == temporary_surface)
-    {
+    } else if (dsttype == temporary_surface) {
        lpDDS4_dst = DirectDrawState.temporary.surface;
-    }
-    else
-    {
+    } else {
        lpDDS4_dst = DirectDrawState.secondary.surface;
     }
-    if( srctype == primary_surface )
-    {
+    if(srctype == primary_surface) {
        lpDDS4_src = DirectDrawState.primary.surface;
-    }
-    else if (srctype == temporary_surface)
-    {
+    } else if (srctype == temporary_surface) {
        lpDDS4_src = DirectDrawState.temporary.surface;
-    }
-    else
-    {
+    } else {
        lpDDS4_src = DirectDrawState.secondary.surface;
     }
-    return DirectDraw_BltFastStub4( lpDDS4_dst, left, top, lpDDS4_src, srcrect );
+    return DirectDraw_BltFastStub4(lpDDS4_dst, left, top, lpDDS4_src, srcrect);
 }
 
 /*
@@ -1701,21 +1610,16 @@ static HRESULT DirectDraw_BltStub(LPDIRECTDRAWSURFACE7 dstsurf, LPRECT dstrect,
     int result = 0, errcnt = 0;
     HRESULT ddrval;
 
-    while(FAILED(ddrval = IDirectDrawSurface7_Blt(dstsurf, dstrect, srcsurf, srcrect, flags, ddbltfx)))
-    {
-       if (ddrval == DDERR_SURFACELOST) 
-       {
+    while(FAILED(ddrval = IDirectDrawSurface7_Blt(dstsurf, dstrect, srcsurf, srcrect, flags, ddbltfx))) {
+       if (ddrval == DDERR_SURFACELOST)  {
            if (errcnt > 10)
                return 1;
            errcnt++;
-           ddrval = restoresurface ( dstsurf );
-           if (FAILED(ddrval))
-           {
+           ddrval = restoresurface (dstsurf);
+           if (FAILED(ddrval)) {
                break;
            }
-       }
-       else if (ddrval != DDERR_SURFACEBUSY) 
-       {
+       } else if (ddrval != DDERR_SURFACEBUSY)  {
            write_log("BltStub(): DirectDrawSURFACE7_Blt() failed with %s\n", DXError (ddrval));
            break;
        }
@@ -1826,52 +1730,32 @@ HRESULT DirectDraw_Blt(surface_type_e dsttype, LPRECT dstrect,
 {
     LPDIRECTDRAWSURFACE7 lpDDS4_dst, lpDDS4_src;
     
-    if( dsttype == primary_surface )
-    {
-       if( DirectDrawState.isoverlay )
+    if(dsttype == primary_surface) {
+       if(DirectDrawState.isoverlay)
            lpDDS4_dst = DirectDrawState.overlay.surface;
        else
            lpDDS4_dst = DirectDrawState.primary.surface;
-    }
-    else if( dsttype == secondary_surface )
-    {
+    } else if(dsttype == secondary_surface) {
        lpDDS4_dst = DirectDrawState.secondary.surface;
-    }
-    else if( dsttype == tertiary_surface )
-    {
+    } else if(dsttype == tertiary_surface) {
        lpDDS4_dst = DirectDrawState.tertiary.surface;
-    }
-    else if( dsttype == temporary_surface )
-    {
+    } else if(dsttype == temporary_surface) {
        lpDDS4_dst = DirectDrawState.temporary.surface;
-    }
-    else
-    {
+    } else {
        lpDDS4_dst = DirectDrawState.overlay.surface;
     }
 
-    if( srctype == primary_surface )
-    {
+    if(srctype == primary_surface) {
        lpDDS4_src = DirectDrawState.primary.surface;
-    }
-    else if( srctype == secondary_surface )
-    {
+    } else if(srctype == secondary_surface) {
        lpDDS4_src = DirectDrawState.secondary.surface;
-    }
-    else if( srctype == tertiary_surface )
-    {
+    } else if(srctype == tertiary_surface) {
        lpDDS4_src = DirectDrawState.tertiary.surface;
-    }
-    else if( srctype == temporary_surface )
-    {
+    } else if(srctype == temporary_surface) {
        lpDDS4_src = DirectDrawState.temporary.surface;
-    }
-    else if( srctype == overlay_surface )
-    {
+    } else if(srctype == overlay_surface) {
        lpDDS4_src = DirectDrawState.overlay.surface;
-    }
-    else
-    {
+    } else {
        lpDDS4_src = NULL; /* For using BltStub to do rect-fills */
     }
     return DirectDraw_BltStub(lpDDS4_dst, dstrect, lpDDS4_src, srcrect, flags, fx);
@@ -1892,10 +1776,10 @@ HRESULT DirectDraw_Blt(surface_type_e dsttype, LPRECT dstrect,
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_WaitForVerticalBlank( DWORD flags )
+HRESULT DirectDraw_WaitForVerticalBlank(DWORD flags)
 {
     HRESULT result;
-    result = IDirectDraw7_WaitForVerticalBlank( DirectDrawState.directdraw.dd, flags, NULL );
+    result = IDirectDraw7_WaitForVerticalBlank(DirectDrawState.directdraw.dd, flags, NULL);
     return result;
 }
 
@@ -1914,10 +1798,10 @@ HRESULT DirectDraw_WaitForVerticalBlank( DWORD flags )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_EnumDisplayModes( DWORD flags, LPDDENUMMODESCALLBACK2 callback )
+HRESULT DirectDraw_EnumDisplayModes(DWORD flags, LPDDENUMMODESCALLBACK2 callback)
 {
     HRESULT result;
-    result = IDirectDraw7_EnumDisplayModes( DirectDrawState.directdraw.dd, flags, NULL, NULL, callback );    
+    result = IDirectDraw7_EnumDisplayModes(DirectDrawState.directdraw.dd, flags, NULL, NULL, callback);
     return result;
 }
 
@@ -1943,12 +1827,11 @@ HRESULT DirectDraw_EnumDisplays(LPDDENUMCALLBACKEX callback )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_FlipToGDISurface( void )
+HRESULT DirectDraw_FlipToGDISurface(void)
 {
     HRESULT result = DDERR_GENERIC;
-    if( DirectDrawState.initialized )
-    {
-       result = IDirectDraw7_FlipToGDISurface( DirectDrawState.directdraw.dd );
+    if(DirectDrawState.initialized) {
+       result = IDirectDraw7_FlipToGDISurface(DirectDrawState.directdraw.dd);
     }
     return result;
 }
@@ -1968,10 +1851,10 @@ HRESULT DirectDraw_FlipToGDISurface( void )
  *   1999.08.02  Brian King             Creation
  *
  */
-HRESULT DirectDraw_GetDC( HDC *hdc, surface_type_e surface )
+HRESULT DirectDraw_GetDC(HDC *hdc, surface_type_e surface)
 {
     HRESULT result = ~DD_OK;
-    if( surface == primary_surface )
+    if(surface == primary_surface)
        result = IDirectDrawSurface7_GetDC (DirectDrawState.primary.surface, hdc);
     else if (surface == overlay_surface)
        result = IDirectDrawSurface7_GetDC (DirectDrawState.overlay.surface, hdc);
index 1c28d23526e7a65e3dafb6bb600c4d85c6848e97..6f35b0124e38ccd2209204d9ce7f2d42525415cc 100755 (executable)
@@ -235,6 +235,6 @@ int uae_start_thread (void *(*f)(void *), void *arg, uae_thread_id *tid)
 void uae_set_thread_priority (int pri)
 {
     /* workaround for filesystem emulation freeze with some dual core systems */
-    SetThreadAffinityMask(GetCurrentThread(), 1); 
+    //SetThreadAffinityMask(GetCurrentThread(), 1); 
 }
 
index 7b98ad11fd3c911b3dc2234400d9ca2002713812..864d622c327da1758ae4ae4ed2cca39538948a1f 100755 (executable)
@@ -320,7 +320,7 @@ static int open_audio_ds (int size)
     wavfmt.nAvgBytesPerSec = wavfmt.nBlockAlign * freq;
     wavfmt.cbSize = 0;
 
-    max_sndbufsize = size * 3;
+    max_sndbufsize = size * 4;
     if (max_sndbufsize > SND_MAX_BUFFER2)
         max_sndbufsize = SND_MAX_BUFFER2;
     dsoundbuf = max_sndbufsize * 2;
@@ -424,6 +424,7 @@ void close_sound (void)
     pause_sound ();
     close_audio_ds ();
     have_sound = 0;
+    gui_data.sndbuf = 0;
 }
 
 int init_sound (void)
@@ -494,6 +495,25 @@ void sound_setadjust (double v)
     }
 }
 
+#define SND_STATUSCNT 10
+
+static int safedist;
+
+void restart_sound_buffer(void)
+{
+    DWORD playpos, safed;
+    HRESULT hr;
+
+    if (waiting_for_buffer != -1)
+       return;
+    hr = IDirectSoundBuffer_GetCurrentPosition (lpDSBsecondary, &playpos, &safed);
+    if (FAILED(hr))
+       return;
+    writepos = snd_writeoffset + safedist + playpos;
+    if (writepos >= dsoundbuf)
+        writepos -= dsoundbuf;
+}
+
 static void finish_sound_buffer_ds (void)
 {
     DWORD playpos, safepos, status;
@@ -503,11 +523,20 @@ static void finish_sound_buffer_ds (void)
     int diff;
     int counter = 1000;
     double vdiff, m, skipmode;
+    static int statuscnt;
+
+    if (statuscnt > 0) {
+       statuscnt--;
+       if (statuscnt == 0)
+           gui_data.sndbuf_status = 0;
+    }
 
     if (!waiting_for_buffer)
        return;
+    if (savestate_state)
+        return;
+
     if (waiting_for_buffer == 1) {
-        int safedist;
        hr = IDirectSoundBuffer_Play (lpDSBsecondary, 0, 0, DSBPLAY_LOOPING);
        if (FAILED(hr)) {
            write_log ("SOUND: Play failed: %s\n", DXError (hr));
@@ -529,8 +558,8 @@ static void finish_sound_buffer_ds (void)
        snd_totalmaxoffset += safedist;
        snd_maxoffset += safedist;
        snd_writeoffset += safedist;
-       writepos = snd_writeoffset + safedist;
        waiting_for_buffer = -1;
+       restart_sound_buffer();
        write_log("SOUND: safedist=%d snd_total=%d snd_max=%d snd_write=%d\n",
            safedist, snd_totalmaxoffset, snd_maxoffset, snd_writeoffset);
     }
@@ -558,15 +587,30 @@ static void finish_sound_buffer_ds (void)
            return;
        }
 
-       if (savestate_state)
-           return;
-
        if (writepos >= playpos)
            diff = writepos - playpos;
        else
            diff = dsoundbuf - playpos + writepos;
 
-       if (diff >= snd_totalmaxoffset) {
+       if (diff < safedist) {
+           hr = IDirectSoundBuffer_Lock (lpDSBsecondary, writepos, safedist, &b1, &s1, &b2, &s2, 0);
+           if (SUCCEEDED(hr)) {
+               memset (b1, 0, s1);
+               if (b2)
+                   memset (b2, 0, s2);
+               IDirectSoundBuffer_Unlock (lpDSBsecondary, b1, s1, b2, s2);
+           }
+           gui_data.sndbuf_status = -1;
+           statuscnt = SND_STATUSCNT;
+           writepos += safedist;
+           if (writepos >= dsoundbuf)
+               writepos -= dsoundbuf;
+           break;
+       }
+
+       if (diff > snd_totalmaxoffset) {
+           gui_data.sndbuf_status = 2;
+           statuscnt = SND_STATUSCNT;
            writepos = safepos + snd_writeoffset;
            if (writepos >= dsoundbuf)
                writepos -= dsoundbuf;
@@ -575,6 +619,8 @@ static void finish_sound_buffer_ds (void)
        }
 
        if (diff > snd_maxoffset) {
+           gui_data.sndbuf_status = 1;
+           statuscnt = SND_STATUSCNT;
            sleep_millis(1);
            counter--;
            if (counter < 0) {
index f707528e28a457d8853c0ecdd7c7511f7b741038..ab1f2aae97f2d7d7aaece63ba169c709beadc84d 100755 (executable)
@@ -11,6 +11,7 @@ extern uae_u16 sndbuffer[];
 extern uae_u16 *sndbufpt;
 extern int sndbufsize;
 extern void finish_sound_buffer (void);
+extern void restart_sound_buffer (void);
 extern int init_sound (void);
 extern void close_sound (void);
 extern int setup_sound (void);
@@ -36,6 +37,12 @@ STATIC_INLINE void check_sound_buffers (void)
     }
 }
 
+STATIC_INLINE void clear_sound_buffers (void)
+{
+    memset (sndbuffer, 0, sndbufsize);
+    sndbufpt = sndbuffer;
+}
+
 #define PUT_SOUND_BYTE(b) do { *(uae_u8 *)sndbufpt = b; sndbufpt = (uae_u16 *)(((uae_u8 *)sndbufpt) + 1); } while (0)
 #define PUT_SOUND_WORD(b) do { *(uae_u16 *)sndbufpt = b; sndbufpt = (uae_u16 *)(((uae_u8 *)sndbufpt) + 2); } while (0)
 #define PUT_SOUND_BYTE_LEFT(b) PUT_SOUND_BYTE(b)
index 779963ea5f16e268d9c88faf033347667babc9cc..21c5f73d74f149e925665c0f97a36fe7f25c7086 100755 (executable)
@@ -1564,7 +1564,7 @@ void logging_init(void)
     write_log (" %s %X.%X %d",
        SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ? "32-bit x86" :
        SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ? "IA64" :
-       SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "AMD64" : "Unknown",
+       SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "64-bit" : "Unknown",
        SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision,
        SystemInfo.dwNumberOfProcessors);
     write_log ("\n(c) 1995-2001 Bernd Schmidt   - Core UAE concept and implementation."
@@ -2807,12 +2807,12 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
     DWORD_PTR oldaff;
 
     thread = GetCurrentThread();
-    oldaff = SetThreadAffinityMask(thread, 1); 
+    //oldaff = SetThreadAffinityMask(thread, 1); 
     __try {
        WinMain2 (hInstance, hPrevInstance, lpCmdLine, nCmdShow);
     } __except(ExceptionFilter(GetExceptionInformation(), GetExceptionCode())) {
     }
-    SetThreadAffinityMask(thread, oldaff);
+    //SetThreadAffinityMask(thread, oldaff);
     return FALSE;
 }
 
index 36d51b097d16dcd4ab1ab158726435f6cbb68f24..45f70315490c1cde44d85350a19e14b65bb480d4 100755 (executable)
@@ -22,7 +22,7 @@ extern int manual_palette_refresh_needed;
 extern int mouseactive, focus;
 extern int ignore_messages_all;
 #define WINUAEBETA 1
-#define WINUAEBETASTR " Beta 2"
+#define WINUAEBETASTR " Beta 3"
 
 extern char start_path_exe[MAX_DPATH];
 extern char start_path_data[MAX_DPATH];
index ea713b60110f325834e5a5d824a9b981f6695c31..c4939fff4f0b707b252d0f900519b2a60aefce89 100755 (executable)
@@ -925,7 +925,7 @@ void flush_screen (int a, int b)
        if(currentmode->flags & DM_DX_FULLSCREEN )
            DX_Flip ();
        else if (DirectDraw_GetLockableType() != overlay_surface)
-           DX_Blit( 0, 0, 0, 0, WIN32GFX_GetWidth(), WIN32GFX_GetHeight(), BLIT_SRC );
+           DX_Blit (0, 0, 0, 0, WIN32GFX_GetWidth(), WIN32GFX_GetHeight(), BLIT_SRC);
 #endif
     } else if ((currentmode->flags & DM_DDRAW) && DirectDraw_GetLockableType() == secondary_surface ) {
        if (currentmode->flags & DM_DX_FULLSCREEN) {
index b3d077fb81f33d5f94fcdde7d154b11d88e1a560..93aef605c4a4664ca5b41474234eecd4630551f3 100755 (executable)
@@ -5251,7 +5251,8 @@ static void values_to_sounddlg (HWND hDlg)
     SendDlgItemMessage(hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
     WIN32GUI_LoadUIString (IDS_SOUND_SWAP_BOTH, txt, sizeof (txt));
     SendDlgItemMessage(hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
-    SendDlgItemMessage(hDlg, IDC_SOUNDSWAP, CB_SETCURSEL, workprefs.sound_stereo_swap_paula + workprefs.sound_stereo_swap_ahi * 2, 0);
+    SendDlgItemMessage(hDlg, IDC_SOUNDSWAP, CB_SETCURSEL,
+       workprefs.sound_stereo_swap_paula + workprefs.sound_stereo_swap_ahi * 2, 0);
 
     SendDlgItemMessage(hDlg, IDC_SOUNDSTEREOSEP, CB_RESETCONTENT, 0, 0);
     for (i = 10; i >= 0; i--) {
@@ -9309,7 +9310,7 @@ void gui_fps (int fps, int idle)
     gui_data.idle = idle;
     gui_led (7, 0);
     gui_led (8, 0);
-    gui_led (9, 0);
+    gui_led (9, gui_data.sndbuf_status > 1 || gui_data.sndbuf_status < 0);
 }
 
 void gui_led (int led, int on)
@@ -9326,10 +9327,6 @@ void gui_led (int led, int on)
 #endif
     if (!hStatusWnd)
        return;
-    if (on)
-       type = SBT_POPOUT;
-    else
-       type = 0;
     tt = NULL;
     if (led >= 1 && led <= 4) {
        pos = 6 + (led - 1);
@@ -9371,8 +9368,17 @@ void gui_led (int led, int on)
     } else if (led == 9) {
        pos = 0;
        ptr = drive_text + pos * 16;
-       sprintf(ptr, "SND: %.0f%%", (double)((gui_data.sndbuf) / 10.0));
+       if (gui_data.sndbuf_status < 3) {
+           sprintf(ptr, "SND: %.0f%%", (double)((gui_data.sndbuf) / 10.0));
+       } else {
+           ptr[0] = 0;
+           on = 0;
+       }
     }
+    if (on)
+       type = SBT_POPOUT;
+    else
+       type = 0;
     if (pos >= 0) {
        PostMessage (hStatusWnd, SB_SETTEXT, (WPARAM) ((pos + 1) | type), (LPARAM) ptr);
        if (tt != NULL)
index 04dc702e8b98870872d8baf51011f7227e29fac7..8794bb3d3c042b171920ceabb4a9fb56b7bda0b7 100755 (executable)
@@ -235,7 +235,7 @@ static uae_u8 *restore_chunk (struct zfile *f, char *name, size_t *len, size_t *
 {
     uae_u8 tmp[4], dummy[4], *mem, *src;
     uae_u32 flags;
-    size_t len2;
+    int len2;
 
     *totallen = 0;
     /* chunk name */