From 5bce9d29c5b9b2fce73a808b3b2b8b0627b5d83b Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 2 Nov 2006 19:51:08 +0200 Subject: [PATCH] imported winuaesrc1330b8.zip --- cfgfile.c | 1 - disk.c | 9 +- expansion.c | 4 +- filesys.c | 23 ++-- include/sysdeps.h | 3 + od-win32/WinUAE_Install.nsi | 4 +- od-win32/ioport.c | 55 +++++---- od-win32/resources/winuae_minimal.rc | 154 +++++++++++++------------- od-win32/win32.c | 9 +- od-win32/win32.h | 2 +- od-win32/win32gui.c | 9 +- od-win32/writelog.c | 31 ++++-- zfile.c | 160 +++++++++++++++++++++++---- 13 files changed, 314 insertions(+), 150 deletions(-) diff --git a/cfgfile.c b/cfgfile.c index 9fd833ff..bf779de3 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -1526,7 +1526,6 @@ int cfgfile_load (struct uae_prefs *p, const char *filename, int *type, int igno end: recursive--; fixup_prefs (p); - write_log ("%s\n", p->romfile); return v; } diff --git a/disk.c b/disk.c index b29b4144..813dc60f 100755 --- a/disk.c +++ b/disk.c @@ -212,7 +212,8 @@ static void disk_checksum(uae_u8 *p, uae_u8 *c) { uae_u32 cs = 0; int i; - for (i = 0; i < FS_FLOPPY_BLOCKSIZE; i+= 4) cs += (p[i] << 24) | (p[i+1] << 16) | (p[i+2] << 8) | (p[i+3] << 0); + for (i = 0; i < FS_FLOPPY_BLOCKSIZE; i+= 4) + cs += (p[i] << 24) | (p[i+1] << 16) | (p[i+2] << 8) | (p[i+3] << 0); cs = -cs; c[0] = cs >> 24; c[1] = cs >> 16; c[2] = cs >> 8; c[3] = cs >> 0; } @@ -572,8 +573,8 @@ static void reset_drive(int i) drv->buffered_side = -1; gui_led (i + 1, 0); drive_settype_id (drv); - if (strlen (drv->newname) > 0) - strcpy (currprefs.df[i], drv->newname); + strcpy (currprefs.df[i], changed_prefs.df[i]); + drv->newname[0] = 0; if (!drive_insert (drv, &currprefs, i, currprefs.df[i])) disk_eject (i); } @@ -582,7 +583,7 @@ static void reset_drive(int i) static void update_drive_gui (int num) { drive *drv = floppy + num; - int writ = dskdmaen == 3 && drv->state ? 1 : 0; + int writ = dskdmaen == 3 && drv->state && !(selected & (1 << num)); if (drv->state == gui_data.drive_motor[num] && drv->cyl == gui_data.drive_track[num] diff --git a/expansion.c b/expansion.c index d3ed5d0c..11b98f6a 100755 --- a/expansion.c +++ b/expansion.c @@ -1160,7 +1160,7 @@ void expansion_clear(void) if (fastmemory) memset (fastmemory, 0, allocated_fastmem); if (z3fastmem) - memset (z3fastmem, 0, allocated_z3fastmem); + memset (z3fastmem, 0, allocated_z3fastmem > 0x800000 ? 0x800000 : allocated_z3fastmem); if (gfxmemory) memset (gfxmemory, 0, allocated_gfxmem); } @@ -1226,4 +1226,4 @@ uae_u8 *restore_expansion (uae_u8 *src) return src; } -#endif /* SAVESTATE */ \ No newline at end of file +#endif /* SAVESTATE */ diff --git a/filesys.c b/filesys.c index 018120c2..d5bd1e37 100755 --- a/filesys.c +++ b/filesys.c @@ -2121,16 +2121,21 @@ static void populate_directory (Unit *unit, a_inode *base) static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info) { - if (ek->curr_file == 0) - goto no_more_entries; - - get_fileinfo (unit, packet, info, ek->curr_file); - ek->curr_file = ek->curr_file->sibling; - TRACE (("curr_file set to %p %s\n", ek->curr_file, + for (;;) { + char *name; + if (ek->curr_file == 0) + break; + name = ek->curr_file->nname; + get_fileinfo (unit, packet, info, ek->curr_file); + ek->curr_file = ek->curr_file->sibling; + if (!fsdb_exists(name)) { + TRACE (("%s orphaned", name)); + continue; + } + TRACE (("curr_file set to %p %s\n", ek->curr_file, ek->curr_file ? ek->curr_file->aname : "NULL")); - return; - - no_more_entries: + return; + } TRACE(("no more entries\n")); free_exkey (unit, ek); PUT_PCK_RES1 (packet, DOS_FALSE); diff --git a/include/sysdeps.h b/include/sysdeps.h index 63a41666..eedf866f 100755 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -460,6 +460,9 @@ extern void gui_message (const char *,...); extern int gui_message_multibutton (int flags, const char *format,...); #define write_log_err write_log extern void logging_init(void); +extern void *log_open(const char *name, int append, int bootlog); +extern void log_close(void *f); + #ifndef O_BINARY #define O_BINARY 0 diff --git a/od-win32/WinUAE_Install.nsi b/od-win32/WinUAE_Install.nsi index 6cd1613b..608d44ff 100755 --- a/od-win32/WinUAE_Install.nsi +++ b/od-win32/WinUAE_Install.nsi @@ -1,5 +1,5 @@ !define PRODUCT_NAME "WinUAE" -!define PRODUCT_VERSION "1.3.2" +!define PRODUCT_VERSION "1.3.3" !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" @@ -87,6 +87,8 @@ Section "WinUAE (required)" secWinUAE_files File "${DISTPATH}\Docs\Readme.txt" ;-- Creates the necessary registry entrys WriteRegStr HKCU "Software\Arabuusimiehet\WinUAE" "InstallDir" "$INSTDIR" + ;-- force ROM rescan after install + DeleteRegKey HKCU "Software\Arabuusimiehet\WinUAE\DetectedROMs" SectionEnd Section "Host-Configurations" secExConfig diff --git a/od-win32/ioport.c b/od-win32/ioport.c index d29a6c11..4c6de0c1 100755 --- a/od-win32/ioport.c +++ b/od-win32/ioport.c @@ -42,12 +42,13 @@ static HMODULE ioh; #include #endif -static bool initialized; +static int initialized; int ioport_init (void) { if (initialized) - return 1; + return initialized > 0 ? 1 : 0; + #ifndef IOPORT_EMU ioh = WIN32_LoadLibrary ("tvicport.dll"); if (ioh) { @@ -58,46 +59,54 @@ int ioport_init (void) pReadPort = (READPORT)GetProcAddress (ioh, "ReadPort"); pWritePort = (WRITEPORT)GetProcAddress (ioh, "WritePort"); if (!pOpenTVicPort || !pCloseTVicPort || !pIsDriverOpened || !pReadPort || !pWritePort) { - io_log("incompatible tvicport.dll\n"); + write_log ("IO: incompatible tvicport.dll\n"); break; } if (!pOpenTVicPort()) { - io_log("tvicport.dll failed to initialize\n"); + write_log ("IO: tvicport.dll failed to initialize\n"); break; } if (!pIsDriverOpened()) { - io_log("tvicport.dll failed to initialized!\n"); + write_log ("IO: tvicport.dll failed to initialized!\n"); pCloseTVicPort(); break; } initialized = 1; - io_log ("tvicport.dll initialized"); + write_log ("IO: tvicport.dll initialized\n"); return 1; } } FreeLibrary(ioh); ioh = WIN32_LoadLibrary ("winio.dll"); - if (!ioh) - return 0; - pInitializeWinIo = (INITIALIZEWINIO)GetProcAddress (ioh, "InitializeWinIo"); - pShutdownWinIo = (SHUTDOWNWINIO)GetProcAddress (ioh, "ShutdownWinIo"); - pGetPortVal = (GETPORTVAL)GetProcAddress (ioh, "GetPortVal"); - pSetPortVal = (SETPORTVAL)GetProcAddress (ioh, "SetPortVal"); - if (!pInitializeWinIo || !pShutdownWinIo || !pGetPortVal || !pSetPortVal) { - io_log ("incompatible winio.dll\n"); - FreeLibrary (ioh); - return 0; - } - __try { - initialized = pInitializeWinIo() ? 2 : 0; - } __except (EXCEPTION_EXECUTE_HANDLER) { - initialized = 0; + if (ioh) { + for (;;) { + pInitializeWinIo = (INITIALIZEWINIO)GetProcAddress (ioh, "InitializeWinIo"); + pShutdownWinIo = (SHUTDOWNWINIO)GetProcAddress (ioh, "ShutdownWinIo"); + pGetPortVal = (GETPORTVAL)GetProcAddress (ioh, "GetPortVal"); + pSetPortVal = (SETPORTVAL)GetProcAddress (ioh, "SetPortVal"); + if (!pInitializeWinIo || !pShutdownWinIo || !pGetPortVal || !pSetPortVal) { + write_log ("IO: incompatible winio.dll\n"); + break; + } + __try { + initialized = pInitializeWinIo() ? 2 : 0; + } __except (EXCEPTION_EXECUTE_HANDLER) { + write_log ("IO: winio.dll initialization failed\n"); + } + if (!initialized) + break; + write_log ("IO: winio.dll initialized\n"); + return 1; + } } + FreeLibrary(ioh); + initialized = -1; + write_log ("IO: tvicport.dll or winio.dll failed to initialize\n"); + return 0; #else initialized = 1; + return 1; #endif - io_log ("io initialize returned %d\n", initialized); - return initialized; } void ioport_free (void) diff --git a/od-win32/resources/winuae_minimal.rc b/od-win32/resources/winuae_minimal.rc index ebf1b11d..0fc2618e 100755 --- a/od-win32/resources/winuae_minimal.rc +++ b/od-win32/resources/winuae_minimal.rc @@ -227,47 +227,44 @@ BEGIN CONTROL "Include network drives",IDC_MAPDRIVES_NET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,216,101,10,0,HIDC_MAPDRIVES_NET END -IDD_SOUND DIALOGEX 0, 0, 300, 244 +IDD_SOUND DIALOGEX 0, 0, 300, 231 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN RTEXT "Sound device:",IDC_SOUNDCARD,8,9,51,13,SS_CENTERIMAGE COMBOBOX IDC_SOUNDCARDLIST,64,9,229,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Sound Emulation",IDC_SOUNDSETTINGS,5,30,120,68 + GROUPBOX "Sound Emulation",IDC_SOUNDSETTINGS,5,30,120,81 CONTROL "Disabled",IDC_SOUND0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,45,43,10 CONTROL "Disabled, but emulated",IDC_SOUND1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,57,88,10 CONTROL "Enabled",IDC_SOUND2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,69,42,10 CONTROL "Enabled, 100% accurate",IDC_SOUND3,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,81,93,10 - GROUPBOX "Volume",IDC_STATIC,131,30,164,31 - CONTROL "",IDC_SOUNDVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,137,38,105,20 - EDITTEXT IDC_SOUNDVOLUME2,247,41,40,12,ES_CENTER | ES_READONLY - GROUPBOX "Sound Buffer Size",IDC_STATIC,132,67,164,31 - CONTROL "Slider1",IDC_SOUNDBUFFERRAM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,138,75,106,19 - EDITTEXT IDC_SOUNDBUFFERMEM,248,78,40,12,ES_CENTER | ES_READONLY - GROUPBOX "Settings",IDC_SOUNDINTERPOLATION2,6,101,290,60 - LTEXT "Frequency:",IDC_SOUNDFREQTXT,11,111,37,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFREQ,13,120,51,75,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT "Audio filter:",IDC_SOUNDFILTERTXT,209,135,34,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFILTER,209,144,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,74,111,41,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREO,73,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,209,111,41,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDINTERPOLATION,209,119,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo separation:",IDC_SOUNDSTEREOSEPTXT,141,111,56,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREOSEP,142,120,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Stereo mixing delay:",IDC_SOUNDSTEREOMIXTXT,141,135,63,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDSTEREOMIX,142,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Floppy Drive Sound Emulation",IDC_STATIC,6,164,290,46 - CONTROL "",IDC_SOUNDDRIVEVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,172,107,19 - EDITTEXT IDC_SOUNDDRIVEVOLUME2,124,178,40,12,ES_CENTER | ES_READONLY - COMBOBOX IDC_SOUNDDRIVE,237,174,46,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_SOUNDDRIVESELECT,18,192,265,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Audio Driver Lag Compensation",IDC_STATIC,6,211,290,31 - CONTROL "Slider1",IDC_SOUNDADJUST,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,221,107,19 - EDITTEXT IDC_SOUNDADJUSTNUM,124,224,40,12,ES_CENTER | ES_READONLY - PUSHBUTTON "Calibrate",IDC_SOUNDCALIBRATE,183,223,40,14 - COMBOBOX IDC_SOUNDSWAP,73,144,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,74,135,50,8,SS_CENTERIMAGE + GROUPBOX "Volume",IDC_STATIC,131,36,164,31 + CONTROL "",IDC_SOUNDVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,137,44,105,20 + EDITTEXT IDC_SOUNDVOLUME2,247,47,40,12,ES_CENTER | ES_READONLY + GROUPBOX "Sound Buffer Size",IDC_STATIC,132,73,164,31 + CONTROL "Slider1",IDC_SOUNDBUFFERRAM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,138,81,106,19 + EDITTEXT IDC_SOUNDBUFFERMEM,248,84,40,12,ES_CENTER | ES_READONLY + GROUPBOX "Settings",IDC_SOUNDINTERPOLATION2,6,114,290,60 + LTEXT "Frequency:",IDC_SOUNDFREQTXT,11,124,37,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDFREQ,13,133,51,75,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Audio filter:",IDC_SOUNDFILTERTXT,209,148,34,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDFILTER,209,157,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,74,124,41,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREO,73,133,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,209,124,41,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDINTERPOLATION,209,132,80,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo separation:",IDC_SOUNDSTEREOSEPTXT,141,124,56,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREOSEP,142,133,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Stereo mixing delay:",IDC_SOUNDSTEREOMIXTXT,141,148,63,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREOMIX,142,157,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Floppy Drive Sound Emulation",IDC_STATIC,6,177,290,46 + CONTROL "",IDC_SOUNDDRIVEVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,185,107,19 + EDITTEXT IDC_SOUNDDRIVEVOLUME2,124,191,40,12,ES_CENTER | ES_READONLY + COMBOBOX IDC_SOUNDDRIVE,237,187,46,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SOUNDDRIVESELECT,18,205,265,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SOUNDSWAP,73,157,62,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Swap channels:",IDC_SOUNDSWAPTXT,74,148,50,8,SS_CENTERIMAGE + CONTROL "Automatic switching",IDC_SOUND_AUTO,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,14,95,103,10 END IDD_LOADSAVE DIALOGEX 0, 0, 302, 241 @@ -357,11 +354,11 @@ BEGIN CONTROL "",IDC_AMIKIT,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,157,169,80,15 END -IDD_MISC1 DIALOGEX 0, 0, 300, 226 +IDD_MISC1 DIALOGEX 0, 0, 300, 237 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Advanced",IDC_STATIC,8,2,285,93 + GROUPBOX "Advanced",IDC_STATIC,8,2,285,110 CONTROL "Untrap mouse with middle button",IDC_JULIAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,15,120,10 CONTROL "Show GUI on startup",IDC_SHOWGUI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,29,120,10 CONTROL "On-screen LEDs",IDC_SHOWLEDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,43,115,10 @@ -371,27 +368,28 @@ BEGIN CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,29,120,10 CONTROL "Don't use RGB overlays",IDC_NOOVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,43,120,10 CONTROL "Synchronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,70,115,10 - GROUPBOX "Keyboard LEDs",IDC_STATIC,7,125,85,94 - COMBOBOX IDC_KBLED1,22,139,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_KBLED2,22,158,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_KBLED3,22,178,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Logging",IDC_STATIC,97,125,195,25 - CONTROL "Create log file",IDC_CREATELOGFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,107,136,72,10,0,HIDC_CREATELOGFILE - CONTROL "Illegal memory accesses",IDC_ILLEGAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,136,95,10 - GROUPBOX "State Files",IDC_STATIC,98,150,195,69 - PUSHBUTTON "Load state...",IDC_DOLOADSTATE,105,167,49,14 - PUSHBUTTON "Save state...",IDC_DOSAVESTATE,106,193,49,14 - CONTROL "Enable state recording",IDC_STATE_CAPTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,188,166,88,10 - RTEXT "Recording rate (seconds):",IDC_STATE_RATE_TEXT,157,184,86,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_RATE,248,182,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - RTEXT "Recording buffer (MB):",IDC_STATE_BUFFERSIZE_TEXT,157,204,83,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_BUFFERSIZE,248,202,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Keyboard LEDs",IDC_STATIC,7,140,85,94 + COMBOBOX IDC_KBLED1,22,154,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_KBLED2,22,173,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_KBLED3,22,193,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Logging",IDC_STATIC,97,140,195,25 + CONTROL "Create log file",IDC_CREATELOGFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,107,151,72,10,0,HIDC_CREATELOGFILE + CONTROL "Illegal memory accesses",IDC_ILLEGAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,151,95,10 + GROUPBOX "State Files",IDC_STATIC,98,165,195,69 + PUSHBUTTON "Load state...",IDC_DOLOADSTATE,105,182,49,14 + PUSHBUTTON "Save state...",IDC_DOSAVESTATE,106,208,49,14 + CONTROL "Enable state recording",IDC_STATE_CAPTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,188,181,88,10 + RTEXT "Recording rate (seconds):",IDC_STATE_RATE_TEXT,157,199,86,10,SS_CENTERIMAGE | WS_TABSTOP + COMBOBOX IDC_STATE_RATE,248,197,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + RTEXT "Recording buffer (MB):",IDC_STATE_BUFFERSIZE_TEXT,157,219,83,10,SS_CENTERIMAGE | WS_TABSTOP + COMBOBOX IDC_STATE_BUFFERSIZE,248,217,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Always on top",IDC_ALWAYSONTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,83,117,10 CONTROL "Catweasel",IDC_CATWEASEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,83,115,10 - CONTROL "USB mode",IDC_KBLED_USB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,201,64,10 + CONTROL "USB mode",IDC_KBLED_USB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,216,64,10 COMBOBOX IDC_SCSIMODE,159,55,104,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_LANGUAGE,103,106,179,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Language",IDC_STATIC,7,97,285,25 + COMBOBOX IDC_LANGUAGE,103,121,179,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Language",IDC_STATIC,7,112,285,25 + CONTROL "Disable powersaving features",IDC_POWERSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,96,117,10 END IDD_HARDFILE DIALOGEX 0, 0, 299, 212 @@ -403,7 +401,7 @@ BEGIN RTEXT "Path:",IDC_HARDFILE_DIR_TEXT,26,18,22,10 EDITTEXT IDC_PATH_NAME,52,15,213,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_SELECTOR,271,15,11,15 - RTEXT "File system:",IDC_HARDFILE_FILESYS_TEXT,14,37,34,10 + RTEXT "FileSys:",IDC_HARDFILE_FILESYS_TEXT,14,37,34,10 EDITTEXT IDC_PATH_FILESYS,52,34,213,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_FILESYS_SELECTOR,271,34,11,15 RTEXT "Device:",IDC_HARDFILE_DEVICE_TEXT,17,58,31,10 @@ -479,8 +477,6 @@ BEGIN CONTROL "NTSC [] North American and Japanese display standard, 60Hz refresh rate. Other countries use PAL (50Hz. display refresh rate)",IDC_NTSC, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,63,50,10 GROUPBOX "Options",IDC_STATIC,168,11,114,82 - CONTROL "Fast Copper [] Faster but less compatible copper emulation.",IDC_FASTCOPPER, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,176,198,98,10 CONTROL "Immediate Blitter [] Faster but less compatible blitter emulation.",IDC_BLITIMM, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,30,96,10 CONTROL "Cycle-exact CPU and Blitter [] The most compatible A500 emulation mode. Very fast PC recommended.",IDC_CYCLEEXACT, @@ -500,13 +496,15 @@ BEGIN CONTROL "Emulated, 100% accurate",IDC_CS_SOUND2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,39,197,95,10 CONTROL "Genlock connected [] Allow boot sequence to detect genlock. Genlock is not emulated.",IDC_GENLOCK, "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,174,56,100,10 + CONTROL "Faster RTG [] Enables less accurate custom chipset emulation mode when Picasso96 is enabled.",IDC_FASTERRTG, + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,174,68,100,10 END -IDD_AVIOUTPUT DIALOGEX 0, 0, 288, 193 +IDD_AVIOUTPUT DIALOGEX 0, 0, 288, 203 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Output Properties",IDC_STATIC,5,8,274,97 + GROUPBOX "Output Properties",IDC_STATIC,5,8,274,118 EDITTEXT IDC_AVIOUTPUT_FILETEXT,15,21,226,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER,WS_EX_CLIENTEDGE PUSHBUTTON "...",IDC_AVIOUTPUT_FILE,249,20,19,12 CONTROL "Audio",IDC_AVIOUTPUT_AUDIO,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,15,36,32,11 @@ -515,19 +513,21 @@ BEGIN CONTROL "",IDC_AVIOUTPUT_VIDEO_STATIC,"Static",SS_LEFTNOWORDWRAP | SS_CENTERIMAGE | SS_SUNKEN | WS_GROUP,59,50,209,11 CONTROL "Disable frame rate limit while recording",IDC_AVIOUTPUT_FRAMELIMITER, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,68,136,10 - CONTROL "AVI output enabled",IDC_AVIOUTPUT_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,15,83,108,14 - CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,133,83,66,14 - CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,204,83,66,14 - CONTROL "Slider1",IDC_AVIOUTPUT_FPS,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,156,68,97,11 - LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,255,68,19,8 - PUSHBUTTON "Save screenshot",IDC_SCREENSHOT,16,124,76,14 - GROUPBOX "Ripper",IDC_STATIC,5,110,275,38 - PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,100,124,76,14,WS_DISABLED - CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,192,124,77,14 - GROUPBOX "Input Recorder",IDC_STATIC,5,152,275,33 - CONTROL "Record",IDC_INPREC_RECORD,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,191,164,77,14 - CONTROL "Playback",IDC_INPREC_PLAY,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,16,165,77,14 - CONTROL "Alt. playback mode",IDC_INPREC_PLAYMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,167,78,10 + CONTROL "AVI output enabled",IDC_AVIOUTPUT_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,15,103,108,14 + CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,133,103,66,14 + CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,204,103,66,14 + CONTROL "Slider1",IDC_AVIOUTPUT_FPS,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,156,84,97,11 + LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,255,84,19,8 + PUSHBUTTON "Save screenshot",IDC_SCREENSHOT,16,141,76,14 + GROUPBOX "Ripper",IDC_STATIC,5,127,274,38 + PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,100,141,76,14,WS_DISABLED + CONTROL "Sample ripper",IDC_SAMPLERIPPER_ACTIVATED,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,192,141,77,14 + GROUPBOX "Input Recorder",IDC_STATIC,5,166,274,33 + CONTROL "Record",IDC_INPREC_RECORD,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,191,177,77,14 + CONTROL "Playback",IDC_INPREC_PLAY,"Button",BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,16,178,77,14 + CONTROL "Alt. playback mode",IDC_INPREC_PLAYMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,180,78,10 + CONTROL "Disable sound output while recording",IDC_AVIOUTPUT_NOSOUNDOUTPUT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,85,136,10 END IDD_INPUT DIALOGEX 0, 0, 300, 242 @@ -744,7 +744,7 @@ GUIDELINES DESIGNINFO BEGIN IDD_SOUND, DIALOG BEGIN - BOTTOMMARGIN, 243 + BOTTOMMARGIN, 230 END IDD_LOADSAVE, DIALOG @@ -760,7 +760,7 @@ BEGIN IDD_MISC1, DIALOG BEGIN - BOTTOMMARGIN, 219 + BOTTOMMARGIN, 226 END IDD_INPUT, DIALOG @@ -838,8 +838,8 @@ IDI_PATHS ICON "paths.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,0 - PRODUCTVERSION 1,3,0,0 + FILEVERSION 1,4,0,0 + PRODUCTVERSION 1,4,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -855,12 +855,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "WinUAE" - VALUE "FileVersion", "1.3" + VALUE "FileVersion", "1.4.0" VALUE "InternalName", "WinUAE" VALUE "LegalCopyright", "© 1996-2006 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" - VALUE "ProductVersion", "1.3" + VALUE "ProductVersion", "1.4.0" END END BLOCK "VarFileInfo" @@ -1112,7 +1112,7 @@ BEGIN IDS_SOUND_4CHANNEL "4 Channels" IDS_HF_FS_CUSTOM "Custom" IDS_SELECTFS "Select file system handler (FastFileSystem, SmartFilesystem, etc.)" - IDS_KEYJOY "Keyboard Layout A (Numeric keypad, 0 and 5 = Fire)\nKeyboard Layout B (Cursor keys, Right CTRL and ALT = Fire)\nKeyboard Layout C (T=Up B=Down F=Left H=Right, Left ALT = Fire)\nX-Arcade (Left)\nX-Arcade (Right)" + IDS_KEYJOY "Keyboard Layout A (Numeric keypad, 0 and 5 = Fire)\nKeyboard Layout B (Cursor keys, Right CTRL and ALT = Fire)\nKeyboard Layout C (W=Up S=Down A=Left D=Right, Left ALT = Fire)\nX-Arcade (Left)\nX-Arcade (Right)" IDS_STATEFILE_UNCOMPRESSED "Uncompressed" IDS_STATEFILE_RAMDUMP "RAM dump" IDS_STATEFILE_WAVE "Wave audio dump" diff --git a/od-win32/win32.c b/od-win32/win32.c index 0b889b0b..0c348cd9 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -305,8 +305,9 @@ static int figure_processor_speed (void) qpcdivisor++; qpc_avail = -1; } - write_log("CLOCKFREQ: QPF %.2fMHz (DIV=%d)\n", freq.QuadPart / 1000000.0, 1 << qpcdivisor); - if (SystemInfo.dwNumberOfProcessors > 1) + write_log("CLOCKFREQ: QPF %.2fMHz (%.2fMHz, DIV=%d)\n", freq.QuadPart / 1000000.0, + qpfrate / 1000000.0, 1 << qpcdivisor); + if (SystemInfo.dwNumberOfProcessors > 1 && no_rdtsc >= 0) rpt_available = 0; /* RDTSC can be weird in SMP-systems */ } else { write_log("CLOCKREQ: QPF not supported\n"); @@ -1585,7 +1586,7 @@ void logging_open(int bootlog, int append) sprintf (debugfilename, "%swinuaebootlog.txt", start_path_data); if (debugfilename[0]) { if (!debugfile) - debugfile = fopen (debugfilename, append ? "a" : "wt"); + debugfile = log_open (debugfilename, append, bootlog); } #endif } @@ -1601,7 +1602,7 @@ void logging_init(void) } if (first == 1) { if (debugfile) - fclose (debugfile); + log_close (debugfile); debugfile = 0; } logging_open(first ? 0 : 1, 0); diff --git a/od-win32/win32.h b/od-win32/win32.h index 2821abde..f3bee8d2 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -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 7" +#define WINUAEBETASTR " Beta 8" extern char start_path_exe[MAX_DPATH]; extern char start_path_data[MAX_DPATH]; diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 19d69dad..481eddf2 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -8848,8 +8848,13 @@ static void centerWindow (HWND hDlg) pt2.x = x + 16; pt2.y = y + GetSystemMetrics (SM_CYMENU) + GetSystemMetrics (SM_CYBORDER); if (MonitorFromPoint (pt1, MONITOR_DEFAULTTONULL) == NULL || MonitorFromPoint (pt2, MONITOR_DEFAULTTONULL) == NULL) { - x = 16; - y = 16; + if (isfullscreen()) { + x = 0; + y = 0; + } else { + x = 16; + y = 16; + } } SetWindowPos (hDlg, HWND_TOP, x, y, 0, 0, SWP_NOSIZE); } diff --git a/od-win32/writelog.c b/od-win32/writelog.c index f7e5625b..93ce3120 100755 --- a/od-win32/writelog.c +++ b/od-win32/writelog.c @@ -12,6 +12,7 @@ static int consoleopen = 0; static HANDLE stdinput,stdoutput; +static int bootlogmode; FILE *debugfile = NULL; int console_logging; @@ -22,7 +23,8 @@ int console_logging; static void openconsole(void) { - if(consoleopen) return; + if(consoleopen) + return; AllocConsole(); stdinput = GetStdHandle(STD_INPUT_HANDLE); stdoutput = GetStdHandle(STD_OUTPUT_HANDLE); @@ -49,8 +51,7 @@ int console_get (char *out, int maxlen) *out = 0; totallen=0; - while(maxlen>0) - { + while(maxlen>0) { ReadConsole(stdinput,out,1,&len,0); if(*out == 13) break; @@ -77,6 +78,8 @@ static char *writets(void) static char lastts[100]; char curts[100]; + if (bootlogmode) + return NULL; _ftime(&tb); t = localtime(&tb.time); strftime(curts, sizeof curts, "%Y-%m-%d %H:%M:%S\n", t); @@ -111,12 +114,12 @@ void write_dlog (const char *format, ...) ts = writets(); if (SHOW_CONSOLE || console_logging) { openconsole(); - if (lfdetected) + if (lfdetected && ts) WriteConsole(stdoutput, ts, strlen(ts), &numwritten,0); WriteConsole(stdoutput, buffer, strlen(buffer), &numwritten,0); } if (debugfile) { - if (lfdetected) + if (lfdetected && ts) fprintf(debugfile, ts); fprintf(debugfile, buffer); fflush(debugfile); @@ -138,14 +141,14 @@ void write_log (const char *format, ...) ts = writets(); if (SHOW_CONSOLE || console_logging) { openconsole(); - if (lfdetected) + if (lfdetected && ts) WriteConsole(stdoutput, ts, strlen(ts), &numwritten,0); tmp = WriteConsole(stdoutput, buffer, strlen(buffer), &numwritten, 0); if (!tmp) tmp = GetLastError(); } if (debugfile) { - if (lfdetected) + if (lfdetected && ts) fprintf(debugfile, ts); fprintf(debugfile, buffer); fflush(debugfile); @@ -171,3 +174,17 @@ void f_out (void *f, const char *format, ...) WriteConsole(stdoutput, buffer, strlen(buffer), &numwritten,0); va_end (parms); } + +void *log_open(const char *name, int append, int bootlog) +{ + FILE *f; + + f = fopen(name, append ? "a" : "wt"); + bootlogmode = bootlog; + return f; +} + +void log_close(void *f) +{ + fclose(f); +} diff --git a/zfile.c b/zfile.c index cdda08ee..58b5d3eb 100755 --- a/zfile.c +++ b/zfile.c @@ -90,7 +90,8 @@ void zfile_fclose (struct zfile *f) pl = l; l = l->next; } - if (l) nxt = l->next; + if (l) + nxt = l->next; zfile_free (f); if (l == 0) return; @@ -711,10 +712,57 @@ static struct zfile *un7z (struct zfile *z) return z; } -#if 0 /* copy and paste job? you are only imagining it! */ static struct zfile *rarunpackzf; /* stupid unrar.dll */ #include +typedef HANDLE (_stdcall* RAROPENARCHIVE)(struct RAROpenArchiveData*); +static RAROPENARCHIVE pRAROpenArchive; +typedef int (_stdcall* RARREADHEADEREX)(HANDLE,struct RARHeaderDataEx*); +static RARREADHEADEREX pRARReadHeaderEx; +typedef int (_stdcall* RARPROCESSFILE)(HANDLE,int,char*,char *); +static RARPROCESSFILE pRARProcessFile; +typedef int (_stdcall* RARCLOSEARCHIVE)(HANDLE); +static RARCLOSEARCHIVE pRARCloseArchive; +typedef void (_stdcall* RARSETCALLBACK)(HANDLE,UNRARCALLBACK,LONG); +static RARSETCALLBACK pRARSetCallback; +typedef int (_stdcall* RARGETDLLVERSION)(void); +static RARGETDLLVERSION pRARGetDllVersion; + +static int rar_resetf(struct zfile *z) +{ + z->f = fopen (z->name, "rb"); + if (!z->f) { + zfile_fclose (z); + return 0; + } + return 1; +} + +static int canrar(void) +{ + static int israr; + HMODULE rarlib; + + if (israr == 0) { + israr = -1; + rarlib = WIN32_LoadLibrary("unrar.dll"); + if (rarlib) { + pRAROpenArchive = (RAROPENARCHIVE)GetProcAddress (rarlib, "RAROpenArchive"); + pRARReadHeaderEx = (RARREADHEADEREX)GetProcAddress (rarlib, "RARReadHeaderEx"); + pRARProcessFile = (RARPROCESSFILE)GetProcAddress (rarlib, "RARProcessFile"); + pRARCloseArchive = (RARCLOSEARCHIVE)GetProcAddress (rarlib, "RARCloseArchive"); + pRARSetCallback = (RARSETCALLBACK)GetProcAddress (rarlib, "RARSetCallback"); + pRARGetDllVersion = (RARGETDLLVERSION)GetProcAddress (rarlib, "RARGetDllVersion"); + if (pRAROpenArchive && pRARReadHeaderEx && pRARProcessFile && pRARCloseArchive && pRARSetCallback) { + israr = 1; + write_log ("unrar.dll version %08.8X detected and used\n", pRARGetDllVersion ? pRARGetDllVersion() : -1); + + } + } + } + return israr < 0 ? 0 : 1; +} + static int CALLBACK RARCallbackProc(UINT msg,LONG UserData,LONG P1,LONG P2) { if (msg == UCM_PROCESSDATA) { @@ -726,28 +774,39 @@ static int CALLBACK RARCallbackProc(UINT msg,LONG UserData,LONG P1,LONG P2) static struct zfile *unrar (struct zfile *z) { HANDLE hArcData; - int RHCode,PFCode; static int first = 1; char tmphist[MAX_DPATH]; struct zfile *zf; - int zipcnt = 0; + int zipcnt; int we_have_file = 0; - struct RARHeaderData HeaderData; - struct RAROpenArchiveDataEx OpenArchiveData; + struct RARHeaderDataEx HeaderData; + struct RAROpenArchiveData OpenArchiveData; + + if (!canrar()) + return arcacc_unpack (z, ArchiveFormatRAR); if (z->data) - return z; /* wtf? stupid unrar.dll only accept filename as an input.. */ + /* wtf? stupid unrar.dll only accept filename as an input.. */ + return arcacc_unpack (z, ArchiveFormatRAR); + fclose (z->f); /* bleh, unrar.dll fails to open the archive if it is already open.. */ + z->f = NULL; zf = 0; memset(&OpenArchiveData,0,sizeof(OpenArchiveData)); OpenArchiveData.ArcName=z->name; OpenArchiveData.OpenMode=RAR_OM_EXTRACT; - hArcData=RAROpenArchiveEx(&OpenArchiveData); - if (OpenArchiveData.OpenResult!=0) - return z; - RARSetCallback(hArcData,RARCallbackProc,0); - while ((RHCode=RARReadHeader(hArcData,&HeaderData))==0) { + hArcData=pRAROpenArchive(&OpenArchiveData); + if (OpenArchiveData.OpenResult!=0) { + if (!rar_resetf(z)) + return NULL; + return arcacc_unpack (z, ArchiveFormatRAR); + } + pRARSetCallback(hArcData,RARCallbackProc,0); + tmphist[0] = 0; + zipcnt = 0; + while (pRARReadHeaderEx(hArcData,&HeaderData)==0) { int select = 0; + int needskip = 1; char *name = HeaderData.FileName; zipcnt++; if (zfile_is_ignore_ext(name)) @@ -774,7 +833,8 @@ static struct zfile *unrar (struct zfile *z) if (select && !we_have_file && HeaderData.UnpSize > 0) { zf = zfile_fopen_empty (name, HeaderData.UnpSize); rarunpackzf = zf; - if (zf && (PFCode=RARProcessFile(hArcData,RAR_EXTRACT,NULL,NULL)) != 0) { + if (zf && pRARProcessFile(hArcData,RAR_EXTRACT,NULL,NULL) == 0) { + needskip = 0; if (select < 0 || zfile_gettype(zf)) we_have_file = 1; if (!we_have_file) { @@ -783,16 +843,21 @@ static struct zfile *unrar (struct zfile *z) } } } + if (needskip) + pRARProcessFile(hArcData,RAR_SKIP,NULL,NULL); } - RARCloseArchive(hArcData); + pRARCloseArchive(hArcData); if (zf) { zfile_fclose (z); z = zf; zfile_fseek (z, 0, SEEK_SET); + } else { + /* bleh continues, reopen the closed archive.. */ + if (!rar_resetf(z)) + z = NULL; } return z; } -#endif static struct zfile *unzip (struct zfile *z) { @@ -891,9 +956,11 @@ static int iszip (struct zfile *z) zfile_fread (header, sizeof (header), 1, z); zfile_fseek (z, 0, SEEK_SET); if (!strcasecmp (ext, ".zip") && header[0] == 'P' && header[1] == 'K') - return -1; + return ArchiveFormatZIP; if (!strcasecmp (ext, ".7z") && header[0] == '7' && header[1] == 'z') - return -2; + return ArchiveFormat7Zip; + if (!strcasecmp (ext, ".rar") && header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!') + return ArchiveFormatRAR; #if defined(ARCHIVEACCESS) for (i = 0; plugins_7z[i]; i++) { if (plugins_7z_x[i] && !strcasecmp (ext + 1, plugins_7z[i]) && @@ -927,6 +994,8 @@ static struct zfile *zuncompress (struct zfile *z) return zfile_gunzip (z); if (strcasecmp (ext, "dms") == 0) return dms (z); + if (strcasecmp (ext, "rar") == 0) + return unrar (z); #if defined(ARCHIVEACCESS) for (i = 0; plugins_7z[i]; i++) { if (strcasecmp (ext, plugins_7z[i]) == 0) @@ -944,6 +1013,8 @@ static struct zfile *zuncompress (struct zfile *z) return zfile_gunzip (z); if (header[0] == 'P' && header[1] == 'K') return unzip (z); + if (header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!') + return unrar (z); if (header[0] == 'D' && header[1] == 'M' && header[2] == 'S' && header[3] == '!') return dms (z); } @@ -1118,6 +1189,55 @@ static int scan_arcacc_zunzip (struct zfile *z, zfile_callback zc, void *user, i return 1; } +// rar scan +static int scan_rar (struct zfile *z, zfile_callback zc, void *user) +{ + HANDLE hArcData; + struct RARHeaderDataEx HeaderData; + struct RAROpenArchiveData OpenArchiveData; + + if (!canrar()) + return scan_arcacc_zunzip (z, zc, user, ArchiveFormatRAR); + if (z->data) + return scan_arcacc_zunzip (z, zc, user, ArchiveFormatRAR); + fclose (z->f); + z->f = NULL; + memset(&OpenArchiveData,0,sizeof(OpenArchiveData)); + OpenArchiveData.ArcName=z->name; + OpenArchiveData.OpenMode=RAR_OM_EXTRACT; + hArcData=pRAROpenArchive(&OpenArchiveData); + if (OpenArchiveData.OpenResult!=0) { + rar_resetf(z); + return 0; + } + pRARSetCallback(hArcData,RARCallbackProc,0); + while (pRARReadHeaderEx(hArcData,&HeaderData)==0) { + int needskip = 1; + char *name = HeaderData.FileName; + if (HeaderData.UnpSize > 0) { + struct zfile *zf = zfile_fopen_empty (name, HeaderData.UnpSize); + rarunpackzf = zf; + if (zf && pRARProcessFile(hArcData,RAR_EXTRACT,NULL,NULL) == 0) { + needskip = 0; + zfile_fseek (zf, 0, SEEK_SET); + if (!zc (zf, user)) { + pRARCloseArchive(hArcData); + zfile_fclose (zf); + rar_resetf (z); + return 0; + } + } + zfile_fclose (zf); + } + if (needskip) + pRARProcessFile(hArcData,RAR_SKIP,NULL,NULL); + } + pRARCloseArchive(hArcData); + if (!rar_resetf (z)) + return 0; + return 1; +} + /* zip (zlib) scanning */ static int scan_zunzip (struct zfile *z, zfile_callback zc, void *user) { @@ -1246,10 +1366,12 @@ int zfile_zopen (const char *name, zfile_callback zc, void *user) ztype = iszip (l); if (ztype == 0) zc (l, user); - else if (ztype == -1) + else if (ztype == ArchiveFormatZIP) scan_zunzip (l, zc, user); - else if (ztype == -2) + else if (ztype == ArchiveFormat7Zip) scan_7z (l, zc, user); + else if (ztype == ArchiveFormatRAR) + scan_rar (l, zc, user); else scan_arcacc_zunzip (l, zc, user, ztype); zfile_fclose (l); -- 2.47.3