]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
2300b20
authorToni Wilen <twilen@winuae.net>
Wed, 22 Sep 2010 17:14:41 +0000 (20:14 +0300)
committerToni Wilen <twilen@winuae.net>
Wed, 22 Sep 2010 17:14:41 +0000 (20:14 +0300)
12 files changed:
include/gfxfilter.h
include/zfile.h
memory.cpp
od-win32/win32.cpp
od-win32/win32.h
od-win32/win32_scaler.cpp
od-win32/win32gui.cpp
od-win32/winuaechangelog.txt
prowizard/rippers/GameMusicCreator.c [deleted file]
prowizard/rippers/NoisePacker3.c [deleted file]
zfile.cpp
zfile_archive.cpp

index 73150e5e1e4d81c37bf27b5502cbd7a7519d2fc9..98a68d1431d51b6d02db9929a4497a3835673dd7 100644 (file)
@@ -76,7 +76,6 @@ struct uae_filter
 extern struct uae_filter uaefilters[];
 extern struct uae_filter *usedfilter;
 
-uae_u8 *getfilterrect1 (RECT *sr, RECT *dr, int dst_depth, int aw, int ah, int scale, int temp_width, int temp_height, uae_u8 *dptr, int pitch);
 void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height, int aw, int ah, int scale, int temp_width, int temp_height);
 void getfilteroffset (int *dx, int *dy, int *mx, int *my);
 uae_u8 *getfilterbuffer (int *widthp, int *heightp, int *pitch, int *depth);
index 72148ff98e08503441e2d4d16c79bebaf005b4ec..fb7be8b2958acce4cfcd31efdc8bcf3c7f5abdd5 100644 (file)
@@ -119,3 +119,4 @@ extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int s
 extern void zfile_close_archive (struct zfile *d);
 extern struct zfile *zfile_open_archive (const TCHAR *path, int flags);
 extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel);
+extern bool zfile_needwrite (struct zfile*);
\ No newline at end of file
index ad24ace892961d61cf5c743d5c3a7c8defb83507..4763d6d008d0972c55064516b81d6ba5b3129066 100644 (file)
@@ -1999,15 +1999,15 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file)
        int id;
        void *answer;
        shmpiece *x;
+       static int recurse;
 
-       if (!canjit()) {
+       if (!canjit ()) {
                nocanbang ();
                return xcalloc (uae_u8, s + 4);
        }
 
        id = shmget (IPC_PRIVATE, s, 0x1ff, file);
        if (id == -1) {
-               static int recurse;
                uae_u8 *p;
                nocanbang ();
                if (recurse)
@@ -2031,8 +2031,13 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file)
                shm_start = x;
                return (uae_u8*)answer;
        }
+       if (recurse)
+               return NULL;
        nocanbang ();
-       return mapped_malloc (s, file);
+       recurse++;
+       uae_u8 *r =  mapped_malloc (s, file);
+       recurse--;
+       return r;
 }
 
 #endif
index 12db19ea38533270430ee91415607d98f28d6c7a..f9093e684d9593ffa7bfc2b24a282515d9332812 100644 (file)
@@ -2837,7 +2837,7 @@ static const TCHAR *obsolete[] = {
        L"killwinkeys", L"sound_force_primary", L"iconified_highpriority",
        L"sound_sync", L"sound_tweak", L"directx6", L"sound_style",
        L"file_path", L"iconified_nospeed", L"activepriority", L"magic_mouse",
-       L"filesystem_codepage", L"aspi",
+       L"filesystem_codepage", L"aspi", L"no_overlay",
        0
 };
 
index f976a2df9cdc635856529c00b75e035b73bcaf39..29f112015187eeec06fa10bc597f54355e992f81 100644 (file)
@@ -18,9 +18,9 @@
 #define WINUAEPUBLICBETA 1
 #define LANG_DLL 1
 
-#define WINUAEBETA L"19"
-#define WINUAEDATE MAKEBD(2010, 9, 19)
-#define WINUAEEXTRA L"RC2"
+#define WINUAEBETA L"20"
+#define WINUAEDATE MAKEBD(2010, 9, 22)
+#define WINUAEEXTRA L"RC3"
 #define WINUAEREV L""
 
 #define IHF_WINDOWHIDDEN 6
index 4255492a50d0a2353ee460c86d25fc028d04de34..852a6035bc5293b8bd204766b951bfe14e82d0e7 100644 (file)
@@ -108,10 +108,12 @@ static int vblscale2 (int v)
        return v;
 }
 
-static void fixh (int *ah, int *th)
+static void fixh (int *ah, int *th, int minh)
 {
        if (!(beamcon0 & 0x80)) {
                int max = ((572 / 2) * scale) << currprefs.gfx_vresolution;
+               if (minh && max < minh)
+                       max = minh;
                if (*ah > max)
                        *ah = max;
                if (*th > max)
@@ -119,11 +121,11 @@ static void fixh (int *ah, int *th)
        }
 }
 
-uae_u8 *getfilterrect1 (RECT *sr, RECT *dr, int dst_depth, int aw, int ah, int scale, int temp_width, int temp_height, uae_u8 *dptr, int pitch)
+static uae_u8 *getfilterrect1 (RECT *sr, RECT *dr, int dst_width, int dst_height, int dst_depth, int aw, int ah, int scale, int temp_width, int temp_height, uae_u8 *dptr, int pitch)
 {
        int aws, ahs;
 
-       fixh (&ah, &temp_height);
+       fixh (&ah, &temp_height, dst_height);
 
        aws = aw * scale;
        ahs = ah * scale;
@@ -172,7 +174,7 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height
 
        fpux_save (&fpuv);
 
-       fixh (&ah, &temp_height);
+       fixh (&ah, &temp_height, dst_height);
 
        getinit ();
        ahs2 = vblscale (ah) * scale;
@@ -658,7 +660,7 @@ void S2X_render (void)
        dptr = surfstart;
        enddptr = dptr + pitch * temp_height;
        if (!d3d) {
-               dptr = getfilterrect1 (&sr, &dr, dst_depth, aw, ah, scale, temp_width, temp_height, dptr, pitch);
+               dptr = getfilterrect1 (&sr, &dr, dst_width, dst_height, dst_depth, aw, ah, scale, temp_width, temp_height, dptr, pitch);
        }
 
        if (!dptr) /* weird things can happen */
index 0663bdf103292d39659e7bebed1b23b93dcbe70d..7563051e3ebc3865dd6b1288b55d7d4e35ee2355 100644 (file)
@@ -4158,18 +4158,16 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co
                HandleConfiguration (hDlg, CONFIG_SAVE_FULL, config, newpath);
                DeleteConfigTree (hDlg);
                config = CreateConfigStore (config, TRUE);
-               config = fixloadconfig (hDlg, config);
                ConfigToRegistry (config, configtypepanel);
-               InitializeConfigTreeView (hDlg);
+               config = initloadsave (hDlg, config);
                InitializeConfig (hDlg, config);
                break;
        case IDC_QUICKSAVE:
                HandleConfiguration (hDlg, CONFIG_SAVE, config, NULL);
                DeleteConfigTree (hDlg);
                config = CreateConfigStore (config, TRUE);
-               config = fixloadconfig (hDlg, config);
                ConfigToRegistry (config, configtypepanel);
-               InitializeConfigTreeView (hDlg);
+               config = initloadsave (hDlg, config);
                InitializeConfig (hDlg, config);
                break;
        case IDC_QUICKLOAD:
@@ -4198,8 +4196,8 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co
                HandleConfiguration (hDlg, CONFIG_DELETE, config, NULL);
                DeleteConfigTree (hDlg);
                config = CreateConfigStore (config, TRUE);
-               config = fixloadconfig (hDlg, config);
-               InitializeConfigTreeView (hDlg);
+               config = initloadsave (hDlg, config);
+               InitializeConfig (hDlg, config);
                break;
        case IDC_VIEWINFO:
                if (workprefs.info[0]) {
@@ -4730,6 +4728,7 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                                set_path (L"SaveimagePath", NULL, path_type);
                                set_path (L"VideoPath", NULL, path_type);
                                set_path (L"RipperPath", NULL, path_type);
+                               set_path (L"InputPath", NULL, path_type);
                                values_to_pathsdialog (hDlg);
                                FreeConfigStore ();
                        }
index ecfb0e0d14994e869f7b9b0e0e9cdfc0dbb5eb17..c53fd08abdffccbb4888ed57d4488d957f147ab8 100644 (file)
@@ -1,5 +1,13 @@
 
-- rar archives crashed if file was already open (due to design flaw, it was possible to
+Beta 20 (RC3):
+
+- Configuration panel save and delete operations lost currently selected configuration entry
+- some filters in DirectDraw mode had blank screen (depended on display height)
+- VirtualAlloc() allocation error and JIT direct enabled recursed until stack overflowed
+
+Beta 19 (RC2):
+
+- rar archives crashed if file was already open (stupid design flaw, it was possible to
   open archives even if requested mode was read-write)
 - added "fullscreen (max)" and "fullscreen (tv)" (approximate only) to "autoscale" select
   menu, basically replaces old "FS" filter multiplier
diff --git a/prowizard/rippers/GameMusicCreator.c b/prowizard/rippers/GameMusicCreator.c
deleted file mode 100644 (file)
index d2f2f85..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/* testGMC() */
-/* Rip_GMC() */
-/* Depack_GMC() */
-
-#include "globals.h"
-#include "extern.h"
-
-
-short testGMC ( void )
-{
-  /* test #1 */
-  if ( (PW_i<7) || ((PW_Start_Address+444)>PW_in_size) )
-  {
-/*printf ( "#1\n" );*/
-    return BAD;
-  }
-  PW_Start_Address = PW_i-7;
-
-  /* samples descriptions */
-  PW_WholeSampleSize=0;
-  PW_j=0;
-  for ( PW_k = 0 ; PW_k < 15 ; PW_k ++ )
-  {
-    PW_o = (in_data[PW_Start_Address+16*PW_k+4]*256)+in_data[PW_Start_Address+16*PW_k+5];
-    PW_n = (in_data[PW_Start_Address+16*PW_k+12]*256)+in_data[PW_Start_Address+16*PW_k+13];
-    PW_o *= 2;
-    /* volumes */
-    if ( in_data[PW_Start_Address + 7 + (16*PW_k)] > 0x40 )
-    {
-/*printf ( "#2\n" );*/
-      return BAD;
-    }
-    /* size */
-    if ( PW_o > 0xFFFF )
-    {
-/*printf ( "#2,1 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    if ( PW_n > PW_o )
-    {
-/*printf ( "#2,2 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    PW_WholeSampleSize += PW_o;
-    if ( PW_o != 0 )
-      PW_j = PW_k+1;
-  }
-  if ( PW_WholeSampleSize <= 4 )
-  {
-/*printf ( "#2,3 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-  /* PW_j is the highest not null sample */
-
-  /* pattern table size */
-  if ( ( in_data[PW_Start_Address+243] > 0x64 ) ||
-       ( in_data[PW_Start_Address+243] == 0x00 ) )
-  {
-    return BAD;
-  }
-
-  /* pattern order table */
-  PW_l=0;
-  for ( PW_n=0 ; PW_n<100 ; PW_n++ )
-  {
-    PW_k = ((in_data[PW_Start_Address+244+PW_n*2]*256)+
-           in_data[PW_Start_Address+245+PW_n*2]);
-    if ( ((PW_k/1024)*1024) != PW_k )
-    {
-/*printf ( "#4 Start:%ld (PW_k:%ld)\n" , PW_Start_Address , PW_k);*/
-      return BAD;
-    }
-    PW_l = ((PW_k/1024)>PW_l) ? PW_k/1024 : PW_l;
-  }
-  PW_l += 1;
-  /* PW_l is the number of pattern */
-  if ( (PW_l == 1) || (PW_l >0x64) )
-  {
-    return BAD;
-  }
-
-  /* test pattern data */
-  PW_o = in_data[PW_Start_Address+243];
-  PW_m = 0;
-  for ( PW_k=0 ; PW_k<PW_l ; PW_k++ )
-  {
-    for ( PW_n=0 ; PW_n<256 ; PW_n++ )
-    {
-      if ( ( in_data[PW_Start_Address+444+PW_k*1024+PW_n*4] > 0x03 ) ||
-          ( (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) >= 0x90 ))
-      {
-/*printf ( "#5,0 Start:%ld (PW_k:%ld)\n" , PW_Start_Address , PW_k);*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0xf0)>>4) > PW_j )
-      {
-/*printf ( "#5,1 Start:%ld (PW_j:%ld) (where:%ld) (value:%x)\n"
-         , PW_Start_Address , PW_j , PW_Start_Address+444+PW_k*1024+PW_n*4+2
-         , ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0xf0)>>4) );*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 3) &&
-           (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > 0x40) )
-      {
-/*printf ( "#5,2 Start:%ld (PW_j:%ld)\n" , PW_Start_Address , PW_j);*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 4) &&
-           (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > 0x63) )
-      {
-/*printf ( "#5,3 Start:%ld (PW_j:%ld)\n" , PW_Start_Address , PW_j);*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 5) &&
-           (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > PW_o+1) )
-      {
-/*printf ( "#5,4 Start:%ld (effect:5)(PW_o:%ld)(4th note byte:%x)\n" , PW_Start_Address , PW_j , in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3]);*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 6) &&
-           (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] >= 0x02) )
-      {
-/*printf ( "#5,5 Start:%ld (at:%ld)\n" , PW_Start_Address , PW_Start_Address+444+PW_k*1024+PW_n*4+3 );*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 7) &&
-           (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] >= 0x02) )
-      {
-/*printf ( "#5,6 Start:%ld (at:%ld)\n" , PW_Start_Address , PW_Start_Address+444+PW_k*1024+PW_n*4+3 );*/
-       return BAD;
-      }
-      if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4]&0x0f) > 0x00) || (in_data[PW_Start_Address+445+PW_k*1024+PW_n*4] > 0x00) )
-       PW_m = 1;
-    }
-  }
-  if ( PW_m == 0 )
-  {
-    /* only empty notes */
-    return BAD;
-  }
-  /* PW_WholeSampleSize is the whole sample size */
-
-  return GOOD;
-}
-
-
-void Rip_GMC ( void )
-{
-  /* PW_l is still the number of pattern to play */
-  /* PW_WholeSampleSize is already the whole sample size */
-
-  OutputSize = PW_WholeSampleSize + (PW_l*1024) + 444;
-
-  CONVERT = GOOD;
-  Save_Rip ( "Game Music Creator module", GMC );
-  
-  if ( Save_Status == GOOD )
-    PW_i += 444; /* after header */
-}
-
-/*
- *   Game_Music_Creator.c   1997 (c) Sylvain "Asle" Chipaux
- *
- * Depacks musics in the Game Music Creator format and saves in ptk.
- *
- * Last update: 30/11/99
- *   - removed open() (and other fread()s and the like)
- *   - general Speed & Size Optmizings
-*/
-
-
-void Depack_GMC ( void )
-{
-  Uchar *Whatever;
-  Uchar Max=0x00;
-  long WholeSampleSize=0;
-  long i=0,j=0;
-  long Where = PW_Start_Address;
-  FILE *out;
-
-  if ( Save_Status == BAD )
-    return;
-
-  sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 );
-  out = PW_fopen ( Depacked_OutName , "w+b" );
-
-  /* title */
-  Whatever = (Uchar *) malloc ( 1024 );
-  BZERO ( Whatever , 1024 );
-  fwrite ( Whatever , 20 , 1 , out );
-
-  /* read and write whole header */
-  /*printf ( "Converting sample headers ... " );*/
-  for ( i=0 ; i<15 ; i++ )
-  {
-    /* write name */
-    fwrite ( Whatever , 22 , 1 , out );
-
-    /* size */
-    fwrite ( &in_data[Where+4] , 2 , 1 , out );
-    WholeSampleSize += (((in_data[Where+4]*256)+in_data[Where+5])*2);
-
-    /* finetune */
-    fwrite ( Whatever , 1 , 1 , out );
-
-    /* volume */
-    fwrite ( &in_data[Where+7] , 1 , 1 , out );
-
-    /* loop size */
-    Whatever[32] = in_data[Where+12];
-    Whatever[33] = in_data[Where+13];
-
-    /* loop start */
-    Whatever[34] = in_data[Where+14];
-    Whatever[35] = in_data[Where+15];
-    Whatever[35] /= 2;
-    if ( (Whatever[34]/2)*2 != Whatever[34] )
-    {
-      if ( Whatever[35] < 0x80 )
-        Whatever[35] += 0x80;
-      else
-      {
-        Whatever[35] -= 0x80;
-        Whatever[34] += 0x01;
-      }
-    }
-    Whatever[34] /= 2;
-    fwrite ( &Whatever[34] , 1 , 1 , out );
-    fwrite ( &Whatever[35] , 1 , 1 , out );
-    Whatever[33] /= 2;
-    if ( (Whatever[32]/2)*2 != Whatever[32] )
-    {
-      if ( Whatever[33] < 0x80 )
-        Whatever[33] += 0x80;
-      else
-      {
-        Whatever[33] -= 0x80;
-        Whatever[32] += 0x01;
-      }
-    }
-    Whatever[32] /= 2;
-    if ( (Whatever[32]==0x00) && (Whatever[33]==0x00) )
-      Whatever[33] = 0x01;
-    fwrite ( &Whatever[32] , 1 , 1 , out );
-    fwrite ( &Whatever[33] , 1 , 1 , out );
-
-    Where += 16;
-  }
-  Whatever[129] = 0x01;
-  for ( i=0 ; i<16 ; i++ )
-    fwrite ( &Whatever[100] , 30 , 1 , out );
-  /*printf ( "ok\n" );*/
-
-  /* pattern list size */
-  Where = PW_Start_Address + 0xF3;
-  fwrite ( &in_data[Where++] , 1 , 1 , out );
-
-  /* ntk byte */
-  Whatever[0] = 0x7f;
-  fwrite ( Whatever , 1 , 1 , out );
-
-  /* read and write size of pattern list */
-  /*printf ( "Creating the pattern table ... " );*/
-  BZERO (Whatever , 1024);
-  for ( i=0 ; i<100 ; i++ )
-  {
-    Whatever[i] = ((in_data[Where]*256)+in_data[Where+1])/1024;
-    Where += 2;
-  }
-  fwrite ( Whatever , 128 , 1 , out );
-
-  /* get number of pattern */
-  Max = 0x00;
-  for ( i=0 ; i<128 ; i++ )
-  {
-    if ( Whatever[i] > Max )
-      Max = Whatever[i];
-  }
-  /*printf ( "ok\n" );*/
-
-
-  /* write ID */
-  Whatever[0] = 'M';
-  Whatever[1] = '.';
-  Whatever[2] = 'K';
-  Whatever[3] = '.';
-  fwrite ( Whatever , 4 , 1 , out );
-
-
-  /* pattern data */
-  /*printf ( "Converting pattern datas " );*/
-  Where = PW_Start_Address + 444;
-  for ( i=0 ; i<=Max ; i++ )
-  {
-    BZERO ( Whatever , 1024 );
-    for ( j=0 ; j<1024 ; j++ ) Whatever[j] = in_data[Where++];
-    for ( j=0 ; j<256 ; j++ )
-    {
-      switch ( Whatever[(j*4)+2]&0x0f )
-      {
-        case 3: /* replace by C */
-          Whatever[(j*4)+2] += 0x09;
-          break;
-        case 4: /* replace by D */
-          Whatever[(j*4)+2] += 0x09;
-          break;
-        case 5: /* replace by B */
-          Whatever[(j*4)+2] += 0x06;
-          break;
-        case 6: /* replace by E0 */
-          Whatever[(j*4)+2] += 0x08;
-          break;
-        case 7: /* replace by E0 */
-          Whatever[(j*4)+2] += 0x07;
-          break;
-        case 8: /* replace by F */
-          Whatever[(j*4)+2] += 0x07;
-          break;
-        default:
-          break;
-      }
-    }
-    fwrite ( Whatever , 1024 , 1 , out );
-    /*printf ( "." );*/
-    /*fflush ( stdout );*/
-  }
-  free ( Whatever );
-  /*printf ( " ok\n" );*/
-  /*fflush ( stdout );*/
-
-  /* sample data */
-  /*printf ( "Saving sample data ... " );*/
-  fwrite ( &in_data[Where] , WholeSampleSize , 1 , out );
-  /*printf ( "ok\n" );*/
-  /*fflush ( stdout );*/
-
-  /* crap */
-  Crap ( "Game Music Creator" , BAD , BAD , out );
-
-  fflush ( out );
-  fclose ( out );
-
-  printf ( "done\n" );
-  return; /* useless ... but */
-}
diff --git a/prowizard/rippers/NoisePacker3.c b/prowizard/rippers/NoisePacker3.c
deleted file mode 100644 (file)
index 12d3198..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/* testNoisepacker3() */
-/* Rip_Noisepacker3() */
-/* Depack_Noisepacker3() */
-
-#include "globals.h"
-#include "extern.h"
-
-short testNoisepacker3 ( void )
-{
-  if ( PW_i < 9 )
-  {
-    return BAD;
-  }
-  PW_Start_Address = PW_i-9;
-
-  /* size of the pattern table */
-  PW_j = (in_data[PW_Start_Address+2]*256)+in_data[PW_Start_Address+3];
-  if ( (((PW_j/2)*2) != PW_j) || (PW_j == 0) )
-  {
-/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-  /* PW_j is the size of the pattern list (*2) */
-
-  /* test nbr of samples */
-  if ( (in_data[PW_Start_Address+1]&0x0f) != 0x0C )
-  {
-/*printf ( "#3,0 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-  PW_l = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f);
-  if ( (PW_l > 0x1F) || (PW_l == 0) || ((PW_Start_Address+8+PW_j+PW_l*8)>PW_in_size))
-  {
-/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-  /* PW_l is the number of samples */
-
-  /* test volumes */
-  for ( PW_k=0 ; PW_k<PW_l ; PW_k++ )
-  {
-    if ( in_data[PW_Start_Address+9+PW_k*16] > 0x40 )
-    {
-      return BAD;
-    }
-  }
-
-  /* test sample sizes */
-  PW_WholeSampleSize=0;
-  for ( PW_k=0 ; PW_k<PW_l ; PW_k++ )
-  {
-    PW_o = (in_data[PW_Start_Address+PW_k*16+14]*256)+in_data[PW_Start_Address+PW_k*16+15];
-    PW_m = (in_data[PW_Start_Address+PW_k*16+20]*256)+in_data[PW_Start_Address+PW_k*16+21];
-    PW_n = (in_data[PW_Start_Address+PW_k*16+22]*256)+in_data[PW_Start_Address+PW_k*16+23];
-    PW_o *= 2;
-    PW_m *= 2;
-    PW_n *= 2;
-    if ( (PW_o > 0xFFFF) ||
-         (PW_m > 0xFFFF) ||
-         (PW_n > 0xFFFF) )
-    {
-/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    if ( (PW_m + PW_n) > (PW_o+2) )
-    {
-/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    if ( (PW_n != 0) && (PW_m == 0) )
-    {
-/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    PW_WholeSampleSize += PW_o;
-  }
-  if ( PW_WholeSampleSize <= 4 )
-  {
-/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-
-
-  /* small shit to gain some vars */
-  PW_l *= 16;
-  PW_l += 8;
-  PW_l += 4;
-  /* PW_l is now the size of the header 'til the end of sample descriptions */
-  if ( (PW_l+PW_Start_Address) > PW_in_size )
-  {
-/* printf ( "NP3 Header bigger than file size (%ld > %ld)\n", PW_l, PW_in_size);*/
-    return BAD;
-  }
-
-
-  /* test pattern table */
-  PW_n=0;
-  for ( PW_k=0 ; PW_k<PW_j ; PW_k += 2 )
-  {
-    PW_m = ((in_data[PW_Start_Address+PW_l+PW_k]*256)+in_data[PW_Start_Address+PW_l+PW_k+1]);
-    if ( ((PW_m/8)*8) != PW_m )
-    {
-/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/
-      return BAD;
-    }
-    if ( PW_m > PW_n )
-      PW_n = PW_m;
-  }
-  PW_l += PW_j;
-  PW_l += PW_n;
-  PW_l += 8; /*paske on a que l'address du dernier pattern .. */
-  /* PW_l is now the size of the header 'til the end of the track list */
-  /* PW_j is now available for use :) */
-  /* PW_n is the highest pattern number (*8) */
-
-  /* test track data size */
-  PW_k = (in_data[PW_Start_Address+6]*256)+in_data[PW_Start_Address+7];
-  if ( (PW_k <= 63) || ((PW_k+PW_l+PW_Start_Address)>PW_in_size))
-  {
-/*printf ( "#7 Start:%ld\n" , PW_Start_Address );*/
-    return BAD;
-  }
-
-  /* test notes */
-  /* re-calculate the number of sample */
-  /* PW_k is the track data size */
-  PW_j = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f);
-  for ( PW_m=0 ; PW_m < PW_k ; PW_m++ )
-  {
-    if ( (in_data[PW_Start_Address+PW_l+PW_m]&0x80) == 0x80 )
-      continue;
-    /* si note trop grande et si effet = A */
-    if ( (in_data[PW_Start_Address+PW_l+PW_m] > 0x49)||
-        ((in_data[PW_Start_Address+PW_l+PW_m+1]&0x0f) == 0x0A) )
-    {
-/*printf ( "#8 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m );*/
-      return BAD;
-    }
-    /* si effet D et arg > 0x40 */
-    if ( ((in_data[PW_Start_Address+PW_l+PW_m+1]&0x0f) == 0x0D )&&
-        (in_data[PW_Start_Address+PW_l+PW_m+2] > 0x40 ) )
-    {
-/*printf ( "#8 Start:%ld (at %ld)(effet:%d)(arg:%ld)\n"
-          , PW_Start_Address
-          , PW_Start_Address+PW_l+PW_m
-          , (PW_Start_Address+PW_l+PW_m+1)&0x0f
-          , (PW_Start_Address+PW_l+PW_m+2) );*/
-      return BAD;
-    }
-    /* sample nbr > ce qui est defini au debut ? */
-    if ( (((in_data[PW_Start_Address+PW_l+PW_m]<<4)&0x10)|
-        ((in_data[PW_Start_Address+PW_l+PW_m+1]>>4)&0x0f)) > PW_j )
-    {
-/*printf ( "#8,1 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/
-      return BAD;
-    }
-    /* all is empty ?!? ... cannot be ! */
-    if ( (in_data[PW_Start_Address+PW_l+PW_m]   == 0) &&
-         (in_data[PW_Start_Address+PW_l+PW_m+1] == 0) &&
-         (in_data[PW_Start_Address+PW_l+PW_m+2] == 0) && (PW_m<(PW_k-3)) )
-    {
-/*printf ( "#8,2 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/
-      return BAD;
-    }
-    PW_m += 2;
-  }
-
-  /* PW_WholeSampleSize is the size of the sample data */
-  /* PW_l is the size of the header 'til the track datas */
-  /* PW_k is the size of the track datas */
-  return GOOD;
-}
-
-
-
-void Rip_Noisepacker3 ( void )
-{
-  OutputSize = PW_k + PW_WholeSampleSize + PW_l;
-  /*  printf ( "\b\b\b\b\b\b\b\bNoisePacker v3 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/
-
-  CONVERT = GOOD;
-  Save_Rip ( "NoisePacker v3 module", Noisepacker3 );
-  
-  if ( Save_Status == GOOD )
-    PW_i += (OutputSize - 16);  /* 15 should do but call it "just to be sure" :) */
-}
-
-
-
-/*
- *   NoisePacker_v3.c   1998 (c) Asle / ReDoX
- *
- * Converts NoisePacked MODs back to ptk
- * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux
- *                 reduced to only one FREAD.
- *                 Speed-up and Binary smaller.
- * update : 01/12/99
- *   - removed fopen() and attached funcs.
-*/
-void Depack_Noisepacker3 ( void )
-{
-  Uchar *Whatever;
-  Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00;
-  Uchar Nbr_Pos;
-  Uchar Nbr_Smp;
-  Uchar poss[36][2];
-  Uchar Pat_Max=0x00;
-  long Where=PW_Start_Address;
-  long WholeSampleSize=0;
-  long TrackDataSize;
-  long Track_Addresses[128][4];
-  long Unknown1;
-  long i=0,j=0,k;
-  long Track_Data_Start_Address;
-  long SampleDataAddress=0;
-  FILE *out;
-
-  if ( Save_Status == BAD )
-    return;
-
-  fillPTKtable(poss);
-
-  BZERO ( Track_Addresses , 128*4*4 );
-
-  sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 );
-  out = PW_fopen ( Depacked_OutName , "w+b" );
-
-  /* read number of sample */
-  Nbr_Smp = ((in_data[Where]<<4)&0xf0) | ((in_data[Where+1]>>4)&0x0f);
-  /*printf ( "\nNumber of sample : %d (%x)\n" , Nbr_Smp , Nbr_Smp );*/
-
-  /* write title */
-  Whatever = (Uchar *) malloc ( 1024 );
-  BZERO ( Whatever , 1024 );
-  fwrite ( Whatever , 20 , 1 , out );
-
-  /* read size of pattern list */
-  Nbr_Pos = in_data[Where+3]/2;
-  /*printf ( "Size of pattern list : %d\n" , Nbr_Pos );*/
-
-  /* read 2 unknown bytes which size seem to be of some use ... */
-  Unknown1 = (in_data[Where+4]*256)+in_data[Where+5];
-
-  /* read track data size */
-  TrackDataSize = (in_data[Where+6]*256)+in_data[Where+7];
-  /*printf ( "TrackDataSize : %ld\n" , TrackDataSize );*/
-
-  /* read sample descriptions */
-  Where += 8;
-  for ( i=0 ; i<Nbr_Smp ; i++ )
-  {
-    /* sample name */
-    fwrite ( Whatever , 22 , 1 , out );
-    /* size */
-    fwrite ( &in_data[Where+6] , 2 , 1 , out );
-    WholeSampleSize += (((in_data[Where+6]*256)+in_data[Where+7])*2);
-    /* write finetune,vol */
-    fwrite ( &in_data[Where] , 2 , 1 , out );
-    /* write loop start */
-    fwrite ( &in_data[Where+14] , 2 , 1 , out );
-    /* write loop size */
-    fwrite ( &in_data[Where+12] , 2 , 1 , out );
-    Where += 16;
-  }
-  /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/
-
-  /* fill up to 31 samples */
-  Whatever[29] = 0x01;
-  while ( i != 31 )
-  {
-    fwrite ( Whatever , 30 , 1 , out );
-    i += 1;
-  }
-
-  /* write size of pattern list */
-  fwrite ( &Nbr_Pos , 1 , 1 , out );
-
-  /* write noisetracker byte */
-  c1 = 0x7f;
-  fwrite ( &c1 , 1 , 1 , out );
-
-  /* bypass 2 bytes ... seems always the same as in $02 */
-  /* & bypass 2 other bytes which meaning is beside me */
-  Where += 4;
-
-  /* read pattern table */
-  Pat_Max = 0x00;
-  for ( i=0 ; i<Nbr_Pos ; i++ )
-  {
-    Whatever[i] = ((in_data[Where+(i*2)]*256)+in_data[Where+(i*2)+1])/8;
-    /*printf ( "%d," , Whatever[i] );*/
-    if ( Whatever[i] > Pat_Max )
-      Pat_Max = Whatever[i];
-  }
-  Where += Nbr_Pos*2;
-  Pat_Max += 1;
-  /*printf ( "Number of pattern : %d\n" , Pat_Max );*/
-
-  /* write pattern table */
-  fwrite ( Whatever , 128 , 1 , out );
-
-  /* write ptk's ID */
-  Whatever[0] = 'M';
-  Whatever[1] = '.';
-  Whatever[2] = 'K';
-  Whatever[3] = '.';
-  fwrite ( Whatever , 4 , 1 , out );
-
-  /* read tracks addresses per pattern */
-  /*printf ( "\nWhere : %ld\n" , Where );*/
-  for ( i=0 ; i<Pat_Max ; i++ )
-  {
-    Track_Addresses[i][0] = (in_data[Where+(i*8)]*256)+in_data[Where+(i*8)+1];
-    Track_Addresses[i][1] = (in_data[Where+(i*8)+2]*256)+in_data[Where+(i*8)+3];
-    Track_Addresses[i][2] = (in_data[Where+(i*8)+4]*256)+in_data[Where+(i*8)+5];
-    Track_Addresses[i][3] = (in_data[Where+(i*8)+6]*256)+in_data[Where+(i*8)+7];
-  }
-  Track_Data_Start_Address = (Where + (Pat_Max*8));
-  /*printf ( "Track_Data_Start_Address : %ld\n" , Track_Data_Start_Address );*/
-
-  /* the track data now ... */
-  for ( i=0 ; i<Pat_Max ; i++ )
-  {
-    BZERO ( Whatever , 1024 );
-    for ( j=0 ; j<4 ; j++ )
-    {
-      Where = Track_Data_Start_Address + Track_Addresses[i][3-j];
-      for ( k=0 ; k<64 ; k++ )
-      {
-        c1 = in_data[Where];
-        Where += 1;
-        if ( c1 >= 0x80 )
-        {
-          k += ((0x100-c1)-1);
-          continue;
-        }
-        c2 = in_data[Where];
-        Where += 1;
-        c3 = in_data[Where];
-        Where += 1;
-
-        Whatever[k*16+j*4]   = (c1<<4)&0x10;
-        c4 = (c1 & 0xFE)/2;
-        Whatever[k*16+j*4] |= poss[c4][0];
-        Whatever[k*16+j*4+1] = poss[c4][1];
-        if ( (c2&0x0f) == 0x08 )
-          c2 &= 0xf0;
-        if ( (c2&0x0f) == 0x07 )
-        {
-          c2 = (c2&0xf0)+0x0A;
-          if ( c3 > 0x80 )
-            c3 = 0x100-c3;
-          else
-            c3 = (c3<<4)&0xf0;
-        }
-        if ( (c2&0x0f) == 0x06 )
-        {
-          if ( c3 > 0x80 )
-            c3 = 0x100-c3;
-          else
-            c3 = (c3<<4)&0xf0;
-        }
-        if ( (c2&0x0f) == 0x05 )
-        {
-          if ( c3 > 0x80 )
-            c3 = 0x100-c3;
-          else
-            c3 = (c3<<4)&0xf0;
-        }
-        if ( (c2&0x0f) == 0x0E )
-        {
-          c3 = 0x01;
-        }
-        if ( (c2&0x0f) == 0x0B )
-        {
-          c3 += 0x04;
-          c3 /= 2;
-        }
-        Whatever[k*16+j*4+2] = c2;
-        Whatever[k*16+j*4+3] = c3;
-        if ( (c2&0x0f) == 0x0D )
-          k = 100; /* to leave the loop */
-      }
-      if ( Where > SampleDataAddress )
-        SampleDataAddress = Where;
-    }
-    fwrite ( Whatever , 1024 , 1 , out );
-  }
-  free ( Whatever );
-
-  /* sample data */
-  if ( (((SampleDataAddress-PW_Start_Address)/2)*2) != SampleDataAddress )
-    SampleDataAddress += 1;
-  Where = SampleDataAddress;
-  /*printf ( "Starting address of sample data : %x\n" , ftell ( in ) );*/
-  fwrite ( &in_data[SampleDataAddress] , WholeSampleSize , 1 , out );
-
-  Crap ( "  NoisePacker v3  " , BAD , BAD , out );
-
-  fclose ( out );
-
-  printf ( "done\n" );
-  return; /* useless ... but */
-}
index 13965c6c30fd15740944464685d46a134e48a329..6a294b2a1d80eea240bea5db0e8733785773175a 100644 (file)
--- a/zfile.cpp
+++ b/zfile.cpp
@@ -248,6 +248,17 @@ static void removeext (TCHAR *s, TCHAR *ext)
                s[_tcslen (s) - _tcslen (ext)] = 0;
 }
 
+static bool checkwrite (struct zfile *zf, int *retcode)
+{
+       if (zfile_needwrite (zf)) {
+               if (retcode)
+                       *retcode = -1;
+               return true;
+       }
+       return false;
+}
+
+
 static uae_u8 exeheader[]={ 0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00 };
 static TCHAR *diskimages[] = { L"adf", L"adz", L"ipf", L"fdi", L"dms", L"wrp", L"dsq", 0 };
 
@@ -507,7 +518,7 @@ end:
        return z;
 }
 
-struct zfile *zfile_gunzip (struct zfile *z)
+static struct zfile *zfile_gunzip (struct zfile *z, int *retcode)
 {
        uae_u8 header[2 + 1 + 1 + 4 + 1 + 1];
        z_stream zs;
@@ -519,6 +530,8 @@ struct zfile *zfile_gunzip (struct zfile *z)
        struct zfile *z2;
        uae_u8 b;
 
+       if (checkwrite (z, retcode))
+               return NULL;
        _tcscpy (name, z->name);
        memset (&zs, 0, sizeof (zs));
        memset (header, 0, sizeof (header));
@@ -591,6 +604,10 @@ struct zfile *zfile_gunzip (struct zfile *z)
        zfile_fclose (z);
        return z2;
 }
+struct zfile *zfile_gunzip (struct zfile *z)
+{
+       return zfile_gunzip (z, NULL);
+}
 
 static void truncate880k (struct zfile *z)
 {
@@ -736,6 +753,8 @@ static struct zfile *fdi (struct zfile *z, int index, int *retcode)
        uae_u8 tmp[12];
        struct zcache *zc;
 
+       if (checkwrite (z, retcode))
+               return NULL;
        if (index > 2)
                return NULL;
 
@@ -864,6 +883,9 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode)
        uae_u8 tmp[12];
        struct zcache *zc;
 
+       if (checkwrite (z, retcode))
+               return NULL;
+
        if (index > 2)
                return NULL;
 
@@ -980,11 +1002,13 @@ end:
 }
 #endif
 
-static struct zfile *dsq (struct zfile *z, int lzx)
+static struct zfile *dsq (struct zfile *z, int lzx, int *retcode)
 {
        struct zfile *zi = NULL;
        struct zvolume *zv = NULL;
 
+       if (checkwrite (z, retcode))
+               return NULL;
        if (lzx) {
                zv = archive_directory_lzx (z);
                if (zv) {
@@ -1035,8 +1059,13 @@ static struct zfile *dsq (struct zfile *z, int lzx)
        return z;
 }
 
-static struct zfile *wrp (struct zfile *z)
+static struct zfile *wrp (struct zfile *z, int *retcode)
 {
+       if (zfile_needwrite (z)) {
+               if (retcode)
+                       *retcode = -1;
+               return NULL;
+       }
        return unwarp (z);
 }
 
@@ -1054,7 +1083,7 @@ static void SzFree(void *p, void *address)
 }
 #define XZ_OUT_SIZE 10000
 #define XZ_IN_SIZE 10000
-static struct zfile *xz (struct zfile *z)
+static struct zfile *xz (struct zfile *z, int *retcode)
 {
        static bool iscrc;
        ISzAlloc allocImp;
@@ -1063,6 +1092,8 @@ static struct zfile *xz (struct zfile *z)
        struct zfile *zo = NULL;
        uae_u8 out[XZ_OUT_SIZE], in[XZ_IN_SIZE];
 
+       if (checkwrite (z, retcode))
+               return NULL;
        memset (&cx, 0, sizeof cx);
        allocImp.Alloc = SzAlloc;
        allocImp.Free = SzFree;
@@ -1130,6 +1161,8 @@ static struct zfile *dms (struct zfile *z, int index, int *retcode)
        int i;
        struct zfile *zextra[DMS_EXTRA_SIZE] = { 0 };
 
+       if (checkwrite (z, retcode))
+               return NULL;
        if (recursive)
                return NULL;
        if (ext) {
@@ -1362,17 +1395,17 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault,
                if (mask & ZFD_UNPACK) {
                        if (index == 0) {
                                if (strcasecmp (ext, L"gz") == 0)
-                                       return zfile_gunzip (z);
+                                       return zfile_gunzip (z, retcode);
                                if (strcasecmp (ext, L"adz") == 0)
-                                       return zfile_gunzip (z);
+                                       return zfile_gunzip (z, retcode);
                                if (strcasecmp (ext, L"roz") == 0)
-                                       return zfile_gunzip (z);
+                                       return zfile_gunzip (z, retcode);
                                if (strcasecmp (ext, L"hdz") == 0)
-                                       return zfile_gunzip (z);
+                                       return zfile_gunzip (z, retcode);
                                if (strcasecmp (ext, L"wrp") == 0)
-                                       return wrp (z);
+                                       return wrp (z, retcode);
                                if (strcasecmp (ext, L"xz") == 0)
-                                       return xz (z);
+                                       return xz (z, retcode);
                        }
                        if (strcasecmp (ext, L"dms") == 0)
                                return dms (z, index, retcode);
@@ -1408,11 +1441,11 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault,
        if (mask & ZFD_UNPACK) {
                if (index == 0) {
                        if (header[0] == 0x1f && header[1] == 0x8b)
-                               return zfile_gunzip (z);
+                               return zfile_gunzip (z, retcode);
                        if (header[0] == 'P' && header[1] == 'K' && header[2] == 'D')
-                               return dsq (z, 0);
+                               return dsq (z, 0, retcode);
                        if (header[0] == 0xfd && header[1] == 0x37 && header[2] == 0x7a && header[3] == 0x58 && header[4] == 0x5a && header[5] == 0)
-                               return xz (z);
+                               return xz (z, retcode);
                }
                if (header[0] == 'D' && header[1] == 'M' && header[2] == 'S' && header[3] == '!')
                        return dms (z, index, retcode);
@@ -1451,7 +1484,7 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault,
        if (ext) {
                if (mask & ZFD_UNPACK) {
                        if (strcasecmp (ext, L"dsq") == 0)
-                               return dsq (z, 1);
+                               return dsq (z, 1, retcode);
                }
                if (mask & ZFD_ADF) {
                        if (strcasecmp (ext, L"adf") == 0 && !memcmp (header, "DOS", 3))
@@ -1555,6 +1588,12 @@ static bool writeneeded (const TCHAR *mode)
 {
        return _tcschr (mode, 'w') || _tcschr (mode, 'a') || _tcschr (mode, '+') || _tcschr (mode, 't');
 }
+bool zfile_needwrite (struct zfile *zf)
+{
+       if (!zf->mode)
+               return false;
+       return writeneeded (zf->mode);
+}
 
 static struct zfile *zfile_fopen_2 (const TCHAR *name, const TCHAR *mode, int mask)
 {
@@ -1593,10 +1632,6 @@ static struct zfile *zfile_fopen_2 (const TCHAR *name, const TCHAR *mode, int ma
                if (stat (l->name, &st) != -1)
                        l->size = st.st_size;
                l->f = f;
-               if (writeneeded (mode) && iszip (l, ZFD_ARCHIVE)) {
-                       zfile_fclose (l);
-                       return NULL;
-               }
        }
        return l;
 }
@@ -1666,8 +1701,6 @@ static struct zfile *zfile_fopen_x (const TCHAR *name, const TCHAR *mode, int ma
        l = zfile_fopen_2 (path, mode, mask);
        if (!l)
                return 0;
-       if (writeneeded (mode))
-               return l;
        l2 = NULL;
        while (cnt-- > 0) {
                int rc;
index 14979f7817d70ad90021fd36c7a1270dafe53388..082d8906b0125c4cbc1f7f9971fcbea8f488a8e6 100644 (file)
@@ -106,6 +106,11 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns
                *retcode = 0;
        if (index > 0)
                return NULL;
+       if (zfile_needwrite (zf)) {
+               if (retcode)
+                       *retcode = -1;
+               return NULL;
+       }
        zv = getzvolume (parent, zf, id);
        if (!zv)
                return NULL;
@@ -208,6 +213,11 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns
 
 struct zfile *archive_access_arcacc_select (struct zfile *zf, unsigned int id, int *retcode)
 {
+       if (zfile_needwrite (zf)) {
+               if (retcode)
+                       *retcode = -1;
+               return NULL;
+       }
        return zf;
 }