You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
4.0KB

  1. #!/usr/bin/python2.5
  2. #
  3. # Copyright 2014 Olivier Gillet.
  4. #
  5. # Author: Olivier Gillet (ol.gillet@gmail.com)
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. # THE SOFTWARE.
  24. #
  25. # See http://creativecommons.org/licenses/MIT/ for more information.
  26. #
  27. # -----------------------------------------------------------------------------
  28. #
  29. # Characters definitions.
  30. characters = []
  31. MASKS = {
  32. 'a': 0x8000,
  33. 'b': 0x4000,
  34. 'c': 0x2000,
  35. 'd': 0x1000,
  36. 'e': 0x0800,
  37. 'f': 0x0400,
  38. 'g': 0x0200,
  39. 'h': 0x0100,
  40. 'j': 0x80,
  41. 'k': 0x40,
  42. 'l': 0x20,
  43. 'm': 0x10,
  44. 'n': 0x08,
  45. 'p': 0x04,
  46. }
  47. characters = {
  48. 'A': 'afepkbc',
  49. 'B': 'adhmbck',
  50. 'C': 'afed',
  51. 'D': 'adhmbc',
  52. 'E': 'afedkp',
  53. 'F': 'afepk',
  54. 'G': 'afedck',
  55. 'H': 'febcpk',
  56. 'I': 'adhm',
  57. 'J': 'bcde',
  58. 'K': 'efpjl',
  59. 'L': 'def',
  60. 'M': 'efgjbc',
  61. 'N': 'efglcb',
  62. 'O': 'abcdef',
  63. 'P': 'abpkef',
  64. 'Q': 'abcdefl',
  65. 'R': 'abpkefl',
  66. 'S': 'afpkcd',
  67. 'T': 'ahm',
  68. 'U': 'bcdef',
  69. 'V': 'fenj',
  70. 'W': 'fenlcb',
  71. 'X': 'gjln',
  72. 'Y': 'gjm',
  73. 'Z': 'ajnd',
  74. 'a': 'abpkecd',
  75. 'b': 'fedlp',
  76. 'c': 'pked',
  77. 'd': 'bcdnk',
  78. 'e': 'afped',
  79. 'f': 'afpe',
  80. 'g': 'agkbcd',
  81. 'h': 'fpkec',
  82. 'i': 'mpkd',
  83. 'j': 'kcd',
  84. 'k': 'hmjl',
  85. 'l': 'hm',
  86. 'm': 'epkmc',
  87. 'n': 'mkc',
  88. 'o': 'pkecd',
  89. 'p': 'afpje',
  90. 'q': 'afpkbl',
  91. 'r': 'mk',
  92. 's': 'agkcd',
  93. 't': 'fedp',
  94. 'u': 'edc',
  95. 'v': 'en',
  96. 'w': 'enlc',
  97. 'x': 'gnjl',
  98. 'y': 'gkbcd',
  99. 'z': 'pnd',
  100. '0': 'abcdef',
  101. '1': 'bc',
  102. '2': 'abpked',
  103. '3': 'abcdkp',
  104. '4': 'fpkbc',
  105. '5': 'afpkcd',
  106. '6': 'afpkcde',
  107. '7': 'abc',
  108. '8': 'abcdefpk',
  109. '9': 'abcpkfd',
  110. '!': 'hm',
  111. '"': 'fh',
  112. '#': 'pkdhmbc',
  113. '$': 'afpkcdhm',
  114. '%': 'jnfc',
  115. '&': 'aghpeld',
  116. '\'': 'h',
  117. '(': 'afed',
  118. ')': 'abcd',
  119. '*': 'ghjmnlpk',
  120. '+': 'hmpk',
  121. ',': 'n',
  122. '-': 'pk',
  123. '.': 'm',
  124. '/': 'jn',
  125. ':': 'hm',
  126. ';': 'hn',
  127. '<': 'jl',
  128. '>': 'gn',
  129. '?': 'fajm',
  130. '=': 'pkd',
  131. '@': 'kmcbafed',
  132. '[': 'afed',
  133. ']': 'abcd',
  134. '\\': 'gl',
  135. '^': 'nl',
  136. '_': 'd',
  137. '`': 'g',
  138. '{': 'pgnad',
  139. '|': 'hm',
  140. '}': 'ajldk',
  141. '~': 'pk',
  142. # LRDU
  143. '\x80': 'jlbc',
  144. '\x81': 'efgn',
  145. '\x82': 'agj',
  146. '\x83': 'dnl',
  147. # LRDU arrow
  148. '\x84': 'jkl',
  149. '\x85': 'gpn',
  150. '\x86': 'ghj',
  151. '\x87': 'nml',
  152. # Waveforms
  153. '\x88': 'njbc', # Saw
  154. '\x89': 'enjb', # Centered saw
  155. '\x8A': 'mn', # Baby saw
  156. '\x8B': 'nl', # Tri
  157. '\x8C': 'efabc', # Square
  158. '\x8D': 'epkc', # Baby square
  159. '\x8E': 'dhm', # Pulse
  160. '\x8F': 'efgkc', # ADSR
  161. # Spinner
  162. '\x90': 'abcdefn',
  163. '\x91': 'abcdefp',
  164. '\x92': 'abcdefg',
  165. '\x93': 'abcdefh',
  166. '\x94': 'abcdefj',
  167. '\x95': 'abcdefk',
  168. '\x96': 'abcdefl',
  169. '\x97': 'abcdefm',
  170. # Spinner 2
  171. '\x98': 'ab',
  172. '\x99': 'abc',
  173. '\x9A': 'bcd',
  174. '\x9B': 'cde',
  175. '\x9C': 'de',
  176. '\x9D': 'def',
  177. '\x9E': 'efa',
  178. '\x9F': 'fab',
  179. '\xA0': 'abcdefghjklmnp',
  180. '\xFF': 'abcdefghjklmnp',
  181. 'null': 'null'
  182. }
  183. character_table = []
  184. for i in xrange(256):
  185. segments = characters.get(chr(i), '')
  186. character_table.append(sum(MASKS[segment] for segment in segments))
  187. characters = [('characters', character_table)]