Compressor Correction

Area:    Quik_Bas
  Msg:    #702
 Date:    06-18-92 09:37 (Public) 
 From:    Steve Gartrell           
 To:      All                      
 Subject: Compressor Correction    
'Correction to my screen compression routine:  Just plug this right
'in in the "FourBits" sub.  It should be pretty obvious where it 
'goes.  All it does is correct the calculation of the final file
'size when a file exceeds 65,536 bytes.  Additionally, in the
'main module screen 13 save routine, right under the file BSAVE,
'there is an extra "CLOSE #filenum%" that needs removed.  I think
'it's harmless, but better safe than sorry.  And, let me expand
'upon my "caveat".  The use of integers, for speed, in the screen
'13 routine means that complex images with less than half of the
'pixels being identical to their adjacent pixels will yield both
'an overflow error inside the routine, and an error as QB/PDS
'attempts to BSAVE more than it can digest.  This can be accounted
'for by changing the size of the FileBuffer array upwards using
'HUGE arrays (far heap), using a long integer counter,  and
'replacing the BSAVE/BLOAD routines with FOR/NEXT loops a la
'"FourBits".  You'll lose speed; even more obvious is that the
'description "compressor" becomes a misnomer.  (PDS's ability to
'use static arrays in user defined types, coupled with random file
'access and the saving of an array of such user defined types,
'would bypass most of the memory and file access speed penalty,
'in exchange for more time spent in branching routines.)
'
'By the way, someday I'm going to post something that's error free,
'I just know it...<g>...|-}

         IF cell% = MaxedOut% THEN
            MaxedFlag% = MaxedFlag% + 1   'new!!!
            FOR cnt% = 1 TO BufSize%
               PUT #filenum%, ByteCnt&, FileBuffer%(cnt%)
               ByteCnt& = ByteCnt& + 2
            NEXT cnt%
            cell% = 1
         END IF
         ColorWord% = 0
         CurColorPix% = ThisPixColor%
         ColorWord% = CurColorPix% * &H800 + 1
      END IF
   NEXT
   FileBuffer%(cell%) = ColorWord%
   cell% = cell% + 1
   IF cell% = MaxedOut% THEN
      MaxedFlag% = MaxedFlag% + 1         'new!!!
      FOR cnt% = 1 TO BufSize%
         PUT #filenum%, ByteCnt&, FileBuffer%(cnt%)
         ByteCnt& = ByteCnt& + 2
      NEXT cnt%
      cell% = 1
   END IF
   ColorWord% = 0
NEXT

IF MaxedFlag% THEN
   Total& = (CLNG(BufSize% * MaxedFlag%) + cell%) * 2&  'new!!!
ELSE
   Total& = cell% * 2&
END IF


--- DB B1073/071082
 * Origin: RadioLink! Columbus, OH (614)766-2162 HST/DS (1:226/140)

Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET