PDF417 barcode encoder (crossplatform)

Share your advanced PureBasic knowledge/code with the community.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

PDF417 barcode encoder (crossplatform)

Post by bbanelli »

[PB 5.3] Windows/Linux/OS X

Update: June 26, 2015 - big thanks to infratec who has improved and tidied my original code. I have replaced posts with that update!

Here is the code for PDF417 barcode encoder. PDF417 is a stacked linear (2D) barcode symbol format used in a variety of applications, primarily transport, identification cards, and inventory management.

At the moment (Oct 2014) this code can:
  • generate crossplatform PDF417 code without any external dependency such as font or anything else that some implementations require
  • code and algorithms are based on ISO/IEC 15438:2006(E) and http://grandzebu.net/informatique/codbar-en/pdf417.htm (sanely put tables and idea for drawing algorithm)
  • it supports byte coding only and drawing functions are set to (approximately) 10 mils and 3:1 ratio. However, adding both text and numeric mode as well as modifying drawing routines should not be too difficult. Consult upper link for additional info.
  • no Compact PDF417 (truncated) or Macro PDF417 (distributed) features are implemented
  • you can set ECC level, number of rows and colons
  • there is an example of function that can be used to code UTF-8 characters but you have to make your own look-up table for each one
  • end result is an image that you can use as you see fit
  • you have to combine code from both posts in one file in order to work
  • I would like to thank everyone from this post for showing me how to add bunch of data to array easily, especially Danilo who's method I used in this case
Hope this will help someone, enjoy!

This was originally "sad story" about my non-functional PDF417 generator but I caught some time and fixed it. Now it is working, though with some limitations in regards to full PDF417 standard. Please read instructions above carefully.
Last edited by bbanelli on Fri Jun 26, 2015 2:29 pm, edited 13 times in total.
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Part 1 of code

Post by bbanelli »

Code: Select all

EnableExplicit
; to test the result:
; http://online-barcode-reader.inliteresearch.com

; Definitions of PDF417 parameters
#ECCLevel = 4
#NumberOfColumns = 9
#NumberOfRows = 30

#StartCharacter = %11111111010101000
#StopCharacter = %111111101000101001

#ImageMaxWidth = 640

DataSection  
  ; Definition of codeword tables
  T1:
  Data.l %11101010111000000, %11110101011110000, %11111010101111100, %11101010011100000
  Data.l %11110101001111000, %11111010100111110, %11010100011000000, %11101010001110000
  Data.l %11010100001100000, %10101000001000000, %11010100000110000, %10101000000100000
  Data.l %11010110111000000, %11101011011110000, %11110101101111100, %11010110011100000
  Data.l %11101011001111000, %11110101100111110, %10101100011000000, %11010110001110000
  Data.l %10101100001100000, %10101110111000000, %11010111011110000, %11101011101111100
  Data.l %10101110011100000, %11010111001111000, %11101011100111110, %10101110001110000
  Data.l %11010111000111100, %10101111011110000, %11010111101111100, %10101111001111000
  Data.l %11010111100111110, %10101111101111100, %11111010111111010, %11101001011100000
  Data.l %11110100101111000, %11111010010111110, %11010010011000000, %11101001001110000
  Data.l %11110100100111100, %11010010001100000, %11101001000111000, %10100100001000000
  Data.l %11010010000110000, %11101001000011100, %10100100000100000, %11010010000011000
  Data.l %10100100000010000, %11010011011100000, %11101001101111000, %11110100110111110
  Data.l %10100110011000000, %11010011001110000, %11101001100111100, %10100110001100000
  Data.l %11010011000111000, %11101001100011110, %10100110000110000, %11010011000011100
  Data.l %10100111011100000, %11010011101111000, %11101001110111110, %10100111001110000
  Data.l %11010011100111100, %10100111000111000, %11010011100011110, %10100111101111000
  Data.l %11010011110111110, %10100111100111100, %10100111100011110, %11010001011000000
  Data.l %11101000101110000, %11110100010111100, %11010001001100000, %11101000100111000
  Data.l %11110100010011110, %10100010001000000, %11010001000110000, %11101000100011100
  Data.l %10100010000100000, %11010001000011000, %10100010000010000, %10100010000001000
  Data.l %10100011011000000, %11010001101110000, %11101000110111100, %10100011001100000
  Data.l %11010001100111000, %11101000110011110, %10100011000110000, %11010001100011100
  Data.l %10100011000011000, %10100011000001100, %10100011101110000, %11010001110111100
  Data.l %10100011100111000, %11010001110011110, %10100011100011100, %10100011110111100
  Data.l %11010000101100000, %11101000010111000, %11110100001011110, %10100001001000000
  Data.l %11010000100110000, %11101000010011100, %10100001000100000, %11010000100011000
  Data.l %11101000010001110, %10100001000010000, %11010000100001100, %10100001000001000
  Data.l %11010000100000110, %10100001101100000, %11010000110111000, %11101000011011110
  Data.l %10100001100110000, %11010000110011100, %10100001100011000, %11010000110001110
  Data.l %10100001100001100, %10100001100000110, %11010000111011110, %10100001110001110
  Data.l %10100000101000000, %11010000010110000, %11101000001011100, %10100000100100000
  Data.l %11010000010011000, %11101000001001110, %10100000100010000, %11010000010001100
  Data.l %10100000100001000, %11010000010000110, %10100000100000100, %10100000110110000
  Data.l %10100000110011000, %10100000110001100, %10100000010100000, %11101000000101110
  Data.l %11010000001001100, %11010000001000110, %10100000010000010, %11100101011100000
  Data.l %11110010101111000, %11111001010111110, %11001010011000000, %11100101001110000
  Data.l %11110010100111100, %11001010001100000, %11100101000111000, %11110010100011110
  Data.l %10010100001000000, %11001010000110000, %10010100000100000, %11001011011100000
  Data.l %11100101101111000, %11110010110111110, %10010110011000000, %11001011001110000
  Data.l %11100101100111100, %10010110001100000, %11001011000111000, %10010110000110000
  Data.l %10010110000011000, %10010111011100000, %11001011101111000, %11100101110111110
  Data.l %10010111001110000, %11001011100111100, %10010111000111000, %10010111000011100
  Data.l %10010111101111000, %11001011110111110, %10010111100111100, %10010111110111110
  Data.l %11101101011000000, %11110110101110000, %11111011010111100, %11101101001100000
  Data.l %11110110100111000, %11111011010011110, %11011010001000000, %11101101000110000
  Data.l %11110110100011100, %11011010000100000, %11101101000011000, %11110110100001110
  Data.l %11011010000010000, %11101101000001100, %11001001011000000, %11100100101110000
  Data.l %11110010010111100, %11011011011000000, %11001001001100000, %11100100100111000
  Data.l %11110010010011110, %11011011001100000, %11101101100111000, %11110110110011110
  Data.l %10110110001000000, %10010010000100000, %11001001000011000, %11100100100001110
  Data.l %10110110000100000, %11011011000011000, %10110110000010000, %10010011011000000
  Data.l %11001001101110000, %11100100110111100, %10110111011000000, %10010011001100000
  Data.l %11001001100111000, %11100100110011110, %10110111001100000, %11011011100111000
  Data.l %11101101110011110, %10110111000110000, %10010011000011000, %10110111000011000
  Data.l %10010011101110000, %11001001110111100, %10110111101110000, %10010011100111000
  Data.l %11001001110011110, %10110111100111000, %11011011110011110, %10110111100011100
  Data.l %10010011110111100, %10110111110111100, %10010011110011110, %10110111110011110
  Data.l %11101100101100000, %11110110010111000, %11111011001011110, %11011001001000000
  Data.l %11101100100110000, %11110110010011100, %11011001000100000, %11101100100011000
  Data.l %11110110010001110, %11011001000010000, %11101100100001100, %11011001000001000
  Data.l %11011001000000100, %11001000101100000, %11100100010111000, %11110010001011110
  Data.l %11011001101100000, %11001000100110000, %11100100010011100, %10110011001000000
  Data.l %10010001000100000, %11101100110011100, %11100100010001110, %10110011000100000
  Data.l %10010001000010000, %11001000100001100, %10110011000010000, %11011001100001100
  Data.l %11001000100000110, %10010001000000100, %10010001101100000, %11001000110111000
  Data.l %11100100011011110, %10110011101100000, %10010001100110000, %11001000110011100
  Data.l %10110011100110000, %11011001110011100, %11001000110001110, %10110011100011000
  Data.l %10010001100001100, %10010001100000110, %10010001110111000, %11001000111011110
  Data.l %10110011110111000, %10010001110011100, %10110011110011100, %10010001110001110
  Data.l %10110011110001110, %10110011111011110, %11011000101000000, %11101100010110000
  Data.l %11110110001011100, %11011000100100000, %11101100010011000, %11110110001001110
  Data.l %11011000100010000, %11101100010001100, %11011000100001000, %11101100010000110
  Data.l %11011000100000100, %11011000100000010, %10010000101000000, %11001000010110000
  Data.l %11100100001011100, %10110001101000000, %10010000100100000, %11001000010011000
  Data.l %11100100001001110, %10110001100100000, %11011000110011000, %11101100011001110
  Data.l %10110001100010000, %10010000100001000, %11001000010000110, %10110001100001000
  Data.l %11011000110000110, %10110001100000100, %10010000110110000, %11001000011011100
  Data.l %10110001110110000, %10010000110011000, %11001000011001110, %10110001110011000
  Data.l %11011000111001110, %10110001110001100, %10010000110000110, %10110001110000110
  Data.l %10110001111011100, %10110001111001110, %11011000010100000, %11101100001011000
  Data.l %11110110000101110, %11011000010010000, %11101100001001100, %11011000010001000
  Data.l %11101100001000110, %11011000010000100, %11011000010000010, %10010000010100000
  Data.l %11001000001011000, %11100100000101110, %10110000110100000, %10010000010010000
  Data.l %11001000001001100, %10110000110010000, %11011000011001100, %11001000001000110
  Data.l %10110000110001000, %10010000010000100, %10110000110000100, %10010000010000010
  Data.l %10010000011011000, %10110000111011000, %10110000111001100, %10110000111000110
  Data.l %11101100000101100, %11101100000100110, %11011000001000010, %11001000000101100
  Data.l %10010000001001000, %10110000011001000, %10110000011000100, %10110000011000010
  Data.l %11000101011000000, %11100010101110000, %11110001010111100, %11000101001100000
  Data.l %11100010100111000, %10001010001000000, %11000101000110000, %11100010100011100
  Data.l %10001010000100000, %11000101000011000, %10001010000010000, %10001010000001000
  Data.l %10001011011000000, %11000101101110000, %11100010110111100, %10001011001100000
  Data.l %11000101100111000, %11100010110011110, %10001011000110000, %11000101100011100
  Data.l %10001011000011000, %10001011000001100, %10001011101110000, %11000101110111100
  Data.l %10001011100111000, %11000101110011110, %10001011100011100, %10001011110111100
  Data.l %10001011110011110, %11100110101100000, %11110011010111000, %11111001101011110
  Data.l %11001101001000000, %11100110100110000, %11110011010011100, %11001101000100000
  Data.l %11100110100011000, %11110011010001110, %11001101000010000, %11100110100001100
  Data.l %11001101000001000, %11100110100000110, %11000100101100000, %11100010010111000
  Data.l %11110001001011110, %11001101101100000, %11000100100110000, %11100010010011100
  Data.l %10011011001000000, %10001001000100000, %11100110110011100, %11100010010001110
  Data.l %10011011000100000, %11001101100011000, %11000100100001100, %10011011000010000
  Data.l %10001001000001000, %10011011000001000, %10001001101100000, %11000100110111000
  Data.l %11100010011011110, %10011011101100000, %10001001100110000, %11100110111011110
  Data.l %10011011100110000, %11001101110011100, %11000100110001110, %10011011100011000
  Data.l %10001001100001100, %10011011100001100, %10001001110111000, %11000100111011110
  Data.l %10011011110111000, %10001001110011100, %10011011110011100, %10001001110001110
  Data.l %10001001111011110, %10011011111011110, %11101110101000000, %11110111010110000
  Data.l %11111011101011100, %11101110100100000, %11110111010011000, %11111011101001110
  Data.l %11101110100010000, %11110111010001100, %11101110100001000, %11110111010000110
  Data.l %11101110100000100, %11001100101000000, %11100110010110000, %11110011001011100
  Data.l %11011101101000000, %11001100100100000, %11110111011011100, %11110011001001110
  Data.l %11011101100100000, %11101110110011000, %11110111011001110, %11011101100010000
  Data.l %11001100100001000, %11100110010000110, %11011101100001000, %11101110110000110
  Data.l %11001100100000010, %10001000101000000, %11000100010110000, %11100010001011100
  Data.l %10011001101000000, %10001000100100000, %11000100010011000, %11100010001001110
  Data.l %10111011101000000, %10011001100100000, %11001100110011000, %11100110011001110
  Data.l %10111011100100000, %11011101110011000, %11101110111001110, %11000100010000110
  Data.l %10111011100010000, %10011001100001000, %11001100110000110, %10111011100001000
  Data.l %10001000100000010, %10001000110110000, %11000100011011100, %10011001110110000
  Data.l %10001000110011000, %11000100011001110, %10111011110110000, %10011001110011000
  Data.l %11001100111001110, %10111011110011000, %11011101111001110, %10001000110000110
  Data.l %10011001110000110, %10001000111011100, %10011001111011100, %10001000111001110
  Data.l %10111011111011100, %10011001111001110, %11101110010100000, %11110111001011000
  Data.l %11111011100101110, %11101110010010000, %11110111001001100, %11101110010001000
  Data.l %11110111001000110, %11101110010000100, %11101110010000010, %11001100010100000
  Data.l %11100110001011000, %11110011000101110, %11011100110100000, %11001100010010000
  Data.l %11110111001101110, %11011100110010000, %11101110011001100, %11100110001000110
  Data.l %11011100110001000, %11001100010000100, %11011100110000100, %11001100010000010
  Data.l %11011100110000010, %10001000010100000, %11000100001011000, %11100010000101110
  Data.l %10011000110100000, %10001000010010000, %11000100001001100, %10111001110100000
  Data.l %10011000110010000, %11001100011001100, %11000100001000110, %10111001110010000
  Data.l %11011100111001100, %10001000010000100, %10111001110001000, %10011000110000100
  Data.l %10001000010000010, %10011000110000010, %10001000011011000, %11000100001101110
  Data.l %10011000111011000, %10001000011001100, %10111001111011000, %10011000111001100
  Data.l %10001000011000110, %10111001111001100, %10011000111000110, %10001000011101110
  Data.l %10111001111101110, %11101110001010000, %11110111000101100, %11101110001001000
  Data.l %11110111000100110, %11101110001000100, %11101110001000010, %11001100001010000
  Data.l %11100110000101100, %11011100011010000, %11001100001001000, %11100110000100110
  Data.l %11011100011001000, %11101110001100110, %11011100011000100, %11001100001000010
  Data.l %11011100011000010, %10001000001010000, %11000100000101100, %10011000011010000
  Data.l %10001000001001000, %11000100000100110, %10111000111010000, %10011000011001000
  Data.l %11001100001100110, %10111000111001000, %11011100011100110, %10001000001000010
  Data.l %10111000111000100, %10011000011000010, %10111000111000010, %10011000011101100
  Data.l %10111000111101100, %10111000111100110, %11110111000010110, %11101110000100010
  Data.l %11100110000010110, %11001100000100100, %11001100000100010, %10001000000101000
  Data.l %10011000001101000, %10111000011101000, %10001000000100010, %10011000001100010
  Data.l %11000010101100000, %10000101001000000, %11000010100110000, %10000101000100000
  Data.l %11000010100011000, %11100001010001110, %10000101000010000, %11000010100001100
  Data.l %10000101000001000, %11000010100000110, %10000101101100000, %11000010110111000
  Data.l %11100001011011110, %10000101100110000, %11000010110011100, %10000101100011000
  Data.l %11000010110001110, %10000101100001100, %10000101100000110, %10000101110111000
  Data.l %11000010111011110, %10000101110011100, %10000101110001110, %10000101111011110
  Data.l %11000110101000000, %11100011010110000, %11110001101011100, %11000110100100000
  Data.l %11100011010011000, %11000110100010000, %11100011010001100, %11000110100001000
  Data.l %11100011010000110, %11000110100000100, %10000100101000000, %11000010010110000
  Data.l %11100001001011100, %10001101101000000, %10000100100100000, %11100011011011100
  Data.l %11100001001001110, %10001101100100000, %11000110110011000, %11100011011001110
  Data.l %10001101100010000, %10000100100001000, %11000010010000110, %10001101100001000
  Data.l %11000110110000110, %10000100100000010, %10000100110110000, %11000010011011100
  Data.l %10001101110110000, %10000100110011000, %11000010011001110, %10001101110011000
  Data.l %11000110111001110, %10001101110001100, %10000100110000110, %10000100111011100
  Data.l %10001101111011100, %10000100111001110, %10001101111001110, %11100111010100000
  Data.l %11110011101011000, %11111001110101110, %11100111010010000, %11110011101001100
  Data.l %11100111010001000, %11110011101000110, %11100111010000100, %11100111010000010
  Data.l %11000110010100000, %11100011001011000, %11001110110100000, %11000110010010000
  Data.l %11100011001001100, %11001110110010000, %11100111011001100, %11100011001000110
  Data.l %11001110110001000, %11000110010000100, %11001110110000100, %11000110010000010
  Data.l %11001110110000010, %10000100010100000, %11000010001011000, %10001100110100000
  Data.l %10000100010010000, %11100011001101110, %10011101110100000, %10001100110010000
  Data.l %11000110011001100, %11000010001000110, %10011101110010000, %11001110111001100
  Data.l %10000100010000100, %10011101110001000, %10001100110000100, %10000100010000010
  Data.l %10001100110000010, %10000100011011000, %11000010001101110, %10001100111011000
  Data.l %10000100011001100, %10011101111011000, %10001100111001100, %10000100011000110
  Data.l %10011101111001100, %10001100111000110, %10000100011101110, %10001100111101110
  Data.l %10011101111101110, %11110111101010000, %11111011110101100, %11110111101001000
  Data.l %11111011110100110, %11110111101000100, %11110111101000010, %11100111001010000
  Data.l %11110011100101100, %11101111011010000, %11110111101101100, %11110011100100110
  Data.l %11101111011001000, %11110111101100110, %11101111011000100, %11100111001000010
  Data.l %11101111011000010, %11000110001010000, %11100011000101100, %11001110011010000
  Data.l %11000110001001000, %11100011000100110, %11011110111010000, %11001110011001000
  Data.l %11100111001100110, %11011110111001000, %11101111011100110, %11000110001000010
  Data.l %11011110111000100, %11001110011000010, %11011110111000010, %10000100001010000
  Data.l %11000010000101100, %10001100011010000, %10000100001001000, %11000010000100110
  Data.l %10011100111010000, %10001100011001000, %11000110001100110, %10111101111010000
  Data.l %10011100111001000, %11001110011100110, %10000100001000010, %10111101111001000
  Data.l %11011110111100110, %10001100011000010, %10111101111000100, %10000100001101100
  Data.l %10001100011101100, %10000100001100110, %10011100111101100, %10001100011100110
  Data.l %10111101111101100, %10011100111100110, %10111101111100110, %11110111100101000
  Data.l %11111011110010110, %11110111100100100, %11110111100100010, %11100111000101000
  Data.l %11110011100010110, %11101111001101000, %11110111100110110, %11101111001100100
  Data.l %11100111000100010, %11101111001100010, %11000110000101000, %11100011000010110
  Data.l %11001110001101000, %11000110000100100, %11011110011101000, %11001110001100100
  Data.l %11000110000100010, %11011110011100100, %11001110001100010, %11011110011100010
  Data.l %10000100000101000, %11000010000010110, %10001100001101000, %11000110000110110
  Data.l %10011100011101000, %10001100001100100, %10000100000100010, %10111100111101000
  Data.l %10011100011100100, %10001100001100010, %10111100111100100, %10011100011100010
  Data.l %10111100111100010, %10001100001110110, %10111100111110110, %11110111100010010
  Data.l %11101111000110100, %11101111000110010, %11001110000110100, %11011110001110100
  Data.l %11011110001110010, %10001100000110100, %10011100001110100, %10111100011110100
  Data.l %10111100011110010, %10000010101000000, %10000010100100000, %11000001010011000
  Data.l %10000010100010000, %10000010100001000, %10000010100000100, %10000010110110000
  Data.l %10000010110011000, %10000010110001100, %10000010110000110, %10000010111011100
  Data.l %10000010111001110, %11000011010100000, %11000011010010000, %11100001101001100
  Data.l %11000011010001000, %11100001101000110, %11000011010000100, %11000011010000010
  Data.l %10000010010100000, %11000001001011000, %10000110110100000, %11000011011011000
  Data.l %11000001001001100, %10000110110010000, %11000011011001100, %10000110110001000
  Data.l %11000011011000110, %10000110110000100, %10000010010000010, %10000110110000010
  Data.l %10000010011011000, %11000001001101110, %10000110111011000, %11000011011101110
  Data.l %10000110111001100, %10000010011000110, %10000110111000110, %10000010011101110
  Data.l %10000110111101110, %11100011101010000, %11100011101001000, %11100011101000100
  Data.l %11100011101000010, %11000011001010000, %11000111011010000, %11100011101101100
  Data.l %11100001100100110, %11000111011001000, %11100011101100110, %11000111011000100
  Data.l %11000011001000010, %11000111011000010, %10000010001010000, %10000110011010000
  Data.l %10000010001001000, %11000001000100110, %10001110111010000, %10000110011001000
  Data.l %10000010001000100, %10001110111001000, %10000110011000100, %10000010001000010
  Data.l %10001110111000100, %10000110011000010, %10000010001101100, %10000110011101100
  Data.l %10000010001100110, %10001110111101100, %10000110011100110, %10001110111100110
  Data.l %11110011110101000, %11110011110100100, %11110011110100010, %11100011100101000
  Data.l %11100111101101000, %11110011110110110, %11100111101100100, %11100011100100010
  Data.l %11100111101100010, %11000011000101000, %11100001100010110, %11000111001101000
  Data.l %11100011100110110, %11001111011101000, %11000111001100100, %11000011000100010
  Data.l %11001111011100100, %11000111001100010, %11001111011100010, %10000010000101000
  Data.l %11000001000010110, %10000110001101000, %11000011000110110, %10001110011101000
  Data.l %10000110001100100, %10000010000100010, %10011110111101000, %10001110011100100
  Data.l %10000110001100010, %10011110111100100, %10001110011100010, %10000010000110110
  Data.l %10000110001110110, %10001110011110110, %10011110111110110, %11111011111010100
  Data.l %11111011111010010, %11110011110010100, %11110111110110100, %11110011110010010
  Data.l %11110111110110010, %11100011100010100, %11100111100110100, %11100011100010010
  Data.l %11101111101110100, %11100111100110010, %11101111101110010, %11000011000010100
  Data.l %11000111000110100, %11000011000010010, %11001111001110100, %11000111000110010
  Data.l %11011111011110100
  T2:
  Data.l %11111010101100000, %11111101010111000, %11110101001000000, %11111010100110000
  Data.l %11111101010011100, %11110101000100000, %11111010100011000, %11111101010001110
  Data.l %11110101000010000, %11111010100001100, %11110101000001000, %11111010100000110
  Data.l %11110101000000100, %11110101101100000, %11111010110111000, %11111101011011110
  Data.l %11101011001000000, %11110101100110000, %11111010110011100, %11101011000100000
  Data.l %11110101100011000, %11111010110001110, %11101011000010000, %11110101100001100
  Data.l %11101011000001000, %11110101100000110, %11101011000000100, %11101011101100000
  Data.l %11110101110111000, %11111010111011110, %11010111001000000, %11101011100110000
  Data.l %11110101110011100, %11010111000100000, %11101011100011000, %11110101110001110
  Data.l %11010111000010000, %11101011100001100, %11010111000001000, %11101011100000110
  Data.l %11010111000000100, %11010111101100000, %11101011110111000, %11110101111011110
  Data.l %10101111001000000, %11010111100110000, %11101011110011100, %10101111000100000
  Data.l %11010111100011000, %11101011110001110, %10101111000010000, %11010111100001100
  Data.l %10101111000001000, %11010111100000110, %10101111101100000, %11010111110111000
  Data.l %11101011111011110, %10101111100110000, %11010111110011100, %10101111100011000
  Data.l %11010111110001110, %10101111100001100, %10101111110111000, %11010111111011110
  Data.l %10101111110011100, %10101111110001110, %11110100101000000, %11111010010110000
  Data.l %11111101001011100, %11110100100100000, %11111010010011000, %11111101001001110
  Data.l %11110100100010000, %11111010010001100, %11110100100001000, %11111010010000110
  Data.l %11110100100000100, %11110100100000010, %11101001101000000, %11110100110110000
  Data.l %11111010011011100, %11101001100100000, %11110100110011000, %11111010011001110
  Data.l %11101001100010000, %11110100110001100, %11101001100001000, %11110100110000110
  Data.l %11101001100000100, %11101001100000010, %11010011101000000, %11101001110110000
  Data.l %11110100111011100, %11010011100100000, %11101001110011000, %11110100111001110
  Data.l %11010011100010000, %11101001110001100, %11010011100001000, %11101001110000110
  Data.l %11010011100000100, %11010011100000010, %10100111101000000, %11010011110110000
  Data.l %11101001111011100, %10100111100100000, %11010011110011000, %11101001111001110
  Data.l %10100111100010000, %11010011110001100, %10100111100001000, %11010011110000110
  Data.l %10100111100000100, %10100111110110000, %11010011111011100, %10100111110011000
  Data.l %11010011111001110, %10100111110001100, %10100111110000110, %10100111111011100
  Data.l %10100111111001110, %11110100010100000, %11111010001011000, %11111101000101110
  Data.l %11110100010010000, %11111010001001100, %11110100010001000, %11111010001000110
  Data.l %11110100010000100, %11110100010000010, %11101000110100000, %11110100011011000
  Data.l %11111010001101110, %11101000110010000, %11110100011001100, %11101000110001000
  Data.l %11110100011000110, %11101000110000100, %11101000110000010, %11010001110100000
  Data.l %11101000111011000, %11110100011101110, %11010001110010000, %11101000111001100
  Data.l %11010001110001000, %11101000111000110, %11010001110000100, %11010001110000010
  Data.l %10100011110100000, %11010001111011000, %11101000111101110, %10100011110010000
  Data.l %11010001111001100, %10100011110001000, %11010001111000110, %10100011110000100
  Data.l %10100011110000010, %10100011111011000, %11010001111101110, %10100011111001100
  Data.l %10100011111000110, %10100011111101110, %11110100001010000, %11111010000101100
  Data.l %11110100001001000, %11111010000100110, %11110100001000100, %11110100001000010
  Data.l %11101000011010000, %11110100001101100, %11101000011001000, %11110100001100110
  Data.l %11101000011000100, %11101000011000010, %11010000111010000, %11101000011101100
  Data.l %11010000111001000, %11101000011100110, %11010000111000100, %11010000111000010
  Data.l %10100001111010000, %11010000111101100, %10100001111001000, %11010000111100110
  Data.l %10100001111000100, %10100001111000010, %10100001111101100, %10100001111100110
  Data.l %11110100000101000, %11111010000010110, %11110100000100100, %11110100000100010
  Data.l %11101000001101000, %11110100000110110, %11101000001100100, %11101000001100010
  Data.l %11010000011101000, %11101000001110110, %11010000011100100, %11010000011100010
  Data.l %10100000111101000, %11010000011110110, %10100000111100100, %10100000111100010
  Data.l %11110100000010100, %11110100000010010, %11101000000110100, %11101000000110010
  Data.l %11010000001110100, %11010000001110010, %11110010101000000, %11111001010110000
  Data.l %11111100101011100, %11110010100100000, %11111001010011000, %11111100101001110
  Data.l %11110010100010000, %11111001010001100, %11110010100001000, %11111001010000110
  Data.l %11110010100000100, %11110010100000010, %11100101101000000, %11110010110110000
  Data.l %11111001011011100, %11100101100100000, %11110010110011000, %11111001011001110
  Data.l %11100101100010000, %11110010110001100, %11100101100001000, %11110010110000110
  Data.l %11100101100000100, %11100101100000010, %11001011101000000, %11100101110110000
  Data.l %11110010111011100, %11001011100100000, %11100101110011000, %11110010111001110
  Data.l %11001011100010000, %11100101110001100, %11001011100001000, %11100101110000110
  Data.l %11001011100000100, %11001011100000010, %10010111101000000, %11001011110110000
  Data.l %11100101111011100, %10010111100100000, %11001011110011000, %11100101111001110
  Data.l %10010111100010000, %11001011110001100, %10010111100001000, %11001011110000110
  Data.l %10010111100000100, %10010111110110000, %11001011111011100, %10010111110011000
  Data.l %11001011111001110, %10010111110001100, %10010111110000110, %10010111111011100
  Data.l %10010111111001110, %11111011010100000, %11111101101011000, %10110101111110000
  Data.l %11111011010010000, %11111101101001100, %10110100111111000, %11111011010001000
  Data.l %11111101101000110, %10110100011111100, %11111011010000100, %11111011010000010
  Data.l %11110010010100000, %11111001001011000, %11111100100101110, %11110110110100000
  Data.l %11110010010010000, %11111101101101110, %11110110110010000, %11111011011001100
  Data.l %11111001001000110, %11110110110001000, %11110010010000100, %11110110110000100
  Data.l %11110010010000010, %11110110110000010, %11100100110100000, %11110010011011000
  Data.l %11111001001101110, %11101101110100000, %11100100110010000, %11110010011001100
  Data.l %11101101110010000, %11110110111001100, %11110010011000110, %11101101110001000
  Data.l %11100100110000100, %11101101110000100, %11100100110000010, %11101101110000010
  Data.l %11001001110100000, %11100100111011000, %11110010011101110, %11011011110100000
  Data.l %11001001110010000, %11100100111001100, %11011011110010000, %11101101111001100
  Data.l %11100100111000110, %11011011110001000, %11001001110000100, %11011011110000100
  Data.l %11001001110000010, %11011011110000010, %10010011110100000, %11001001111011000
  Data.l %11100100111101110, %10110111110100000, %10010011110010000, %11001001111001100
  Data.l %10110111110010000, %11011011111001100, %11001001111000110, %10110111110001000
  Data.l %10010011110000100, %10110111110000100, %10010011110000010, %10010011111011000
  Data.l %11001001111101110, %10110111111011000, %10010011111001100, %10110111111001100
  Data.l %10010011111000110, %10110111111000110, %10010011111101110, %11111011001010000
  Data.l %11111101100101100, %10110010111111000, %11111011001001000, %11111101100100110
  Data.l %10110010011111100, %11111011001000100, %10110010001111110, %11111011001000010
  Data.l %11110010001010000, %11111001000101100, %11110110011010000, %11110010001001000
  Data.l %11111001000100110, %11110110011001000, %11111011001100110, %11110110011000100
  Data.l %11110010001000010, %11110110011000010, %11100100011010000, %11110010001101100
  Data.l %11101100111010000, %11100100011001000, %11110010001100110, %11101100111001000
  Data.l %11110110011100110, %11101100111000100, %11100100011000010, %11101100111000010
  Data.l %11001000111010000, %11100100011101100, %11011001111010000, %11001000111001000
  Data.l %11100100011100110, %11011001111001000, %11101100111100110, %11011001111000100
  Data.l %11001000111000010, %11011001111000010, %10010001111010000, %11001000111101100
  Data.l %10110011111010000, %10010001111001000, %11001000111100110, %10110011111001000
  Data.l %11011001111100110, %10110011111000100, %10010001111000010, %10110011111000010
  Data.l %10010001111101100, %10110011111101100, %10010001111100110, %10110011111100110
  Data.l %11111011000101000, %11111101100010110, %10110001011111100, %11111011000100100
  Data.l %10110001001111110, %11111011000100010, %11110010000101000, %11111001000010110
  Data.l %11110110001101000, %11111011000110110, %11110110001100100, %11110010000100010
  Data.l %11110110001100010, %11100100001101000, %11110010000110110, %11101100011101000
  Data.l %11100100001100100, %11101100011100100, %11100100001100010, %11101100011100010
  Data.l %11001000011101000, %11100100001110110, %11011000111101000, %11101100011110110
  Data.l %11011000111100100, %11001000011100010, %11011000111100010, %10010000111101000
  Data.l %11001000011110110, %10110001111101000, %10010000111100100, %10110001111100100
  Data.l %10010000111100010, %10110001111100010, %10010000111110110, %10110001111110110
  Data.l %11111011000010100, %10110000101111110, %11111011000010010, %11110010000010100
  Data.l %11110110000110100, %11110010000010010, %11110110000110010, %11100100000110100
  Data.l %11101100001110100, %11100100000110010, %11101100001110010, %11001000001110100
  Data.l %11011000011110100, %11001000001110010, %11011000011110010, %10010000011110100
  Data.l %10110000111110100, %10010000011110010, %10110000111110010, %11111011000001010
  Data.l %11110010000001010, %11110110000011010, %11100100000011010, %11101100000111010
  Data.l %11001000000111010, %11011000001111010, %11110001010100000, %11111000101011000
  Data.l %11111100010101110, %11110001010010000, %11111000101001100, %11110001010001000
  Data.l %11111000101000110, %11110001010000100, %11110001010000010, %11100010110100000
  Data.l %11110001011011000, %11111000101101110, %11100010110010000, %11110001011001100
  Data.l %11100010110001000, %11110001011000110, %11100010110000100, %11100010110000010
  Data.l %11000101110100000, %11100010111011000, %11110001011101110, %11000101110010000
  Data.l %11100010111001100, %11000101110001000, %11100010111000110, %11000101110000100
  Data.l %11000101110000010, %10001011110100000, %11000101111011000, %11100010111101110
  Data.l %10001011110010000, %11000101111001100, %10001011110001000, %11000101111000110
  Data.l %10001011110000100, %10001011110000010, %10001011111011000, %11000101111101110
  Data.l %10001011111001100, %10001011111000110, %10001011111101110, %11111001101010000
  Data.l %11111100110101100, %10011010111111000, %11111001101001000, %11111100110100110
  Data.l %10011010011111100, %11111001101000100, %10011010001111110, %11111001101000010
  Data.l %11110001001010000, %11111000100101100, %11110011011010000, %11110001001001000
  Data.l %11111000100100110, %11110011011001000, %11111001101100110, %11110011011000100
  Data.l %11110001001000010, %11110011011000010, %11100010011010000, %11110001001101100
  Data.l %11100110111010000, %11100010011001000, %11110001001100110, %11100110111001000
  Data.l %11110011011100110, %11100110111000100, %11100010011000010, %11100110111000010
  Data.l %11000100111010000, %11100010011101100, %11001101111010000, %11000100111001000
  Data.l %11100010011100110, %11001101111001000, %11100110111100110, %11001101111000100
  Data.l %11000100111000010, %11001101111000010, %10001001111010000, %11000100111101100
  Data.l %10011011111010000, %10001001111001000, %11000100111100110, %10011011111001000
  Data.l %11001101111100110, %10011011111000100, %10001001111000010, %10011011111000010
  Data.l %10001001111101100, %10011011111101100, %10001001111100110, %10011011111100110
  Data.l %11111101110101000, %10111010111110000, %11011101011111100, %11111101110100100
  Data.l %10111010011111000, %11011101001111110, %11111101110100010, %10111010001111100
  Data.l %10111010000111110, %11111001100101000, %11111100110010110, %10011001011111100
  Data.l %11111011101101000, %11111101110110110, %10111011011111100, %10011001001111110
  Data.l %11111011101100100, %11111001100100010, %10111011001111110, %11111011101100010
  Data.l %11110001000101000, %11111000100010110, %11110011001101000, %11110001000100100
  Data.l %11110111011101000, %11111011101110110, %11110001000100010, %11110111011100100
  Data.l %11110011001100010, %11110111011100010, %11100010001101000, %11110001000110110
  Data.l %11100110011101000, %11100010001100100, %11101110111101000, %11100110011100100
  Data.l %11100010001100010, %11101110111100100, %11100110011100010, %11101110111100010
  Data.l %11000100011101000, %11100010001110110, %11001100111101000, %11000100011100100
  Data.l %11011101111101000, %11001100111100100, %11000100011100010, %11011101111100100
  Data.l %11001100111100010, %11011101111100010, %10001000111101000, %11000100011110110
  Data.l %10011001111101000, %10001000111100100, %10111011111101000, %10011001111100100
  Data.l %10001000111100010, %10111011111100100, %10011001111100010, %10111011111100010
  Data.l %10001000111110110, %10011001111110110, %11111101110010100, %10111001011111000
  Data.l %11011100101111110, %11111101110010010, %10111001001111100, %10111001000111110
  Data.l %11111001100010100, %10011000101111110, %11111011100110100, %11111001100010010
  Data.l %10111001101111110, %11111011100110010, %11110001000010100, %11110011000110100
  Data.l %11110001000010010, %11110111001110100, %11110011000110010, %11110111001110010
  Data.l %11100010000110100, %11100110001110100, %11100010000110010, %11101110011110100
  Data.l %11100110001110010, %11101110011110010, %11000100001110100, %11001100011110100
  Data.l %11000100001110010, %11011100111110100, %11001100011110010, %11011100111110010
  Data.l %10001000011110100, %10011000111110100, %10001000011110010, %10111001111110100
  Data.l %10011000111110010, %10111001111110010, %11111101110001010, %10111000101111100
  Data.l %10111000100111110, %11111001100001010, %11111011100011010, %11110001000001010
  Data.l %11110011000011010, %11110111000111010, %11100010000011010, %11100110000111010
  Data.l %11101110001111010, %11000100000111010, %11001100001111010, %11011100011111010
  Data.l %10001000001111010, %10011000011111010, %10111000111111010, %10111000010111110
  Data.l %11110000101010000, %11111000010101100, %11110000101001000, %11111000010100110
  Data.l %11110000101000100, %11110000101000010, %11100001011010000, %11110000101101100
  Data.l %11100001011001000, %11110000101100110, %11100001011000100, %11100001011000010
  Data.l %11000010111010000, %11100001011101100, %11000010111001000, %11100001011100110
  Data.l %11000010111000100, %11000010111000010, %10000101111010000, %11000010111101100
  Data.l %10000101111001000, %11000010111100110, %10000101111000100, %10000101111000010
  Data.l %10000101111101100, %10000101111100110, %11111000110101000, %11111100011010110
  Data.l %10001101011111100, %11111000110100100, %10001101001111110, %11111000110100010
  Data.l %11110000100101000, %11111000010010110, %11110001101101000, %11110000100100100
  Data.l %11110001101100100, %11110000100100010, %11110001101100010, %11100001001101000
  Data.l %11110000100110110, %11100011011101000, %11100001001100100, %11100011011100100
  Data.l %11100001001100010, %11100011011100010, %11000010011101000, %11100001001110110
  Data.l %11000110111101000, %11000010011100100, %11000110111100100, %11000010011100010
  Data.l %11000110111100010, %10000100111101000, %11000010011110110, %10001101111101000
  Data.l %10000100111100100, %10001101111100100, %10000100111100010, %10001101111100010
  Data.l %10000100111110110, %10001101111110110, %11111100111010100, %10011101011111000
  Data.l %11001110101111110, %11111100111010010, %10011101001111100, %10011101000111110
  Data.l %11111000110010100, %10001100101111110, %11111001110110100, %11111000110010010
  Data.l %10011101101111110, %11111001110110010, %11110000100010100, %11110001100110100
  Data.l %11110000100010010, %11110011101110100, %11110001100110010, %11110011101110010
  Data.l %11100001000110100, %11100011001110100, %11100001000110010, %11100111011110100
  Data.l %11100011001110010, %11100111011110010, %11000010001110100, %11000110011110100
  Data.l %11000010001110010, %11001110111110100, %11000110011110010, %11001110111110010
  Data.l %10000100011110100, %10001100111110100, %10000100011110010, %10011101111110100
  Data.l %10001100111110010, %10011101111110010, %10111101011110000, %11011110101111100
  Data.l %10111101001111000, %11011110100111110, %10111101000111100, %10111101000011110
  Data.l %11111100111001010, %10011100101111100, %11111101111011010, %10111101101111100
  Data.l %10011100100111110, %10111101100111110, %11111000110001010, %11111001110011010
  Data.l %11111011110111010, %11110000100001010, %11110001100011010, %11110011100111010
  Data.l %11110111101111010, %11100001000011010, %11100011000111010, %11100111001111010
  Data.l %11101111011111010, %11000010000111010, %11000110001111010, %11001110011111010
  Data.l %11011110111111010, %10000100001111010, %10001100011111010, %10011100111111010
  Data.l %10111100101111000, %11011110010111110, %10111100100111100, %10111100100011110
  Data.l %10011100010111110, %10111100110111110, %10111100010111100, %10111100010011110
  Data.l %10111100001011110, %11110000010101000, %11110000010100100, %11110000010100010
  Data.l %11100000101101000, %11110000010110110, %11100000101100100, %11100000101100010
  Data.l %11000001011101000, %11100000101110110, %11000001011100100, %11000001011100010
  Data.l %10000010111101000, %11000001011110110, %10000010111100100, %10000010111100010
  Data.l %10000010111110110, %11111000011010100, %10000110101111110, %11111000011010010
  Data.l %11110000010010100, %11110000110110100, %11110000010010010, %11110000110110010
  Data.l %11100000100110100, %11100001101110100, %11100000100110010, %11100001101110010
  Data.l %11000001001110100, %11000011011110100, %11000001001110010, %11000011011110010
  Data.l %10000010011110100, %10000110111110100, %10000010011110010, %10000110111110010
  Data.l %11111100011101010, %10001110101111100, %10001110100111110, %11111000011001010
  Data.l %11111000111011010, %11110000010001010, %11110000110011010, %11110001110111010
  Data.l %11100000100011010, %11100001100111010, %11100011101111010, %11000001000111010
  Data.l %11000011001111010, %11000111011111010, %10000010001111010, %10000110011111010
  Data.l %10001110111111010, %10011110101111000, %11001111010111110, %10011110100111100
  Data.l %10011110100011110, %10001110010111110, %10011110110111110, %10111110101110000
  Data.l %11011111010111100, %10111110100111000, %11011111010011110, %10111110100011100
  Data.l %10111110100001110, %10011110010111100, %10111110110111100, %10011110010011110
  Data.l %10111110110011110, %10111110010111000, %11011111001011110, %10111110010011100
  Data.l %10111110010001110, %10011110001011110, %10111110011011110, %10111110001011100
  Data.l %10111110001001110, %10111110000101110, %11100000010110100, %11100000010110010
  Data.l %11000000101110100, %11000000101110010, %10000001011110100, %10000001011110010
  Data.l %11110000011011010, %11100000010011010, %11100000110111010, %11000000100111010
  Data.l %11000001101111010, %10000001001111010, %10000011011111010, %10000111010111110
  Data.l %10001111010111100, %10001111010011110, %10011111010111000, %11001111101011110
  Data.l %10011111010011100, %10011111010001110, %10001111001011110, %10011111011011110
  Data.l %10111111010110000, %11011111101011100, %10111111010011000, %11011111101001110
  Data.l %10111111010001100, %10111111010000110, %10011111001011100, %10111111011011100
  Data.l %10011111001001110, %10111111011001110, %10111111001011000, %11011111100101110
  Data.l %10111111001001100, %10111111001000110, %10011111000101110, %10111111001101110
  Data.l %10111111000101100, %10111111000100110, %10000111101011110, %10001111101011100
  Data.l %10001111101001110, %10011111101011000, %11001111110101110, %10011111101001100
  Data.l %10011111101000110, %10001111100101110, %10011111101101110, %10011111100101100
  Data.l %10011111100100110
Last edited by bbanelli on Fri Jun 26, 2015 2:32 pm, edited 2 times in total.
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Part 2 of code

Post by bbanelli »

Code: Select all

  T3:
  Data.l %11010101111100000, %11101010111111000, %10101001111000000, %11010100111110000
  Data.l %11101010011111100, %10101000111100000, %11010100011111000, %11101010001111110
  Data.l %10101000011110000, %11010100001111100, %10101000001111000, %11111101011010000
  Data.l %10101101111100000, %11010110111111000, %11111101011001000, %10101100111110000
  Data.l %11010110011111100, %11111101011000100, %10101100011111000, %11010110001111110
  Data.l %11111101011000010, %10101100001111100, %11111010111010000, %11111101011101100
  Data.l %10101110111111000, %11111010111001000, %11111101011100110, %10101110011111100
  Data.l %11111010111000100, %10101110001111110, %11111010111000010, %11110101111010000
  Data.l %11111010111101100, %11110101111001000, %11111010111100110, %11110101111000100
  Data.l %11110101111000010, %11101011111010000, %11110101111101100, %11101011111001000
  Data.l %11110101111100110, %11101011111000100, %11101011111000010, %11010111111010000
  Data.l %11101011111101100, %11010111111001000, %11101011111100110, %11010111111000100
  Data.l %10100101111000000, %11010010111110000, %11101001011111100, %10100100111100000
  Data.l %11010010011111000, %11101001001111110, %10100100011110000, %11010010001111100
  Data.l %10100100001111000, %11010010000111110, %10100100000111100, %11111101001101000
  Data.l %10100110111110000, %11010011011111100, %11111101001100100, %10100110011111000
  Data.l %11010011001111110, %11111101001100010, %10100110001111100, %10100110000111110
  Data.l %11111010011101000, %11111101001110110, %10100111011111100, %11111010011100100
  Data.l %10100111001111110, %11111010011100010, %11110100111101000, %11111010011110110
  Data.l %11110100111100100, %11110100111100010, %11101001111101000, %11110100111110110
  Data.l %11101001111100100, %11101001111100010, %11010011111101000, %11101001111110110
  Data.l %11010011111100100, %11010011111100010, %10100010111100000, %11010001011111000
  Data.l %11101000101111110, %10100010011110000, %11010001001111100, %10100010001111000
  Data.l %11010001000111110, %10100010000111100, %10100010000011110, %11111101000110100
  Data.l %10100011011111000, %11010001101111110, %11111101000110010, %10100011001111100
  Data.l %10100011000111110, %11111010001110100, %10100011101111110, %11111010001110010
  Data.l %11110100011110100, %11110100011110010, %11101000111110100, %11101000111110010
  Data.l %11010001111110100, %11010001111110010, %10100001011110000, %11010000101111100
  Data.l %10100001001111000, %11010000100111110, %10100001000111100, %10100001000011110
  Data.l %11111101000011010, %10100001101111100, %10100001100111110, %11111010000111010
  Data.l %11110100001111010, %11101000011111010, %10100000101111000, %11010000010111110
  Data.l %10100000100111100, %10100000100011110, %10100000110111110, %10100000010111100
  Data.l %10100000010011110, %10010101111000000, %11001010111110000, %11100101011111100
  Data.l %10010100111100000, %11001010011111000, %11100101001111110, %10010100011110000
  Data.l %11001010001111100, %10010100001111000, %11001010000111110, %10010100000111100
  Data.l %11111100101101000, %10010110111110000, %11001011011111100, %11111100101100100
  Data.l %10010110011111000, %11001011001111110, %11111100101100010, %10010110001111100
  Data.l %10010110000111110, %11111001011101000, %11111100101110110, %10010111011111100
  Data.l %11111001011100100, %10010111001111110, %11111001011100010, %11110010111101000
  Data.l %11111001011110110, %11110010111100100, %11110010111100010, %11100101111101000
  Data.l %11110010111110110, %11100101111100100, %11100101111100010, %11001011111101000
  Data.l %11100101111110110, %11001011111100100, %11001011111100010, %11011010111100000
  Data.l %11101101011111000, %11110110101111110, %10110100111000000, %11011010011110000
  Data.l %11101101001111100, %10110100011100000, %11011010001111000, %11101101000111110
  Data.l %10110100001110000, %11011010000111100, %10110100000111000, %11011010000011110
  Data.l %10110100000011100, %10010010111100000, %11001001011111000, %11100100101111110
  Data.l %10110110111100000, %10010010011110000, %11001001001111100, %10110110011110000
  Data.l %11011011001111100, %11001001000111110, %10110110001111000, %10010010000111100
  Data.l %10110110000111100, %10010010000011110, %10110110000011110, %11111100100110100
  Data.l %10010011011111000, %11001001101111110, %11111101101110100, %11111100100110010
  Data.l %10110111011111000, %10010011001111100, %11111101101110010, %10110111001111100
  Data.l %10010011000111110, %10110111000111110, %11111001001110100, %10010011101111110
  Data.l %11111011011110100, %11111001001110010, %10110111101111110, %11111011011110010
  Data.l %11110010011110100, %11110110111110100, %11110010011110010, %11110110111110010
  Data.l %11100100111110100, %11101101111110100, %11100100111110010, %11101101111110010
  Data.l %11001001111110100, %11001001111110010, %10110010111000000, %11011001011110000
  Data.l %11101100101111100, %10110010011100000, %11011001001111000, %11101100100111110
  Data.l %10110010001110000, %11011001000111100, %10110010000111000, %11011001000011110
  Data.l %10110010000011100, %10110010000001110, %10010001011110000, %11001000101111100
  Data.l %10110011011110000, %10010001001111000, %11001000100111110, %10110011001111000
  Data.l %11011001100111110, %10110011000111100, %10010001000011110, %10110011000011110
  Data.l %11111100100011010, %10010001101111100, %11111101100111010, %10110011101111100
  Data.l %10010001100111110, %10110011100111110, %11111001000111010, %11111011001111010
  Data.l %11110010001111010, %11110110011111010, %11100100011111010, %11101100111111010
  Data.l %11001000111111010, %10110001011100000, %11011000101111000, %11101100010111110
  Data.l %10110001001110000, %11011000100111100, %10110001000111000, %11011000100011110
  Data.l %10110001000011100, %10110001000001110, %10010000101111000, %11001000010111110
  Data.l %10110001101111000, %10010000100111100, %10110001100111100, %10010000100011110
  Data.l %10110001100011110, %10010000110111110, %10110001110111110, %10110000101110000
  Data.l %11011000010111100, %10110000100111000, %11011000010011110, %10110000100011100
  Data.l %10110000100001110, %10010000010111100, %10110000110111100, %10010000010011110
  Data.l %10110000110011110, %10110000010111000, %11011000001011110, %10110000010011100
  Data.l %10110000010001110, %10010000001011110, %10110000011011110, %10110000001011100
  Data.l %10110000001001110, %10001010111100000, %11000101011111000, %11100010101111110
  Data.l %10001010011110000, %11000101001111100, %10001010001111000, %11000101000111110
  Data.l %10001010000111100, %10001010000011110, %11111100010110100, %10001011011111000
  Data.l %11000101101111110, %11111100010110010, %10001011001111100, %10001011000111110
  Data.l %11111000101110100, %10001011101111110, %11111000101110010, %11110001011110100
  Data.l %11110001011110010, %11100010111110100, %11100010111110010, %11000101111110100
  Data.l %11000101111110010, %10011010111000000, %11001101011110000, %11100110101111100
  Data.l %10011010011100000, %11001101001111000, %11100110100111110, %10011010001110000
  Data.l %11001101000111100, %10011010000111000, %11001101000011110, %10011010000011100
  Data.l %10011010000001110, %10001001011110000, %11000100101111100, %10011011011110000
  Data.l %10001001001111000, %11000100100111110, %10011011001111000, %11001101100111110
  Data.l %10011011000111100, %10001001000011110, %10011011000011110, %11111100010011010
  Data.l %10001001101111100, %11111100110111010, %10011011101111100, %10001001100111110
  Data.l %10011011100111110, %11111000100111010, %11111001101111010, %11110001001111010
  Data.l %11110011011111010, %11100010011111010, %11100110111111010, %11000100111111010
  Data.l %11011101011100000, %11101110101111000, %11110111010111110, %10111010011000000
  Data.l %11011101001110000, %11101110100111100, %10111010001100000, %11011101000111000
  Data.l %11101110100011110, %10111010000110000, %11011101000011100, %10111010000011000
  Data.l %11011101000001110, %10111010000001100, %10011001011100000, %11001100101111000
  Data.l %11100110010111110, %10111011011100000, %10011001001110000, %11001100100111100
  Data.l %10111011001110000, %11011101100111100, %11001100100011110, %10111011000111000
  Data.l %10011001000011100, %10111011000011100, %10011001000001110, %10111011000001110
  Data.l %10001000101111000, %11000100010111110, %10011001101111000, %10001000100111100
  Data.l %10111011101111000, %10011001100111100, %10001000100011110, %10111011100111100
  Data.l %10011001100011110, %10111011100011110, %10001000110111110, %10011001110111110
  Data.l %10111011110111110, %10111001011000000, %11011100101110000, %11101110010111100
  Data.l %10111001001100000, %11011100100111000, %11101110010011110, %10111001000110000
  Data.l %11011100100011100, %10111001000011000, %11011100100001110, %10111001000001100
  Data.l %10111001000000110, %10011000101110000, %11001100010111100, %10111001101110000
  Data.l %10011000100111000, %11001100010011110, %10111001100111000, %11011100110011110
  Data.l %10111001100011100, %10011000100001110, %10111001100001110, %10001000010111100
  Data.l %10011000110111100, %10001000010011110, %10111001110111100, %10011000110011110
  Data.l %10111001110011110, %10111000101100000, %11011100010111000, %11101110001011110
  Data.l %10111000100110000, %11011100010011100, %10111000100011000, %11011100010001110
  Data.l %10111000100001100, %10111000100000110, %10011000010111000, %11001100001011110
  Data.l %10111000110111000, %10011000010011100, %10111000110011100, %10011000010001110
  Data.l %10111000110001110, %10001000001011110, %10011000011011110, %10111000111011110
  Data.l %10111000010110000, %11011100001011100, %10111000010011000, %11011100001001110
  Data.l %10111000010001100, %10111000010000110, %10011000001011100, %10111000011011100
  Data.l %10011000001001110, %10111000011001110, %10111000001011000, %11011100000101110
  Data.l %10111000001001100, %10111000001000110, %10011000000101110, %10111000001101110
  Data.l %10111000000101100, %10111000000100110, %10000101011110000, %11000010101111100
  Data.l %10000101001111000, %11000010100111110, %10000101000111100, %10000101000011110
  Data.l %10000101101111100, %10000101100111110, %11111000010111010, %11110000101111010
  Data.l %11100001011111010, %11000010111111010, %10001101011100000, %11000110101111000
  Data.l %11100011010111110, %10001101001110000, %11000110100111100, %10001101000111000
  Data.l %11000110100011110, %10001101000011100, %10001101000001110, %10000100101111000
  Data.l %11000010010111110, %10001101101111000, %10000100100111100, %10001101100111100
  Data.l %10000100100011110, %10001101100011110, %10000100110111110, %10001101110111110
  Data.l %10011101011000000, %11001110101110000, %11100111010111100, %10011101001100000
  Data.l %11001110100111000, %11100111010011110, %10011101000110000, %11001110100011100
  Data.l %10011101000011000, %11001110100001110, %10011101000001100, %10011101000000110
  Data.l %10001100101110000, %11000110010111100, %10011101101110000, %10001100100111000
  Data.l %11000110010011110, %10011101100111000, %10001100100011100, %10011101100011100
  Data.l %10001100100001110, %10011101100001110, %10000100010111100, %10001100110111100
  Data.l %10000100010011110, %10011101110111100, %10001100110011110, %10011101110011110
  Data.l %11011110101100000, %11101111010111000, %11110111101011110, %10111101001000000
  Data.l %11011110100110000, %11101111010011100, %10111101000100000, %11011110100011000
  Data.l %11101111010001110, %10111101000010000, %11011110100001100, %10111101000001000
  Data.l %11011110100000110, %10111101000000100, %10011100101100000, %11001110010111000
  Data.l %11100111001011110, %10111101101100000, %10011100100110000, %11001110010011100
  Data.l %10111101100110000, %11011110110011100, %11001110010001110, %10111101100011000
  Data.l %10011100100001100, %10111101100001100, %10011100100000110, %10111101100000110
  Data.l %10001100010111000, %11000110001011110, %10011100110111000, %10001100010011100
  Data.l %10111101110111000, %10011100110011100, %10001100010001110, %10111101110011100
  Data.l %10011100110001110, %10111101110001110, %10000100001011110, %10001100011011110
  Data.l %10011100111011110, %10111101111011110, %10111100101000000, %11011110010110000
  Data.l %11101111001011100, %10111100100100000, %11011110010011000, %11101111001001110
  Data.l %10111100100010000, %11011110010001100, %10111100100001000, %11011110010000110
  Data.l %10111100100000100, %10111100100000010, %10011100010110000, %11001110001011100
  Data.l %10111100110110000, %10011100010011000, %11001110001001110, %10111100110011000
  Data.l %11011110011001110, %10111100110001100, %10011100010000110, %10111100110000110
  Data.l %10001100001011100, %10011100011011100, %10001100001001110, %10111100111011100
  Data.l %10011100011001110, %10111100111001110, %10111100010100000, %11011110001011000
  Data.l %11101111000101110, %10111100010010000, %11011110001001100, %10111100010001000
  Data.l %11011110001000110, %10111100010000100, %10111100010000010, %10011100001011000
  Data.l %11001110000101110, %10111100011011000, %10011100001001100, %10111100011001100
  Data.l %10011100001000110, %10111100011000110, %10001100000101110, %10011100001101110
  Data.l %10111100011101110, %10111100001010000, %11011110000101100, %10111100001001000
  Data.l %11011110000100110, %10111100001000100, %10111100001000010, %10011100000101100
  Data.l %10111100001101100, %10011100000100110, %10111100001100110, %10111100000101000
  Data.l %11011110000010110, %10111100000100100, %10111100000100010, %10011100000010110
  Data.l %10111100000110110, %10000010101111000, %11000001010111110, %10000010100111100
  Data.l %10000010100011110, %10000010110111110, %10000110101110000, %11000011010111100
  Data.l %10000110100111000, %11000011010011110, %10000110100011100, %10000110100001110
  Data.l %10000010010111100, %10000110110111100, %10000010010011110, %10000110110011110
  Data.l %10001110101100000, %11000111010111000, %11100011101011110, %10001110100110000
  Data.l %11000111010011100, %10001110100011000, %11000111010001110, %10001110100001100
  Data.l %10001110100000110, %10000110010111000, %11000011001011110, %10001110110111000
  Data.l %10000110010011100, %10001110110011100, %10000110010001110, %10001110110001110
  Data.l %10000010001011110, %10000110011011110, %10001110111011110, %10011110101000000
  Data.l %11001111010110000, %11100111101011100, %10011110100100000, %11001111010011000
  Data.l %11100111101001110, %10011110100010000, %11001111010001100, %10011110100001000
  Data.l %11001111010000110, %10011110100000100, %10011110100000010, %10001110010110000
  Data.l %11000111001011100, %10011110110110000, %10001110010011000, %11000111001001110
  Data.l %10011110110011000, %11001111011001110, %10011110110001100, %10001110010000110
  Data.l %10011110110000110, %10000110001011100, %10001110011011100, %10000110001001110
  Data.l %10011110111011100, %10001110011001110, %10011110111001110, %11011111010100000
  Data.l %11101111101011000, %11110111110101110, %11011111010010000, %11101111101001100
  Data.l %11011111010001000, %11101111101000110, %11011111010000100, %11011111010000010
  Data.l %10011110010100000, %11001111001011000, %11100111100101110, %10111110110100000
  Data.l %10011110010010000, %11001111001001100, %10111110110010000, %11011111011001100
  Data.l %11001111001000110, %10111110110001000, %10011110010000100, %10111110110000100
  Data.l %10011110010000010, %10111110110000010, %10001110001011000, %11000111000101110
  Data.l %10011110011011000, %10001110001001100, %10111110111011000, %10011110011001100
  Data.l %10001110001000110, %10111110111001100, %10011110011000110, %10111110111000110
  Data.l %10000110000101110, %10001110001101110, %10011110011101110, %10111110111101110
  Data.l %11011111001010000, %11101111100101100, %11011111001001000, %11101111100100110
  Data.l %11011111001000100, %11011111001000010, %10011110001010000, %11001111000101100
  Data.l %10111110011010000, %10011110001001000, %11001111000100110, %10111110011001000
  Data.l %11011111001100110, %10111110011000100, %10011110001000010, %10111110011000010
  Data.l %10001110000101100, %10011110001101100, %10001110000100110, %10111110011101100
  Data.l %10011110001100110, %10111110011100110, %11011111000101000, %11101111100010110
  Data.l %11011111000100100, %11011111000100010, %10011110000101000, %11001111000010110
  Data.l %10111110001101000, %10011110000100100, %10111110001100100, %10011110000100010
  Data.l %10111110001100010, %10001110000010110, %10011110000110110, %10111110001110110
  Data.l %11011111000010100, %11011111000010010, %10011110000010100, %10111110000110100
  Data.l %10011110000010010, %10111110000110010, %10000001010111100, %10000001010011110
  Data.l %10000011010111000, %11000001101011110, %10000011010011100, %10000011010001110
  Data.l %10000001001011110, %10000011011011110, %10000111010110000, %11000011101011100
  Data.l %10000111010011000, %11000011101001110, %10000111010001100, %10000111010000110
  Data.l %10000011001011100, %10000111011011100, %10000011001001110, %10000111011001110
  Data.l %10001111010100000, %11000111101011000, %11100011110101110, %10001111010010000
  Data.l %11000111101001100, %10001111010001000, %11000111101000110, %10001111010000100
  Data.l %10001111010000010, %10000111001011000, %11000011100101110, %10001111011011000
  Data.l %11000111101101110, %10001111011001100, %10000111001000110, %10001111011000110
  Data.l %10000011000101110, %10000111001101110, %10001111011101110, %11001111101010000
  Data.l %11100111110101100, %11001111101001000, %11100111110100110, %11001111101000100
  Data.l %11001111101000010, %10001111001010000, %11000111100101100, %10011111011010000
  Data.l %11001111101101100, %11000111100100110, %10011111011001000, %10001111001000100
  Data.l %10011111011000100, %10001111001000010, %10011111011000010, %10000111000101100
  Data.l %10001111001101100, %10000111000100110, %10011111011101100, %10001111001100110
  Data.l %10011111011100110, %11101111110101000, %11110111111010110, %11101111110100100
  Data.l %11101111110100010, %11001111100101000, %11100111110010110, %11011111101101000
  Data.l %11001111100100100, %11011111101100100, %11001111100100010, %11011111101100010
  Data.l %10001111000101000, %11000111100010110, %10011111001101000, %10001111000100100
  Data.l %10111111011101000, %10011111001100100, %10001111000100010, %10111111011100100
  Data.l %10011111001100010, %10111111011100010, %10000111000010110, %10001111000110110
  Data.l %10011111001110110, %10111111011110110, %11101111110010100, %11101111110010010
  Data.l %11001111100010100, %11011111100110100, %11001111100010010, %11011111100110010
  Data.l %10001111000010100, %10011111000110100, %10001111000010010, %10111111001110100
  Data.l %10011111000110010, %10111111001110010, %11101111110001010, %11001111100001010
  Data.l %11011111100011010, %10001111000001010, %10011111000011010, %10111111000111010
  Data.l %10000001101011100, %10000001101001110, %10000011101011000, %11000001110101110
  Data.l %10000011101001100, %10000011101000110, %10000001100101110, %10000011101101110
  Data.l %10000111101010000, %11000011110101100, %10000111101001000, %11000011110100110
  Data.l %10000111101000100, %10000111101000010, %10000011100101100, %10000111101101100
  Data.l %10000011100100110, %10000111101100110, %11000111110101000, %11100011111010110
  Data.l %11000111110100100, %11000111110100010, %10000111100101000, %11000011110010110
  Data.l %10001111101101000, %11000111110110110, %10001111101100100, %10000111100100010
  Data.l %10001111101100010, %10000011100010110, %10000111100110110, %10001111101110110
  Data.l %11100111111010100, %11100111111010010, %11000111110010100, %11001111110110100
  Data.l %11000111110010010, %11001111110110010, %10000111100010100, %10001111100110100
  Data.l %10000111100010010, %10011111101110100, %10001111100110010, %10011111101110010
  Data.l %11100111111001010, %11000111110001010, %11001111110011010, %10000111100001010
  Data.l %10001111100011010, %10011111100111010, %10000001110101100, %10000001110100110
  Data.l %10000011110101000, %11000001111010110, %10000011110100100, %10000011110100010
  Data.l %10000001110010110, %10000011110110110, %11000011111010100, %11000011111010010
  Data.l %10000011110010100, %10000111110110100, %10000011110010010, %10000111110110010
  Data.l %11100011111101010
  
  FA0:
  Data.u  27, 917
  FA1:
  Data.u 522, 568, 723, 809
  FA2:
  Data.u 237, 308, 436, 284, 646, 653, 428, 379
  FA3:
  Data.u 274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295,  42, 176,  65
  FA4:
  Data.u 361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517
  Data.u 273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330,  63, 410
  FA5:
  Data.u 539, 422,   6,  93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, 612
  Data.u 723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, 283, 184
  Data.u 440,  35, 519,  31, 460, 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502
  Data.u 648, 733, 717,  83, 404,  97, 280, 771, 840, 629,   4, 381, 843, 623, 264, 543
  FA6:
  Data.u 521, 310, 864, 547, 858, 580, 296, 379,  53, 779, 897, 444, 400, 925, 749, 415
  Data.u 822,  93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, 490, 704
  Data.u 516, 258, 457, 907, 594, 723, 674, 292, 272,  96, 684, 432, 686, 606, 860, 569
  Data.u 193, 219, 129, 186, 236, 287, 192, 775, 278, 173,  40, 379, 712, 463, 646, 776
  Data.u 171, 491, 297, 763, 156, 732,  95, 270, 447,  90, 507,  48, 228, 821, 808, 898
  Data.u 784, 663, 627, 378, 382, 262, 380, 602, 754, 336,  89, 614,  87, 432, 670, 616
  Data.u 157, 374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814, 587, 804,  34
  Data.u 211, 330, 539, 297, 827, 865,  37, 517, 834, 315, 550,  86, 801,   4, 108, 539
  FA7:
  Data.u 524, 894,  75, 766, 882, 857,  74, 204,  82, 586, 708, 250, 905, 786, 138, 720
  Data.u 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, 828, 757
  Data.u 710, 814, 919,  89,  68, 569,  11, 204, 796, 605, 540, 913, 801, 700, 799, 137
  Data.u 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284, 549, 209, 884
  Data.u 315,  70, 329, 793, 490, 274, 877, 162, 749, 812, 684, 461, 334, 376, 849, 521
  Data.u 307, 291, 803, 712,  19, 358, 399, 908, 103, 511,  51,   8, 517, 225, 289, 470
  Data.u 637, 731,  66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136, 538, 906,  90
  Data.u   2, 290, 743, 199, 655, 903, 329,  49, 802, 580, 355, 588, 188, 462,  10, 134
  Data.u 628, 320, 479, 130, 739,  71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234
  Data.u 722, 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641,  48,  60, 732, 621
  Data.u 895, 544, 261, 852, 655, 309, 697, 755, 756,  60, 231, 773, 434, 421, 726, 528
  Data.u 503, 118,  49, 795,  32, 144, 500, 238, 836, 394, 280, 566, 319,   9, 647, 550
  Data.u  73, 914, 342, 126,  32, 681, 331, 792, 620,  60, 609, 441, 180, 791, 893, 754
  Data.u 605, 383, 228, 749, 760, 213,  54, 297, 134,  54, 834, 299, 922, 191, 910, 532
  Data.u 609, 829, 189,  20, 167,  29, 872, 449,  83, 402,  41, 656, 505, 579, 481, 173
  Data.u 404, 251, 688,  95, 497, 555, 642, 543, 307, 159, 924, 558, 648,  55, 497,  10
  FA8:
  Data.u 352,  77, 373, 504,  35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, 492
  Data.u 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306,  88,  87, 193, 352, 781
  Data.u 846,  75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534
  Data.u 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545,  37, 858, 916, 552,  41
  Data.u 542, 289, 122, 272, 383, 800, 485,  98, 752, 472, 761, 107, 784, 860, 658, 741
  Data.u 290, 204, 681, 407, 855,  85,  99,  62, 482, 180,  20, 297, 451, 593, 913, 142
  Data.u 808, 684, 287, 536, 561,  76, 653, 899, 729, 567, 744, 390, 513, 192, 516, 258
  Data.u 240, 518, 794, 395, 768, 848,  51, 610, 384, 168, 190, 826, 328, 596, 786, 303
  Data.u 570, 381, 415, 641, 156, 237, 151, 429, 531, 207, 676, 710,  89, 168, 304, 402
  Data.u  40, 708, 575, 162, 864, 229,  65, 861, 841, 512, 164, 477, 221,  92, 358, 785
  Data.u 288, 357, 850, 836, 827, 736, 707,  94,   8, 494, 114, 521,   2, 499, 851, 543
  Data.u 152, 729, 771,  95, 248, 361, 578, 323, 856, 797, 289,  51, 684, 466, 533, 820
  Data.u 669,  45, 902, 452, 167, 342, 244, 173,  35, 463, 651,  51, 699, 591, 452, 578
  Data.u  37, 124, 298, 332, 552,  43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911
  Data.u 283, 711, 472, 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688,  43, 408
  Data.u 842, 383, 721, 521, 560, 644, 714, 559,  62, 145, 873, 663, 713, 159, 672, 729
  Data.u 624,  59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772
  Data.u 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536,  35, 777
  Data.u 618, 586, 424, 833,  77, 597, 346, 269, 757, 632, 695, 751, 331, 247, 184,  45
  Data.u 787, 680,  18,  66, 407, 369,  54, 492, 228, 613, 830, 922, 437, 519, 644, 905
  Data.u 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513,  56, 252, 341
  Data.u 242, 797, 838, 837, 720, 224, 307, 631,  61,  87, 560, 310, 756, 665, 397, 808
  Data.u 851, 309, 473, 795, 378,  31, 647, 915, 459, 806, 590, 731, 425, 216, 548, 249
  Data.u 321, 881, 699, 535, 673, 782, 210, 815, 905, 303, 843, 922, 281,  73, 469, 791
  Data.u 660, 162, 498, 308, 155, 422, 907, 817, 187,  62,  16, 425, 535, 336, 286, 437
  Data.u 375, 273, 610, 296, 183, 923, 116, 667, 751, 353,  62, 366, 691, 379, 687, 842
  Data.u  37, 357, 720, 742, 330,   5,  39, 923, 311, 424, 242, 749, 321,  54, 669, 316
  Data.u 342, 299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, 610,  46, 656
  Data.u 447, 171, 616, 464, 190, 531, 297, 321, 762, 752, 533, 175, 134,  14, 381, 433
  Data.u 717,  45, 111,  20, 596, 284, 736, 138, 646, 411, 877, 669, 141, 919,  45, 780
  Data.u 407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647
  Data.u  63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244,  31, 121, 303, 263
EndDataSection

; Procedures
Procedure ByteCompactionModeEncoding(Array X.u(1), List ByteCodewords.i())
  Define S.q, n.i, m.i, i.i, *FirstElement, *SecondElement
  Define NewList Temp.i()
  
  ; Instead of using Pow(256,x), fixed numbers are used in order to reduce computation time in general
  S = X(5) * 1099511627776 + X(4) * 4294967296 + X(3) * 16777216 + X(2) * 65536 + X(1) * 256 + X(0)
  AddElement (Temp())
  Temp() = S % 900
;   CodeWordsArray(0) = S % 900
  S = S / 900
  ;   CodeWordsArray(1) = S % 900
  AddElement (Temp())
  Temp() = S % 900 
  S = S / 900
  ;   CodeWordsArray(2) = S % 900
  AddElement (Temp())
  Temp() = S % 900 
  S = S / 900
  ;   CodeWordsArray(3) = S % 900
  AddElement (Temp())
  Temp() = S % 900
  S = S / 900
  ;   CodeWordsArray(4) = S % 900
  AddElement (Temp())
  Temp() = S % 900
  ; Reverse codeword list order obtained by algorithm
  ResetList(Temp())
  n = ListSize(Temp())
  For i = 0 To (n - 1) / 2
    SelectElement(Temp(),i)
    *FirstElement = @Temp()
    SelectElement(Temp(),n - i - 1)
    *SecondElement = @Temp()
    SwapElements(Temp(), *FirstElement, *SecondElement)
  Next
  MergeLists(Temp(),ByteCodewords(),#PB_List_Last)
EndProcedure

Procedure LeftRowIndicatorsEncoding(Array LeftRowIndicators.i(1))
  Protected CurrentRowNumber.b
  For CurrentRowNumber = 1 To #NumberOfRows
    If ((CurrentRowNumber - 1) % 3) * 3 = 0
      LeftRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + (#NumberOfRows - 1) / 3
    ElseIf ((CurrentRowNumber - 1) % 3) * 3 = 3
      LeftRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + (#ECCLevel * 3) + ((#NumberOfRows - 1) % 3)
    ElseIf ((CurrentRowNumber - 1) % 3) * 3 = 6
      LeftRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + (#NumberOfColumns - 1)
    EndIf
  Next
EndProcedure

Procedure RightRowIndicatorsEncoding(Array RightRowIndicators.i(1))
  Protected CurrentRowNumber.b
  For CurrentRowNumber = 1 To #NumberOfRows
    If ((CurrentRowNumber - 1) % 3) * 3 = 0
      RightRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + (#NumberOfColumns - 1)
    ElseIf ((CurrentRowNumber - 1) % 3) * 3 = 3
      RightRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + ((#NumberOfRows - 1) / 3)
    ElseIf ((CurrentRowNumber - 1) % 3) * 3 = 6
      RightRowIndicators(CurrentRowNumber - 1) = 30 * ((CurrentRowNumber - 1) / 3) + (#ECCLevel * 3) + ((#NumberOfRows - 1) % 3)
    EndIf
  Next
EndProcedure

Procedure GetCodeForDrawingBar(TableCodeWord.l, List BarsDrawingCode.a())
  ClearList(BarsDrawingCode())
  While TableCodeWord > 0
    AddElement(BarsDrawingCode())
    BarsDrawingCode() = TableCodeWord & 1
    MoveElement(BarsDrawingCode(), #PB_List_First)
    TableCodeWord >> 1
  Wend 
EndProcedure

Procedure.i CreatePDF417(Text$)
  Protected.a RowScaleFactor, b, ColumnNumber, Cluster ; i for loop iterator, b for byte loop in character mode
  Protected.i Image, NewImage, ImageWidth, ImageHeight, x, y, i, j, OriginalTextLength, m, k, n, NumberOfPads
  Protected.q t1, t2, t3
  Protected CharText6$                  ; Text to be used to encode in PDF417, CharText6 as temporary variable in byte mode loop
  Protected *FA
  
  Protected Dim X.u(5), Dim CodeWordsArray.i(1), Dim LeftRowIndicators.i(1), Dim RightRowIndicators.i(1), Dim ECC.i(1), Dim DataArray.i(1) ; Arrays definition
  
  Protected NewList BarsDrawingCode.a() ; Linked list for storing temporary code for drawing current bar
  Protected NewList ByteCodewords.i() ; Data codeword linked list
  
  ; Code for byte replacement of UTF-8 characters - you have to add your own characters (case-sensitive!) and make byte replacement. This procedure effectively uses *2 bytes for any original size of character. Example is commented below for 'capital C with caron'.
  ; Text$ = ReplaceString(Text$,"C", Chr($C4)+Chr($8C)) ;C C4 8C
  
  OriginalTextLength = Len(Text$)
  ; End of coding text part
  
  While Len(Text$) > 0
    If Len(Text$) >= 6
      b = 5
      CharText6$ = Left(Text$,6)
      While Len(CharText6$) > 0
        X(b) = Asc(Left(CharText6$, 1))
        CharText6$ = Right(CharText6$, Len(CharText6$)-1)
        b - 1
      Wend
      ByteCompactionModeEncoding(X(), ByteCodewords())
      Text$ = Right(Text$,Len(Text$)-6)
    Else
      While Len(Text$) > 0
        AddElement(ByteCodewords())
        ByteCodewords() = PeekB(@Text$)
        MoveElement(ByteCodewords(),#PB_List_Last)
        Text$ = Right(Text$,Len(Text$)-1)
      Wend   
    EndIf
  Wend
  
  ; If the byte number is a multiple of 6, we use the 924 codeword to switch to "Byte" mode; if the byte number is not a multiple of 6 we use 901 codeword for switching.
  ResetList(ByteCodewords())
  If OriginalTextLength % 6 = 0
    AddElement(ByteCodewords())
    ByteCodewords() = 924
  Else
    AddElement(ByteCodewords())
    ByteCodewords() = 901
  EndIf
  
  m = ListSize(ByteCodewords()) ; Number of source data codewords prior to the addition of the Symbol Length Descriptor and any pad codewords
  k = Pow(2,#ECCLevel+1) ; Number of error correction codewords
  n = #NumberOfColumns * #NumberOfRows - k ; Total number of data codewords including Symbol Length Descriptor and any pad codewords
  
  ; Add length descriptor
  AddElement(ByteCodewords())
  ByteCodewords() = n
  MoveElement(ByteCodewords(),#PB_List_First)
  
  ; Pad if neccessary
  If n > m + 1
    i = 0
    NumberOfPads.i = (n - m) - 1
    While NumberOfPads - i > 0
      AddElement(ByteCodewords())
      ByteCodewords() = 900
      MoveElement(ByteCodewords(),#PB_List_Last)
      i + 1
    Wend
  EndIf
  
  ReDim CodeWordsArray(n - 1)
  
  ; Copy list to array and delete list since we do not need it any more
  i = 0
  ForEach ByteCodewords()
    CodeWordsArray(i) = ByteCodewords()
    i + 1
  Next
  FreeList(ByteCodewords())
  
  ; Change dimension of ECC array
  ReDim ECC(k - 1)
  
  Select #ECCLevel
    Case 0 : *FA = ?FA0
    Case 1 : *FA = ?FA1
    Case 2 : *FA = ?FA2
    Case 3 : *FA = ?FA3
    Case 4 : *FA = ?FA4
    Case 5 : *FA = ?FA5
    Case 6 : *FA = ?FA6
    Case 7 : *FA = ?FA7
    Case 8 : *FA = ?FA8
  EndSelect
  
  m = ArraySize(CodeWordsArray()); Calculated on the basis of the values of all the data codewords including the Symbol Length Descriptor and any pad codewords
  
  For i = 0 To m
    t1 = (CodeWordsArray(i) + ECC(k - 1)) % 929
    For j = k - 1 To 1 Step -1
      t2 = (t1 * PeekU(*Fa + (j << 1))) % 929
      t3 = 929 - t2
      ECC(j) = (ECC(j - 1) + t3) % 929
    Next
    t2 = (t1 * PeekU(*Fa)) % 929
    t3 = 929 - t2
    ECC(0) = t3 % 929
  Next
  For j = 0 To k - 1
    If ECC(j) <> 0
      ECC(j) = 929 - ECC(j)
    EndIf
  Next
  
  ; Alternative versions of ECC algoritham
;   For i = 0 To m - 1
;     t1 = (CodeWordsArray(i) + ECC(k - 1)) % 929
;     For j = k - 1 To 0 Step -1
;       If j = 0
;         ECC(j) = (929 - (t1 * Fa(j)) % 929) % 929
;       Else
;         ECC(j) = (ECC(j - 1) + 929 - (t1 * Fa(j)) % 929) % 929
;       EndIf
;     Next
;   Next
;   For j = 0 To k - 1
;     If ECC(j) <> 0
;       ECC(j) = (929 - ECC(j)) % 929
;     EndIf
;   Next
  
  ReDim DataArray(ArraySize(CodeWordsArray()) + ArraySize(ECC()) + 1)
  
  For i = 0 To ArraySize(CodeWordsArray())
    DataArray(i) = CodeWordsArray(i)
  Next
  
  j = k - 1
  
  For i = ArraySize(CodeWordsArray()) + 1 To ArraySize(DataArray())
    DataArray(i) = ECC(j)
    j - 1
  Next
  
  ; Left row indicator
  ReDim LeftRowIndicators(#NumberOfRows - 1)
  LeftRowIndicatorsEncoding(LeftRowIndicators())
  
  ; Right row indicator
  ReDim RightRowIndicators(#NumberOfRows - 1)
  RightRowIndicatorsEncoding(RightRowIndicators())
  
  
  ImageHeight = (#NumberOfRows + 2) * 3
  
  Image = CreateImage(#PB_Any, #ImageMaxWidth, ImageHeight, 24, RGB(255,255,255))
  If Image
    
    If StartDrawing(ImageOutput(Image))
      
      For y = 1 To #NumberOfRows
      
        ColumnNumber = 1
      
        ; Draw Start Character
        GetCodeForDrawingBar(#StartCharacter, BarsDrawingCode())
        ResetList(BarsDrawingCode())
        For x = 0 To 17
          NextElement(BarsDrawingCode())
          If BarsDrawingCode()
            Box(x, y*3, 1, 3, RGB(0,0,0))
          Else
            Continue
          EndIf
        Next
        
        ; Draw Left Row Character
        If ((y - 1) % 3) * 3 = 0
          GetCodeForDrawingBar(PeekL(?T1 + (LeftRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 17 To 34
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next
        ElseIf ((y - 1) % 3) * 3 = 3
          GetCodeForDrawingBar(PeekL(?T2 + (LeftRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 17 To 34
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next   
        ElseIf ((y - 1) % 3) * 3 = 6
          GetCodeForDrawingBar(PeekL(?T3 + (LeftRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 17 To 34
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next
        EndIf
        
        ; Draw data codewords
        For j = (y - 1) * 9 To (y * 9) - 1
          ; Two special casef for switching rows
          If j = 0
            RowScaleFactor = 1
          ElseIf j%#NumberOfColumns = 0
            RowScaleFactor = Round(j/#NumberOfColumns,#PB_Round_Up) + 1
          Else
            RowScaleFactor = Round(j/#NumberOfColumns,#PB_Round_Up)
          EndIf
          If ((RowScaleFactor - 1) % 3) * 3 = 0
            GetCodeForDrawingBar(PeekL(?T1 + (DataArray(j) << 2)), BarsDrawingCode())
            ResetList(BarsDrawingCode())
            For x = 34 + (17 * (ColumnNumber - 1)) To 51 + (17 * (ColumnNumber - 1))
              NextElement(BarsDrawingCode())
              If BarsDrawingCode()
                Box(x, y*3, 1, 3, RGB(0,0,0))
              Else
                Continue
              EndIf
            Next
          ElseIf ((RowScaleFactor - 1) % 3) * 3 = 3
            GetCodeForDrawingBar(PeekL(?T2 + (DataArray(j) << 2)), BarsDrawingCode())
            ResetList(BarsDrawingCode())
            For x = 34 + (17 * (ColumnNumber - 1)) To 51 + (17 * (ColumnNumber - 1))
              NextElement(BarsDrawingCode())
              If BarsDrawingCode()
                Box(x, y*3, 1, 3, RGB(0,0,0))
              Else
                Continue
              EndIf
            Next
          ElseIf ((RowScaleFactor - 1) % 3) * 3 = 6
            GetCodeForDrawingBar(PeekL(?T3 + (DataArray(j) << 2)), BarsDrawingCode())
            ResetList(BarsDrawingCode())
            For x = 34 + (17 * (ColumnNumber - 1)) To 51 + (17 * (ColumnNumber - 1))
              NextElement(BarsDrawingCode())
              If BarsDrawingCode()
                Box(x, y*3, 1, 3, RGB(0,0,0))
              Else
                Continue
              EndIf
            Next
          EndIf
          ColumnNumber + 1
        Next
       
        ; Return one Column back due to the loop for Data Codewords
        ColumnNumber - 1
       
  ;       Draw Right Row Character
        If ((y - 1) % 3) * 3 = 0
          GetCodeForDrawingBar(PeekL(?T1 + (RightRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 51 + (17 * (ColumnNumber - 1)) To 68 + (17 * (ColumnNumber - 1))
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next x
        ElseIf ((y - 1) % 3) * 3 = 3
          GetCodeForDrawingBar(PeekL(?T2 + (RightRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 51 + (17 * (ColumnNumber - 1)) To 68 + (17 * (ColumnNumber - 1))
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next x
        ElseIf ((y - 1) % 3) * 3 = 6
          GetCodeForDrawingBar(PeekL(?T3 + (RightRowIndicators(y-1) << 2)), BarsDrawingCode())
          ResetList(BarsDrawingCode())
          For x = 51 + (17 * (ColumnNumber - 1)) To 68 + (17 * (ColumnNumber - 1))
            NextElement(BarsDrawingCode())
            If BarsDrawingCode()
              Box(x, y*3, 1, 3, RGB(0,0,0))
            Else
              Continue
            EndIf
          Next x
        EndIf
       
        ; Draw Stop Character
        GetCodeForDrawingBar(#StopCharacter, BarsDrawingCode())
        ResetList(BarsDrawingCode())
        For x = 51 + (17 * (ColumnNumber)) To 68 + (17 * (ColumnNumber))
          NextElement(BarsDrawingCode())
          If BarsDrawingCode()
            Box(x, y*3, 1, 3, RGB(0,0,0))
          Else
            Continue
          EndIf
        Next x
       
      Next
      
      StopDrawing()
      
      ImageWidth = 68 + (17 * (ColumnNumber)) + 1 + 3
      
      NewImage = GrabImage(Image, #PB_Any, 0, 0, ImageWidth, ImageHeight)
      If NewImage
        FreeImage(Image)
        Image = NewImage
      Else
        FreeImage(Image)
        Image = 0
      EndIf      
      
    EndIf
  EndIf
  
  ProcedureReturn Image
EndProcedure

;- Demo
CompilerIf #PB_Compiler_IsMainFile
  ; Definitions of variables, EnableExplicite
  Define.i Image, x, y, Event
  
  UsePNGImageEncoder()
  
  ; This is text variable to be encoded in PDF417
  Image = CreatePDF417("PureBasic is the best! :)")
  If Image
    
    SaveImage(Image, "PDF417.png", #PB_ImagePlugin_PNG)
    
    If OpenWindow(0, 0, 0, ImageWidth(Image), ImageHeight(Image), "PDF417", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
      ImageGadget(0, 0, 0, 0, 0, ImageID(Image))
      
      Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
      
    EndIf
  EndIf
CompilerEndIf
Last edited by bbanelli on Wed Jul 13, 2016 10:06 am, edited 4 times in total.
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PDF417 barcode encoder (crossplatform)

Post by bbanelli »

Greetings to all,

I finally found some time and fixed my faulty PDF417 2D barcode encoder code. Hope it will help someone!

With my best,

Bruno
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
Liqu
User
User
Posts: 77
Joined: Sun Apr 21, 2013 10:31 am

Re: PDF417 barcode encoder (crossplatform)

Post by Liqu »

bbanelli wrote:Greetings to all,

I finally found some time and fixed my faulty PDF417 2D barcode encoder code. Hope it will help someone!

With my best,

Bruno
Whoa, thanks a lot for your great work!
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: PDF417 barcode encoder (crossplatform)

Post by Kwai chang caine »

Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PDF417 barcode encoder (crossplatform)

Post by bbanelli »

Code has been updated. Perhaps this should be moved to Tips&Tricks?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: PDF417 barcode encoder (crossplatform)

Post by Keya »

bbanelli great code and thanks for sharing! :)
just two things - it's crashing if #ECCLevel = 7 or 8
and, any idea how to determine how many bytes can be stored? if too much is tried to be stored it currently also crashes
Post Reply