Advertisement
jacksonliam

8x8x8 LED Cube Patterns Arduino

Mar 16th, 2012
12,802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 47.20 KB | None | 0 0
  1. /***************************************************************************************
  2.  * Name    : LED CUBE 8x8x8 74HC595
  3.  * By      : Liam Jackson
  4.  
  5.  Based on code by Joseph Francis (74hc595 SPI)
  6.  and by chr at instructables
  7.  http://www.instructables.com/id/Led-Cube-8x8x8/step70/Run-the-cube-on-an-Arduino/
  8.  Font found somewhere
  9. ****************************************************************************************/
  10.  
  11. #include <TimerOne.h>
  12. #include <string.h>
  13. #define AXIS_X 1
  14. #define AXIS_Y 2
  15. #define AXIS_Z 3
  16.  
  17. //--- Pin connected to ST_CP of 74HC595
  18. int latchPin = 10;
  19. //--- Pin connected to SH_CP of 74HC595
  20. int clockPin = 13;
  21. //--- Pin connected to DS of 74HC595
  22. int dataPin = 11;
  23. //--- Used for faster latching
  24. int latchPinPORTB = latchPin - 8;
  25. //holds value for all the pins, [x][y][z]
  26. byte cube[8][8];
  27.  
  28. //Counts through the layers
  29. int current_layer = 0;
  30.  
  31. //--- This process is run by the timer and does the PWM control
  32. void iProcess(){
  33.   //last layer store
  34.   int oldLayerBit = current_layer + 2;
  35.    
  36.   //increment layer count
  37.   current_layer++;
  38.   if(current_layer >= 8){
  39.     current_layer = 0;
  40.   }
  41.  
  42.   //--- Run through all the shift register values and send them (last one first)
  43.   // latching in the process
  44.   latchOff();
  45.   for (int i = 0 ; i < 8 ; i++){
  46.     spi_transfer(cube[current_layer][i]);
  47.   }
  48.  
  49.   //Hide the old layer
  50.   digitalWrite(oldLayerBit, LOW);
  51.   //New data on the pins
  52.   latchOn();
  53.   //new layer high
  54.   digitalWrite(current_layer + 2, HIGH);
  55. }
  56.  
  57. //--- Direct port access latching
  58. void latchOn(){
  59.   bitSet(PORTB,latchPinPORTB);
  60. }
  61. void latchOff(){
  62.   bitClear(PORTB,latchPinPORTB);
  63. }
  64.  
  65. //--- Used to setup SPI based on current pin setup
  66. //    this is called in the setup routine;
  67. void setupSPI(){
  68.   byte clr;
  69.   SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master
  70.   SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits
  71.   clr=SPSR; // clear SPI status reg
  72.   clr=SPDR; // clear SPI data reg
  73.   SPSR |= (1<<SPI2X); // set prescaler bits
  74.   delay(10);
  75. }
  76.  
  77. //--- The really fast SPI version of shiftOut
  78. byte spi_transfer(byte data)
  79. {
  80.   SPDR = data;            // Start the transmission
  81.   loop_until_bit_is_set(SPSR, SPIF);
  82.   return SPDR;            // return the received byte, we don't need that
  83. }
  84.  
  85. void setup() {
  86.   Serial.begin(9600);
  87.  
  88.   //layer pins
  89.   for(int i = 2; i < 10; i++)
  90.   {
  91.     pinMode(i, OUTPUT);
  92.   }
  93.  
  94.   pinMode(latchPin, OUTPUT);
  95.   pinMode(clockPin, OUTPUT);
  96.   pinMode(dataPin, OUTPUT);
  97.  
  98.   digitalWrite(latchPin,LOW);
  99.   digitalWrite(dataPin,LOW);
  100.   digitalWrite(clockPin,LOW);
  101.  
  102.   //--- Setup to run SPI
  103.   setupSPI();
  104.  
  105.   //--- Activate the PWM timer
  106.   Timer1.initialize(100); // Timer for updating pwm pins
  107.   Timer1.attachInterrupt(iProcess);
  108. }
  109.  
  110.  
  111. void loop(){
  112.   int i,x,y,z;
  113.  
  114.   while (true)
  115.   {
  116.     effect_text(800);
  117.    
  118.     effect_box_wamp(1000);
  119.      
  120.     effect_rain(100);
  121.    
  122.     effect_planboing(AXIS_Z, 400);
  123.     effect_planboing(AXIS_Y, 400);
  124.     effect_planboing(AXIS_X, 400);
  125.    
  126.     effect_blinky2();
  127.    
  128.     effect_random_filler(75,1);
  129.     effect_random_filler(75,0);
  130.    
  131.     effect_boxside_randsend_parallel (AXIS_X, 0, 150, 1);
  132.     effect_boxside_randsend_parallel (AXIS_X, 1, 150, 1);
  133.     effect_boxside_randsend_parallel (AXIS_Y, 0, 150, 1);
  134.     effect_boxside_randsend_parallel (AXIS_Y, 1, 150, 1);
  135.     effect_boxside_randsend_parallel (AXIS_Z, 0, 150, 1);
  136.     effect_boxside_randsend_parallel (AXIS_Z, 1, 150, 1);
  137.    
  138.   }
  139. }
  140.  
  141. // ==========================================================================================
  142. //   TEXT Functions
  143. // ==========================================================================================
  144. char font_data[128][8] = {
  145. { 0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00 },    // 0 :
  146.         //      |          |
  147.         //      |          |
  148.         //      |          |
  149.         //      |          |
  150.         //      |          |
  151.         //      |          |
  152.         //      |          |
  153.         //      |          |
  154.  
  155.   { 0x00,  0x3E,  0x41,  0x55,  0x41,  0x55,  0x49,  0x3E },    // 1 : 
  156.         //      |          |
  157.         //      |   *****  |
  158.         //      |  *     * |
  159.         //      |  * * * * |
  160.         //      |  *     * |
  161.         //      |  * * * * |
  162.         //      |  *  *  * |
  163.         //      |   *****  |
  164.  
  165.   { 0x00,  0x3E,  0x7F,  0x6B,  0x7F,  0x6B,  0x77,  0x3E },    // 2 : 
  166.         //      |          |
  167.         //      |   *****  |
  168.         //      |  ******* |
  169.         //      |  ** * ** |
  170.         //      |  ******* |
  171.         //      |  ** * ** |
  172.         //      |  *** *** |
  173.         //      |   *****  |
  174.  
  175.   { 0x00,  0x22,  0x77,  0x7F,  0x7F,  0x3E,  0x1C,  0x08 },    // 3 : 
  176.         //      |          |
  177.         //      |   *   *  |
  178.         //      |  *** *** |
  179.         //      |  ******* |
  180.         //      |  ******* |
  181.         //      |   *****  |
  182.         //      |    ***   |
  183.         //      |     *    |
  184.  
  185.   { 0x00,  0x08,  0x1C,  0x3E,  0x7F,  0x3E,  0x1C,  0x08 },    // 4 : 
  186.         //      |          |
  187.         //      |     *    |
  188.         //      |    ***   |
  189.         //      |   *****  |
  190.         //      |  ******* |
  191.         //      |   *****  |
  192.         //      |    ***   |
  193.         //      |     *    |
  194.  
  195.   { 0x00,  0x08,  0x1C,  0x2A,  0x7F,  0x2A,  0x08,  0x1C },    // 5 : 
  196.         //      |          |
  197.         //      |     *    |
  198.         //      |    ***   |
  199.         //      |   * * *  |
  200.         //      |  ******* |
  201.         //      |   * * *  |
  202.         //      |     *    |
  203.         //      |    ***   |
  204.  
  205.   { 0x00,  0x08,  0x1C,  0x3E,  0x7F,  0x3E,  0x08,  0x1C },    // 6 : 
  206.         //      |          |
  207.         //      |     *    |
  208.         //      |    ***   |
  209.         //      |   *****  |
  210.         //      |  ******* |
  211.         //      |   *****  |
  212.         //      |     *    |
  213.         //      |    ***   |
  214.  
  215.   { 0x00,  0x00,  0x1C,  0x3E,  0x3E,  0x3E,  0x1C,  0x00 },    // 7 : 
  216.         //      |          |
  217.         //      |          |
  218.         //      |    ***   |
  219.         //      |   *****  |
  220.         //      |   *****  |
  221.         //      |   *****  |
  222.         //      |    ***   |
  223.         //      |          |
  224.  
  225.   { 0xFF,  0xFF,  0xE3,  0xC1,  0xC1,  0xC1,  0xE3,  0xFF },    // 8 : 
  226.         //      | ******** |
  227.         //      | ******** |
  228.         //      | ***   ** |
  229.         //      | **     * |
  230.         //      | **     * |
  231.         //      | **     * |
  232.         //      | ***   ** |
  233.         //      | ******** |
  234.  
  235.   { 0x00,  0x00,  0x1C,  0x22,  0x22,  0x22,  0x1C,  0x00 },    // 9 :  
  236.         //      |          |
  237.         //      |          |
  238.         //      |    ***   |
  239.         //      |   *   *  |
  240.         //      |   *   *  |
  241.         //      |   *   *  |
  242.         //      |    ***   |
  243.         //      |          |
  244.  
  245.   { 0xFF,  0xFF,  0xE3,  0xDD,  0xDD,  0xDD,  0xE3,  0xFF },    // 10 :
  246.  
  247.         //      | ******** |
  248.         //      | ******** |
  249.         //      | ***   ** |
  250.         //      | ** *** * |
  251.         //      | ** *** * |
  252.         //      | ** *** * |
  253.         //      | ***   ** |
  254.         //      | ******** |
  255.  
  256.   { 0x00,  0x0F,  0x03,  0x05,  0x39,  0x48,  0x48,  0x30 },    // 11 :
  257.         //      |          |
  258.         //      |     **** |
  259.         //      |       ** |
  260.         //      |      * * |
  261.         //      |   ***  * |
  262.         //      |  *  *    |
  263.         //      |  *  *    |
  264.         //      |   **     |
  265.  
  266.   { 0x00,  0x08,  0x3E,  0x08,  0x1C,  0x22,  0x22,  0x1C },    // 12 :
  267.         //      |          |
  268.         //      |     *    |
  269.         //      |   *****  |
  270.         //      |     *    |
  271.         //      |    ***   |
  272.         //      |   *   *  |
  273.         //      |   *   *  |
  274.         //      |    ***   |
  275.  
  276.   { 0x00,  0x18,  0x14,  0x10,  0x10,  0x30,  0x70,  0x60 },    // 13 :
  277.  
  278.         //      |          |
  279.         //      |    **    |
  280.         //      |    * *   |
  281.         //      |    *     |
  282.         //      |    *     |
  283.         //      |   **     |
  284.         //      |  ***     |
  285.         //      |  **      |
  286.  
  287.   { 0x00,  0x0F,  0x19,  0x11,  0x13,  0x37,  0x76,  0x60 },    // 14 : 
  288.         //      |          |
  289.         //      |     **** |
  290.         //      |    **  * |
  291.         //      |    *   * |
  292.         //      |    *  ** |
  293.         //      |   ** *** |
  294.         //      |  *** **  |
  295.         //      |  **      |
  296.  
  297.   { 0x00,  0x08,  0x2A,  0x1C,  0x77,  0x1C,  0x2A,  0x08 },    // 15 : 
  298.         //      |          |
  299.         //      |     *    |
  300.         //      |   * * *  |
  301.         //      |    ***   |
  302.         //      |  *** *** |
  303.         //      |    ***   |
  304.         //      |   * * *  |
  305.         //      |     *    |
  306.  
  307.   { 0x00,  0x60,  0x78,  0x7E,  0x7F,  0x7E,  0x78,  0x60 },    // 16 : 
  308.         //      |          |
  309.         //      |  **      |
  310.         //      |  ****    |
  311.         //      |  ******  |
  312.         //      |  ******* |
  313.         //      |  ******  |
  314.         //      |  ****    |
  315.         //      |  **      |
  316.  
  317.   { 0x00,  0x03,  0x0F,  0x3F,  0x7F,  0x3F,  0x0F,  0x03 },    // 17 : 
  318.         //      |          |
  319.         //      |       ** |
  320.         //      |     **** |
  321.         //      |   ****** |
  322.         //      |  ******* |
  323.         //      |   ****** |
  324.         //      |     **** |
  325.         //      |       ** |
  326.  
  327.   { 0x00,  0x08,  0x1C,  0x2A,  0x08,  0x2A,  0x1C,  0x08 },    // 18 : 
  328.         //      |          |
  329.         //      |     *    |
  330.         //      |    ***   |
  331.         //      |   * * *  |
  332.         //      |     *    |
  333.         //      |   * * *  |
  334.         //      |    ***   |
  335.         //      |     *    |
  336.  
  337.   { 0x00,  0x66,  0x66,  0x66,  0x66,  0x00,  0x66,  0x66 },    // 19 : 
  338.         //      |          |
  339.         //      |  **  **  |
  340.         //      |  **  **  |
  341.         //      |  **  **  |
  342.         //      |  **  **  |
  343.         //      |          |
  344.         //      |  **  **  |
  345.         //      |  **  **  |
  346.  
  347.   { 0x00,  0x3F,  0x65,  0x65,  0x3D,  0x05,  0x05,  0x05 },    // 20 : 
  348.         //      |          |
  349.         //      |   ****** |
  350.         //      |  **  * * |
  351.         //      |  **  * * |
  352.         //      |   **** * |
  353.         //      |      * * |
  354.         //      |      * * |
  355.         //      |      * * |
  356.  
  357.   { 0x00,  0x0C,  0x32,  0x48,  0x24,  0x12,  0x4C,  0x30 },    // 21 : 
  358.         //      |          |
  359.         //      |     **   |
  360.         //      |   **  *  |
  361.         //      |  *  *    |
  362.         //      |   *  *   |
  363.         //      |    *  *  |
  364.         //      |  *  **   |
  365.         //      |   **     |
  366.  
  367.   { 0x00,  0x00,  0x00,  0x00,  0x00,  0x7F,  0x7F,  0x7F },    // 22 : 
  368.         //      |          |
  369.         //      |          |
  370.         //      |          |
  371.         //      |          |
  372.         //      |          |
  373.         //      |  ******* |
  374.         //      |  ******* |
  375.         //      |  ******* |
  376.  
  377.   { 0x00,  0x08,  0x1C,  0x2A,  0x08,  0x2A,  0x1C,  0x3E },    // 23 : 
  378.         //      |          |
  379.         //      |     *    |
  380.         //      |    ***   |
  381.         //      |   * * *  |
  382.         //      |     *    |
  383.         //      |   * * *  |
  384.         //      |    ***   |
  385.         //      |   *****  |
  386.  
  387.   { 0x00,  0x08,  0x1C,  0x3E,  0x7F,  0x1C,  0x1C,  0x1C },    // 24 : 
  388.         //      |          |
  389.         //      |     *    |
  390.         //      |    ***   |
  391.         //      |   *****  |
  392.         //      |  ******* |
  393.         //      |    ***   |
  394.         //      |    ***   |
  395.         //      |    ***   |
  396.  
  397.   { 0x00,  0x1C,  0x1C,  0x1C,  0x7F,  0x3E,  0x1C,  0x08 },    // 25 : 
  398.         //      |          |
  399.         //      |    ***   |
  400.         //      |    ***   |
  401.         //      |    ***   |
  402.         //      |  ******* |
  403.         //      |   *****  |
  404.         //      |    ***   |
  405.         //      |     *    |
  406.  
  407.   { 0x00,  0x08,  0x0C,  0x7E,  0x7F,  0x7E,  0x0C,  0x08 },    // 26 : 
  408.         //      |          |
  409.         //      |     *    |
  410.         //      |     **   |
  411.         //      |  ******  |
  412.         //      |  ******* |
  413.         //      |  ******  |
  414.         //      |     **   |
  415.         //      |     *    |
  416.  
  417.   { 0x00,  0x08,  0x18,  0x3F,  0x7F,  0x3F,  0x18,  0x08 },    // 27 : 
  418.         //      |          |
  419.         //      |     *    |
  420.         //      |    **    |
  421.         //      |   ****** |
  422.         //      |  ******* |
  423.         //      |   ****** |
  424.         //      |    **    |
  425.         //      |     *    |
  426.  
  427.   { 0x00,  0x00,  0x00,  0x70,  0x70,  0x70,  0x7F,  0x7F },    // 28 : 
  428.         //      |          |
  429.         //      |          |
  430.         //      |          |
  431.         //      |  ***     |
  432.         //      |  ***     |
  433.         //      |  ***     |
  434.         //      |  ******* |
  435.         //      |  ******* |
  436.  
  437.   { 0x00,  0x00,  0x14,  0x22,  0x7F,  0x22,  0x14,  0x00 },    // 29 : 
  438.         //      |          |
  439.         //      |          |
  440.         //      |    * *   |
  441.         //      |   *   *  |
  442.         //      |  ******* |
  443.         //      |   *   *  |
  444.         //      |    * *   |
  445.         //      |          |
  446.  
  447.   { 0x00,  0x08,  0x1C,  0x1C,  0x3E,  0x3E,  0x7F,  0x7F },    // 30 : 
  448.         //      |          |
  449.         //      |     *    |
  450.         //      |    ***   |
  451.         //      |    ***   |
  452.         //      |   *****  |
  453.         //      |   *****  |
  454.         //      |  ******* |
  455.         //      |  ******* |
  456.  
  457.   { 0x00,  0x7F,  0x7F,  0x3E,  0x3E,  0x1C,  0x1C,  0x08 },    // 31 : 
  458.         //      |          |
  459.         //      |  ******* |
  460.         //      |  ******* |
  461.         //      |   *****  |
  462.         //      |   *****  |
  463.         //      |    ***   |
  464.         //      |    ***   |
  465.         //      |     *    |
  466.  
  467.   { 0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00 },    // 32 :  
  468.         //      |          |
  469.         //      |          |
  470.         //      |          |
  471.         //      |          |
  472.         //      |          |
  473.         //      |          |
  474.         //      |          |
  475.         //      |          |
  476.  
  477.   { 0x00,  0x18,  0x18,  0x18,  0x18,  0x18,  0x00,  0x18 },    // 33 : !
  478.         //      |          |
  479.         //      |    **    |
  480.         //      |    **    |
  481.         //      |    **    |
  482.         //      |    **    |
  483.         //      |    **    |
  484.         //      |          |
  485.         //      |    **    |
  486.  
  487.   { 0x00,  0x36,  0x36,  0x14,  0x00,  0x00,  0x00,  0x00 },    // 34 : "
  488.         //      |          |
  489.         //      |   ** **  |
  490.         //      |   ** **  |
  491.         //      |    * *   |
  492.         //      |          |
  493.         //      |          |
  494.         //      |          |
  495.         //      |          |
  496.  
  497.   { 0x00,  0x36,  0x36,  0x7F,  0x36,  0x7F,  0x36,  0x36 },    // 35 : #
  498.         //      |          |
  499.         //      |   ** **  |
  500.         //      |   ** **  |
  501.         //      |  ******* |
  502.         //      |   ** **  |
  503.         //      |  ******* |
  504.         //      |   ** **  |
  505.         //      |   ** **  |
  506.  
  507.   { 0x00,  0x08,  0x1E,  0x20,  0x1C,  0x02,  0x3C,  0x08 },    // 36 : $
  508.         //      |          |
  509.         //      |     *    |
  510.         //      |    ****  |
  511.         //      |   *      |
  512.         //      |    ***   |
  513.         //      |       *  |
  514.         //      |   ****   |
  515.         //      |     *    |
  516.  
  517.   { 0x00,  0x60,  0x66,  0x0C,  0x18,  0x30,  0x66,  0x06 },    // 37 : %
  518.         //      |          |
  519.         //      |  **      |
  520.         //      |  **  **  |
  521.         //      |     **   |
  522.         //      |    **    |
  523.         //      |   **     |
  524.         //      |  **  **  |
  525.         //      |      **  |
  526.  
  527.   { 0x00,  0x3C,  0x66,  0x3C,  0x28,  0x65,  0x66,  0x3F },    // 38 : &
  528.         //      |          |
  529.         //      |   ****   |
  530.         //      |  **  **  |
  531.         //      |   ****   |
  532.         //      |   * *    |
  533.         //      |  **  * * |
  534.         //      |  **  **  |
  535.         //      |   ****** |
  536.  
  537.   { 0x00,  0x18,  0x18,  0x18,  0x30,  0x00,  0x00,  0x00 },    // 39 : '
  538.         //      |          |
  539.         //      |    **    |
  540.         //      |    **    |
  541.         //      |    **    |
  542.         //      |   **     |
  543.         //      |          |
  544.         //      |          |
  545.         //      |          |
  546.  
  547.   { 0x00,  0x60,  0x30,  0x18,  0x18,  0x18,  0x30,  0x60 },    // 40 : (
  548.         //      |          |
  549.         //      |  **      |
  550.         //      |   **     |
  551.         //      |    **    |
  552.         //      |    **    |
  553.         //      |    **    |
  554.         //      |   **     |
  555.         //      |  **      |
  556.  
  557.   { 0x00,  0x06,  0x0C,  0x18,  0x18,  0x18,  0x0C,  0x06 },    // 41 : )
  558.         //      |          |
  559.         //      |      **  |
  560.         //      |     **   |
  561.         //      |    **    |
  562.         //      |    **    |
  563.         //      |    **    |
  564.         //      |     **   |
  565.         //      |      **  |
  566.  
  567.   { 0x00,  0x00,  0x36,  0x1C,  0x7F,  0x1C,  0x36,  0x00 },    // 42 : *
  568.         //      |          |
  569.         //      |          |
  570.         //      |   ** **  |
  571.         //      |    ***   |
  572.         //      |  ******* |
  573.         //      |    ***   |
  574.         //      |   ** **  |
  575.         //      |          |
  576.  
  577.   { 0x00,  0x00,  0x08,  0x08,  0x3E,  0x08,  0x08,  0x00 },    // 43 : +
  578.         //      |          |
  579.         //      |          |
  580.         //      |     *    |
  581.         //      |     *    |
  582.         //      |   *****  |
  583.         //      |     *    |
  584.         //      |     *    |
  585.         //      |          |
  586.  
  587.   { 0x00,  0x00,  0x00,  0x00,  0x30,  0x30,  0x30,  0x60 },    // 44 : ,
  588.         //      |          |
  589.         //      |          |
  590.         //      |          |
  591.         //      |          |
  592.         //      |   **     |
  593.         //      |   **     |
  594.         //      |   **     |
  595.         //      |  **      |
  596.  
  597.   { 0x00,  0x00,  0x00,  0x00,  0x3C,  0x00,  0x00,  0x00 },    // 45 : -
  598.         //      |          |
  599.         //      |          |
  600.         //      |          |
  601.         //      |          |
  602.         //      |   ****   |
  603.         //      |          |
  604.         //      |          |
  605.         //      |          |
  606.  
  607.   { 0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x60,  0x60 },    // 46 : .
  608.         //      |          |
  609.         //      |          |
  610.         //      |          |
  611.         //      |          |
  612.         //      |          |
  613.         //      |          |
  614.         //      |  **      |
  615.         //      |  **      |
  616.  
  617.   { 0x00,  0x00,  0x06,  0x0C,  0x18,  0x30,  0x60,  0x00 },    // 47 : /
  618.         //      |          |
  619.         //      |          |
  620.         //      |      **  |
  621.         //      |     **   |
  622.         //      |    **    |
  623.         //      |   **     |
  624.         //      |  **      |
  625.         //      |          |
  626.  
  627.   { 0x00,  0x3C,  0x66,  0x6E,  0x76,  0x66,  0x66,  0x3C },    // 48 : 0
  628.         //      |          |
  629.         //      |   ****   |
  630.         //      |  **  **  |
  631.         //      |  ** ***  |
  632.         //      |  *** **  |
  633.         //      |  **  **  |
  634.         //      |  **  **  |
  635.         //      |   ****   |
  636.  
  637.   { 0x00,  0x18,  0x18,  0x38,  0x18,  0x18,  0x18,  0x7E },    // 49 : 1
  638.         //      |          |
  639.         //      |    **    |
  640.         //      |    **    |
  641.         //      |   ***    |
  642.         //      |    **    |
  643.         //      |    **    |
  644.         //      |    **    |
  645.         //      |  ******  |
  646.  
  647.   { 0x00,  0x3C,  0x66,  0x06,  0x0C,  0x30,  0x60,  0x7E },    // 50 : 2
  648.         //      |          |
  649.         //      |   ****   |
  650.         //      |  **  **  |
  651.         //      |      **  |
  652.         //      |     **   |
  653.         //      |   **     |
  654.         //      |  **      |
  655.         //      |  ******  |
  656.  
  657.   { 0x00,  0x3C,  0x66,  0x06,  0x1C,  0x06,  0x66,  0x3C },    // 51 : 3
  658.         //      |          |
  659.         //      |   ****   |
  660.         //      |  **  **  |
  661.         //      |      **  |
  662.         //      |    ***   |
  663.         //      |      **  |
  664.         //      |  **  **  |
  665.         //      |   ****   |
  666.  
  667.   { 0x00,  0x0C,  0x1C,  0x2C,  0x4C,  0x7E,  0x0C,  0x0C },    // 52 : 4
  668.         //      |          |
  669.         //      |     **   |
  670.         //      |    ***   |
  671.         //      |   * **   |
  672.         //      |  *  **   |
  673.         //      |  ******  |
  674.         //      |     **   |
  675.         //      |     **   |
  676.  
  677.   { 0x00,  0x7E,  0x60,  0x7C,  0x06,  0x06,  0x66,  0x3C },    // 53 : 5
  678.         //      |          |
  679.         //      |  ******  |
  680.         //      |  **      |
  681.         //      |  *****   |
  682.         //      |      **  |
  683.         //      |      **  |
  684.         //      |  **  **  |
  685.         //      |   ****   |
  686.  
  687.   { 0x00,  0x3C,  0x66,  0x60,  0x7C,  0x66,  0x66,  0x3C },    // 54 : 6
  688.         //      |          |
  689.         //      |   ****   |
  690.         //      |  **  **  |
  691.         //      |  **      |
  692.         //      |  *****   |
  693.         //      |  **  **  |
  694.         //      |  **  **  |
  695.         //      |   ****   |
  696.  
  697.   { 0x00,  0x7E,  0x66,  0x0C,  0x0C,  0x18,  0x18,  0x18 },    // 55 : 7
  698.         //      |          |
  699.         //      |  ******  |
  700.         //      |  **  **  |
  701.         //      |     **   |
  702.         //      |     **   |
  703.         //      |    **    |
  704.         //      |    **    |
  705.         //      |    **    |
  706.  
  707.   { 0x00,  0x3C,  0x66,  0x66,  0x3C,  0x66,  0x66,  0x3C },    // 56 : 8
  708.         //      |          |
  709.         //      |   ****   |
  710.         //      |  **  **  |
  711.         //      |  **  **  |
  712.         //      |   ****   |
  713.         //      |  **  **  |
  714.         //      |  **  **  |
  715.         //      |   ****   |
  716.  
  717.   { 0x00,  0x3C,  0x66,  0x66,  0x3E,  0x06,  0x66,  0x3C },    // 57 : 9
  718.         //      |          |
  719.         //      |   ****   |
  720.         //      |  **  **  |
  721.         //      |  **  **  |
  722.         //      |   *****  |
  723.         //      |      **  |
  724.         //      |  **  **  |
  725.         //      |   ****   |
  726.  
  727.   { 0x00,  0x00,  0x18,  0x18,  0x00,  0x18,  0x18,  0x00 },    // 58 : :
  728.         //      |          |
  729.         //      |          |
  730.         //      |    **    |
  731.         //      |    **    |
  732.         //      |          |
  733.         //      |    **    |
  734.         //      |    **    |
  735.         //      |          |
  736.  
  737.   { 0x00,  0x00,  0x18,  0x18,  0x00,  0x18,  0x18,  0x30 },    // 59 : ;
  738.         //      |          |
  739.         //      |          |
  740.         //      |    **    |
  741.         //      |    **    |
  742.         //      |          |
  743.         //      |    **    |
  744.         //      |    **    |
  745.         //      |   **     |
  746.  
  747.   { 0x00,  0x06,  0x0C,  0x18,  0x30,  0x18,  0x0C,  0x06 },    // 60 : <
  748.         //      |          |
  749.         //      |      **  |
  750.         //      |     **   |
  751.         //      |    **    |
  752.         //      |   **     |
  753.         //      |    **    |
  754.         //      |     **   |
  755.         //      |      **  |
  756.  
  757.   { 0x00,  0x00,  0x00,  0x3C,  0x00,  0x3C,  0x00,  0x00 },    // 61 : =
  758.         //      |          |
  759.         //      |          |
  760.         //      |          |
  761.         //      |   ****   |
  762.         //      |          |
  763.         //      |   ****   |
  764.         //      |          |
  765.         //      |          |
  766.  
  767.   { 0x00,  0x60,  0x30,  0x18,  0x0C,  0x18,  0x30,  0x60 },    // 62 : >
  768.         //      |          |
  769.         //      |  **      |
  770.         //      |   **     |
  771.         //      |    **    |
  772.         //      |     **   |
  773.         //      |    **    |
  774.         //      |   **     |
  775.         //      |  **      |
  776.  
  777.   { 0x00,  0x3C,  0x66,  0x06,  0x1C,  0x18,  0x00,  0x18 },    // 63 : ?
  778.         //      |          |
  779.         //      |   ****   |
  780.         //      |  **  **  |
  781.         //      |      **  |
  782.         //      |    ***   |
  783.         //      |    **    |
  784.         //      |          |
  785.         //      |    **    |
  786.  
  787.   { 0x00,  0x38,  0x44,  0x5C,  0x58,  0x42,  0x3C,  0x00 },    // 64 : @
  788.         //      |          |
  789.         //      |   ***    |
  790.         //      |  *   *   |
  791.         //      |  * ***   |
  792.         //      |  * **    |
  793.         //      |  *    *  |
  794.         //      |   ****   |
  795.         //      |          |
  796.  
  797.   { 0x00,  0x3C,  0x66,  0x66,  0x7E,  0x66,  0x66,  0x66 },    // 65 : A
  798.         //      |          |
  799.         //      |   ****   |
  800.         //      |  **  **  |
  801.         //      |  **  **  |
  802.         //      |  ******  |
  803.         //      |  **  **  |
  804.         //      |  **  **  |
  805.         //      |  **  **  |
  806.  
  807.   { 0x00,  0x7C,  0x66,  0x66,  0x7C,  0x66,  0x66,  0x7C },    // 66 : B
  808.         //      |          |
  809.         //      |  *****   |
  810.         //      |  **  **  |
  811.         //      |  **  **  |
  812.         //      |  *****   |
  813.         //      |  **  **  |
  814.         //      |  **  **  |
  815.         //      |  *****   |
  816.  
  817.   { 0x00,  0x3C,  0x66,  0x60,  0x60,  0x60,  0x66,  0x3C },    // 67 : C
  818.         //      |          |
  819.         //      |   ****   |
  820.         //      |  **  **  |
  821.         //      |  **      |
  822.         //      |  **      |
  823.         //      |  **      |
  824.         //      |  **  **  |
  825.         //      |   ****   |
  826.  
  827.   { 0x00,  0x7C,  0x66,  0x66,  0x66,  0x66,  0x66,  0x7C },    // 68 : D
  828.         //      |          |
  829.         //      |  *****   |
  830.         //      |  **  **  |
  831.         //      |  **  **  |
  832.         //      |  **  **  |
  833.         //      |  **  **  |
  834.         //      |  **  **  |
  835.         //      |  *****   |
  836.  
  837.   { 0x00,  0x7E,  0x60,  0x60,  0x7C,  0x60,  0x60,  0x7E },    // 69 : E
  838.         //      |          |
  839.         //      |  ******  |
  840.         //      |  **      |
  841.         //      |  **      |
  842.         //      |  *****   |
  843.         //      |  **      |
  844.         //      |  **      |
  845.         //      |  ******  |
  846.  
  847.   { 0x00,  0x7E,  0x60,  0x60,  0x7C,  0x60,  0x60,  0x60 },    // 70 : F
  848.         //      |          |
  849.         //      |  ******  |
  850.         //      |  **      |
  851.         //      |  **      |
  852.         //      |  *****   |
  853.         //      |  **      |
  854.         //      |  **      |
  855.         //      |  **      |
  856.  
  857.   { 0x00,  0x3C,  0x66,  0x60,  0x60,  0x6E,  0x66,  0x3C },    // 71 : G
  858.         //      |          |
  859.         //      |   ****   |
  860.         //      |  **  **  |
  861.         //      |  **      |
  862.         //      |  **      |
  863.         //      |  ** ***  |
  864.         //      |  **  **  |
  865.         //      |   ****   |
  866.  
  867.   { 0x00,  0x66,  0x66,  0x66,  0x7E,  0x66,  0x66,  0x66 },    // 72 : H
  868.         //      |          |
  869.         //      |  **  **  |
  870.         //      |  **  **  |
  871.         //      |  **  **  |
  872.         //      |  ******  |
  873.         //      |  **  **  |
  874.         //      |  **  **  |
  875.         //      |  **  **  |
  876.  
  877.   { 0x00,  0x3C,  0x18,  0x18,  0x18,  0x18,  0x18,  0x3C },    // 73 : I
  878.         //      |          |
  879.         //      |   ****   |
  880.         //      |    **    |
  881.         //      |    **    |
  882.         //      |    **    |
  883.         //      |    **    |
  884.         //      |    **    |
  885.         //      |   ****   |
  886.  
  887.   { 0x00,  0x1E,  0x0C,  0x0C,  0x0C,  0x6C,  0x6C,  0x38 },    // 74 : J
  888.         //      |          |
  889.         //      |    ****  |
  890.         //      |     **   |
  891.         //      |     **   |
  892.         //      |     **   |
  893.         //      |  ** **   |
  894.         //      |  ** **   |
  895.         //      |   ***    |
  896.  
  897.   { 0x00,  0x66,  0x6C,  0x78,  0x70,  0x78,  0x6C,  0x66 },    // 75 : K
  898.         //      |          |
  899.         //      |  **  **  |
  900.         //      |  ** **   |
  901.         //      |  ****    |
  902.         //      |  ***     |
  903.         //      |  ****    |
  904.         //      |  ** **   |
  905.         //      |  **  **  |
  906.  
  907.   { 0x00,  0x60,  0x60,  0x60,  0x60,  0x60,  0x60,  0x7E },    // 76 : L
  908.         //      |          |
  909.         //      |  **      |
  910.         //      |  **      |
  911.         //      |  **      |
  912.         //      |  **      |
  913.         //      |  **      |
  914.         //      |  **      |
  915.         //      |  ******  |
  916.  
  917.   { 0x00,  0x63,  0x77,  0x7F,  0x6B,  0x63,  0x63,  0x63 },    // 77 : M
  918.         //      |          |
  919.         //      |  **   ** |
  920.         //      |  *** *** |
  921.         //      |  ******* |
  922.         //      |  ** * ** |
  923.         //      |  **   ** |
  924.         //      |  **   ** |
  925.         //      |  **   ** |
  926.  
  927.   { 0x00,  0x63,  0x73,  0x7B,  0x6F,  0x67,  0x63,  0x63 },    // 78 : N
  928.         //      |          |
  929.         //      |  **   ** |
  930.         //      |  ***  ** |
  931.         //      |  **** ** |
  932.         //      |  ** **** |
  933.         //      |  **  *** |
  934.         //      |  **   ** |
  935.         //      |  **   ** |
  936.  
  937.   { 0x00,  0x3C,  0x66,  0x66,  0x66,  0x66,  0x66,  0x3C },    // 79 : O
  938.         //      |          |
  939.         //      |   ****   |
  940.         //      |  **  **  |
  941.         //      |  **  **  |
  942.         //      |  **  **  |
  943.         //      |  **  **  |
  944.         //      |  **  **  |
  945.         //      |   ****   |
  946.  
  947.   { 0x00,  0x7C,  0x66,  0x66,  0x66,  0x7C,  0x60,  0x60 },    // 80 : P
  948.         //      |          |
  949.         //      |  *****   |
  950.         //      |  **  **  |
  951.         //      |  **  **  |
  952.         //      |  **  **  |
  953.         //      |  *****   |
  954.         //      |  **      |
  955.         //      |  **      |
  956.  
  957.   { 0x00,  0x3C,  0x66,  0x66,  0x66,  0x6E,  0x3C,  0x06 },    // 81 : Q
  958.         //      |          |
  959.         //      |   ****   |
  960.         //      |  **  **  |
  961.         //      |  **  **  |
  962.         //      |  **  **  |
  963.         //      |  ** ***  |
  964.         //      |   ****   |
  965.         //      |      **  |
  966.  
  967.   { 0x00,  0x7C,  0x66,  0x66,  0x7C,  0x78,  0x6C,  0x66 },    // 82 : R
  968.         //      |          |
  969.         //      |  *****   |
  970.         //      |  **  **  |
  971.         //      |  **  **  |
  972.         //      |  *****   |
  973.         //      |  ****    |
  974.         //      |  ** **   |
  975.         //      |  **  **  |
  976.  
  977.   { 0x00,  0x3C,  0x66,  0x60,  0x3C,  0x06,  0x66,  0x3C },    // 83 : S
  978.         //      |          |
  979.         //      |   ****   |
  980.         //      |  **  **  |
  981.         //      |  **      |
  982.         //      |   ****   |
  983.         //      |      **  |
  984.         //      |  **  **  |
  985.         //      |   ****   |
  986.  
  987.   { 0x00,  0x7E,  0x5A,  0x18,  0x18,  0x18,  0x18,  0x18 },    // 84 : T
  988.         //      |          |
  989.         //      |  ******  |
  990.         //      |  * ** *  |
  991.         //      |    **    |
  992.         //      |    **    |
  993.         //      |    **    |
  994.         //      |    **    |
  995.         //      |    **    |
  996.  
  997.   { 0x00,  0x66,  0x66,  0x66,  0x66,  0x66,  0x66,  0x3E },    // 85 : U
  998.         //      |          |
  999.         //      |  **  **  |
  1000.         //      |  **  **  |
  1001.         //      |  **  **  |
  1002.         //      |  **  **  |
  1003.         //      |  **  **  |
  1004.         //      |  **  **  |
  1005.         //      |   *****  |
  1006.  
  1007.   { 0x00,  0x66,  0x66,  0x66,  0x66,  0x66,  0x3C,  0x18 },    // 86 : V
  1008.         //      |          |
  1009.         //      |  **  **  |
  1010.         //      |  **  **  |
  1011.         //      |  **  **  |
  1012.         //      |  **  **  |
  1013.         //      |  **  **  |
  1014.         //      |   ****   |
  1015.         //      |    **    |
  1016.  
  1017.   { 0x00,  0x63,  0x63,  0x63,  0x6B,  0x7F,  0x77,  0x63 },    // 87 : W
  1018.         //      |          |
  1019.         //      |  **   ** |
  1020.         //      |  **   ** |
  1021.         //      |  **   ** |
  1022.         //      |  ** * ** |
  1023.         //      |  ******* |
  1024.         //      |  *** *** |
  1025.         //      |  **   ** |
  1026.  
  1027.   { 0x00,  0x63,  0x63,  0x36,  0x1C,  0x36,  0x63,  0x63 },    // 88 : X
  1028.         //      |          |
  1029.         //      |  **   ** |
  1030.         //      |  **   ** |
  1031.         //      |   ** **  |
  1032.         //      |    ***   |
  1033.         //      |   ** **  |
  1034.         //      |  **   ** |
  1035.         //      |  **   ** |
  1036.  
  1037.   { 0x00,  0x66,  0x66,  0x66,  0x3C,  0x18,  0x18,  0x18 },    // 89 : Y
  1038.         //      |          |
  1039.         //      |  **  **  |
  1040.         //      |  **  **  |
  1041.         //      |  **  **  |
  1042.         //      |   ****   |
  1043.         //      |    **    |
  1044.         //      |    **    |
  1045.         //      |    **    |
  1046.  
  1047.   { 0x00,  0x7E,  0x06,  0x0C,  0x18,  0x30,  0x60,  0x7E },    // 90 : Z
  1048.         //      |          |
  1049.         //      |  ******  |
  1050.         //      |      **  |
  1051.         //      |     **   |
  1052.         //      |    **    |
  1053.         //      |   **     |
  1054.         //      |  **      |
  1055.         //      |  ******  |
  1056.  
  1057.   { 0x00,  0x1E,  0x18,  0x18,  0x18,  0x18,  0x18,  0x1E },    // 91 : [
  1058.         //      |          |
  1059.         //      |    ****  |
  1060.         //      |    **    |
  1061.         //      |    **    |
  1062.         //      |    **    |
  1063.         //      |    **    |
  1064.         //      |    **    |
  1065.         //      |    ****  |
  1066.  
  1067.   { 0x00,  0x00,  0x60,  0x30,  0x18,  0x0C,  0x06,  0x00 },    // 92 : \
  1068.         //      |          |
  1069.         //      |          |
  1070.         //      |  **      |
  1071.         //      |   **     |
  1072.         //      |    **    |
  1073.         //      |     **   |
  1074.         //      |      **  |
  1075.         //      |          |
  1076.  
  1077.   { 0x00,  0x78,  0x18,  0x18,  0x18,  0x18,  0x18,  0x78 },    // 93 : ]
  1078.         //      |          |
  1079.         //      |  ****    |
  1080.         //      |    **    |
  1081.         //      |    **    |
  1082.         //      |    **    |
  1083.         //      |    **    |
  1084.         //      |    **    |
  1085.         //      |  ****    |
  1086.  
  1087.   { 0x00,  0x08,  0x14,  0x22,  0x41,  0x00,  0x00,  0x00 },    // 94 : ^
  1088.         //      |          |
  1089.         //      |     *    |
  1090.         //      |    * *   |
  1091.         //      |   *   *  |
  1092.         //      |  *     * |
  1093.         //      |          |
  1094.         //      |          |
  1095.         //      |          |
  1096.  
  1097.   { 0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x7F },    // 95 : _
  1098.         //      |          |
  1099.         //      |          |
  1100.         //      |          |
  1101.         //      |          |
  1102.         //      |          |
  1103.         //      |          |
  1104.         //      |          |
  1105.         //      |  ******* |
  1106.  
  1107.   { 0x00,  0x0C,  0x0C,  0x06,  0x00,  0x00,  0x00,  0x00 },    // 96 : `
  1108.         //      |          |
  1109.         //      |     **   |
  1110.         //      |     **   |
  1111.         //      |      **  |
  1112.         //      |          |
  1113.         //      |          |
  1114.         //      |          |
  1115.         //      |          |
  1116.  
  1117.   { 0x00,  0x00,  0x00,  0x3C,  0x06,  0x3E,  0x66,  0x3E },    // 97 : a
  1118.         //      |          |
  1119.         //      |          |
  1120.         //      |          |
  1121.         //      |   ****   |
  1122.         //      |      **  |
  1123.         //      |   *****  |
  1124.         //      |  **  **  |
  1125.         //      |   *****  |
  1126.  
  1127.   { 0x00,  0x60,  0x60,  0x60,  0x7C,  0x66,  0x66,  0x7C },    // 98 : b
  1128.         //      |          |
  1129.         //      |  **      |
  1130.         //      |  **      |
  1131.         //      |  **      |
  1132.         //      |  *****   |
  1133.         //      |  **  **  |
  1134.         //      |  **  **  |
  1135.         //      |  *****   |
  1136.  
  1137.   { 0x00,  0x00,  0x00,  0x3C,  0x66,  0x60,  0x66,  0x3C },    // 99 : c
  1138.         //      |          |
  1139.         //      |          |
  1140.         //      |          |
  1141.         //      |   ****   |
  1142.         //      |  **  **  |
  1143.         //      |  **      |
  1144.         //      |  **  **  |
  1145.         //      |   ****   |
  1146.  
  1147.   { 0x00,  0x06,  0x06,  0x06,  0x3E,  0x66,  0x66,  0x3E },    // 100 : d
  1148.         //      |          |
  1149.         //      |      **  |
  1150.         //      |      **  |
  1151.         //      |      **  |
  1152.         //      |   *****  |
  1153.         //      |  **  **  |
  1154.         //      |  **  **  |
  1155.         //      |   *****  |
  1156.  
  1157.   { 0x00,  0x00,  0x00,  0x3C,  0x66,  0x7E,  0x60,  0x3C },    // 101 : e
  1158.         //      |          |
  1159.         //      |          |
  1160.         //      |          |
  1161.         //      |   ****   |
  1162.         //      |  **  **  |
  1163.         //      |  ******  |
  1164.         //      |  **      |
  1165.         //      |   ****   |
  1166.  
  1167.   { 0x00,  0x1C,  0x36,  0x30,  0x30,  0x7C,  0x30,  0x30 },    // 102 : f
  1168.         //      |          |
  1169.         //      |    ***   |
  1170.         //      |   ** **  |
  1171.         //      |   **     |
  1172.         //      |   **     |
  1173.         //      |  *****   |
  1174.         //      |   **     |
  1175.         //      |   **     |
  1176.  
  1177.   { 0x00,  0x00,  0x3E,  0x66,  0x66,  0x3E,  0x06,  0x3C },    // 103 : g
  1178.         //      |          |
  1179.         //      |          |
  1180.         //      |   *****  |
  1181.         //      |  **  **  |
  1182.         //      |  **  **  |
  1183.         //      |   *****  |
  1184.         //      |      **  |
  1185.         //      |   ****   |
  1186.  
  1187.   { 0x00,  0x60,  0x60,  0x60,  0x7C,  0x66,  0x66,  0x66 },    // 104 : h
  1188.         //      |          |
  1189.         //      |  **      |
  1190.         //      |  **      |
  1191.         //      |  **      |
  1192.         //      |  *****   |
  1193.         //      |  **  **  |
  1194.         //      |  **  **  |
  1195.         //      |  **  **  |
  1196.  
  1197.   { 0x00,  0x00,  0x18,  0x00,  0x18,  0x18,  0x18,  0x3C },    // 105 : i
  1198.         //      |          |
  1199.         //      |          |
  1200.         //      |    **    |
  1201.         //      |          |
  1202.         //      |    **    |
  1203.         //      |    **    |
  1204.         //      |    **    |
  1205.         //      |   ****   |
  1206.  
  1207.   { 0x00,  0x0C,  0x00,  0x0C,  0x0C,  0x6C,  0x6C,  0x38 },    // 106 : j
  1208.         //      |          |
  1209.         //      |     **   |
  1210.         //      |          |
  1211.         //      |     **   |
  1212.         //      |     **   |
  1213.         //      |  ** **   |
  1214.         //      |  ** **   |
  1215.         //      |   ***    |
  1216.  
  1217.   { 0x00,  0x60,  0x60,  0x66,  0x6C,  0x78,  0x6C,  0x66 },    // 107 : k
  1218.         //      |          |
  1219.         //      |  **      |
  1220.         //      |  **      |
  1221.         //      |  **  **  |
  1222.         //      |  ** **   |
  1223.         //      |  ****    |
  1224.         //      |  ** **   |
  1225.         //      |  **  **  |
  1226.  
  1227.   { 0x00,  0x18,  0x18,  0x18,  0x18,  0x18,  0x18,  0x18 },    // 108 : l
  1228.         //      |          |
  1229.         //      |    **    |
  1230.         //      |    **    |
  1231.         //      |    **    |
  1232.         //      |    **    |
  1233.         //      |    **    |
  1234.         //      |    **    |
  1235.         //      |    **    |
  1236.  
  1237.   { 0x00,  0x00,  0x00,  0x63,  0x77,  0x7F,  0x6B,  0x6B },    // 109 : m
  1238.         //      |          |
  1239.         //      |          |
  1240.         //      |          |
  1241.         //      |  **   ** |
  1242.         //      |  *** *** |
  1243.         //      |  ******* |
  1244.         //      |  ** * ** |
  1245.         //      |  ** * ** |
  1246.  
  1247.   { 0x00,  0x00,  0x00,  0x7C,  0x7E,  0x66,  0x66,  0x66 },    // 110 : n
  1248.         //      |          |
  1249.         //      |          |
  1250.         //      |          |
  1251.         //      |  *****   |
  1252.         //      |  ******  |
  1253.         //      |  **  **  |
  1254.         //      |  **  **  |
  1255.         //      |  **  **  |
  1256.  
  1257.   { 0x00,  0x00,  0x00,  0x3C,  0x66,  0x66,  0x66,  0x3C },    // 111 : o
  1258.         //      |          |
  1259.         //      |          |
  1260.         //      |          |
  1261.         //      |   ****   |
  1262.         //      |  **  **  |
  1263.         //      |  **  **  |
  1264.         //      |  **  **  |
  1265.         //      |   ****   |
  1266.  
  1267.   { 0x00,  0x00,  0x7C,  0x66,  0x66,  0x7C,  0x60,  0x60 },    // 112 : p
  1268.         //      |          |
  1269.         //      |          |
  1270.         //      |  *****   |
  1271.         //      |  **  **  |
  1272.         //      |  **  **  |
  1273.         //      |  *****   |
  1274.         //      |  **      |
  1275.         //      |  **      |
  1276.  
  1277.   { 0x00,  0x00,  0x3C,  0x6C,  0x6C,  0x3C,  0x0D,  0x0F },    // 113 : q
  1278.         //      |          |
  1279.         //      |          |
  1280.         //      |   ****   |
  1281.         //      |  ** **   |
  1282.         //      |  ** **   |
  1283.         //      |   ****   |
  1284.         //      |     ** * |
  1285.         //      |     **** |
  1286.  
  1287.   { 0x00,  0x00,  0x00,  0x7C,  0x66,  0x66,  0x60,  0x60 },    // 114 : r
  1288.         //      |          |
  1289.         //      |          |
  1290.         //      |          |
  1291.         //      |  *****   |
  1292.         //      |  **  **  |
  1293.         //      |  **  **  |
  1294.         //      |  **      |
  1295.         //      |  **      |
  1296.  
  1297.   { 0x00,  0x00,  0x00,  0x3E,  0x40,  0x3C,  0x02,  0x7C },    // 115 : s
  1298.         //      |          |
  1299.         //      |          |
  1300.         //      |          |
  1301.         //      |   *****  |
  1302.         //      |  *       |
  1303.         //      |   ****   |
  1304.         //      |       *  |
  1305.         //      |  *****   |
  1306.  
  1307.   { 0x00,  0x00,  0x18,  0x18,  0x7E,  0x18,  0x18,  0x18 },    // 116 : t
  1308.         //      |          |
  1309.         //      |          |
  1310.         //      |    **    |
  1311.         //      |    **    |
  1312.         //      |  ******  |
  1313.         //      |    **    |
  1314.         //      |    **    |
  1315.         //      |    **    |
  1316.  
  1317.   { 0x00,  0x00,  0x00,  0x66,  0x66,  0x66,  0x66,  0x3E },    // 117 : u
  1318.         //      |          |
  1319.         //      |          |
  1320.         //      |          |
  1321.         //      |  **  **  |
  1322.         //      |  **  **  |
  1323.         //      |  **  **  |
  1324.         //      |  **  **  |
  1325.         //      |   *****  |
  1326.  
  1327.   { 0x00,  0x00,  0x00,  0x00,  0x66,  0x66,  0x3C,  0x18 },    // 118 : v
  1328.         //      |          |
  1329.         //      |          |
  1330.         //      |          |
  1331.         //      |          |
  1332.         //      |  **  **  |
  1333.         //      |  **  **  |
  1334.         //      |   ****   |
  1335.         //      |    **    |
  1336.  
  1337.   { 0x00,  0x00,  0x00,  0x63,  0x6B,  0x6B,  0x6B,  0x3E },    // 119 : w
  1338.         //      |          |
  1339.         //      |          |
  1340.         //      |          |
  1341.         //      |  **   ** |
  1342.         //      |  ** * ** |
  1343.         //      |  ** * ** |
  1344.         //      |  ** * ** |
  1345.         //      |   *****  |
  1346.  
  1347.   { 0x00,  0x00,  0x00,  0x66,  0x3C,  0x18,  0x3C,  0x66 },    // 120 : x
  1348.         //      |          |
  1349.         //      |          |
  1350.         //      |          |
  1351.         //      |  **  **  |
  1352.         //      |   ****   |
  1353.         //      |    **    |
  1354.         //      |   ****   |
  1355.         //      |  **  **  |
  1356.  
  1357.   { 0x00,  0x00,  0x00,  0x66,  0x66,  0x3E,  0x06,  0x3C },    // 121 : y
  1358.         //      |          |
  1359.         //      |          |
  1360.         //      |          |
  1361.         //      |  **  **  |
  1362.         //      |  **  **  |
  1363.         //      |   *****  |
  1364.         //      |      **  |
  1365.         //      |   ****   |
  1366.  
  1367.   { 0x00,  0x00,  0x00,  0x3C,  0x0C,  0x18,  0x30,  0x3C },    // 122 : z
  1368.         //      |          |
  1369.         //      |          |
  1370.         //      |          |
  1371.         //      |   ****   |
  1372.         //      |     **   |
  1373.         //      |    **    |
  1374.         //      |   **     |
  1375.         //      |   ****   |
  1376.  
  1377.   { 0x00,  0x0E,  0x18,  0x18,  0x30,  0x18,  0x18,  0x0E },    // 123 : {
  1378.         //      |          |
  1379.         //      |     ***  |
  1380.         //      |    **    |
  1381.         //      |    **    |
  1382.         //      |   **     |
  1383.         //      |    **    |
  1384.         //      |    **    |
  1385.         //      |     ***  |
  1386.  
  1387.   { 0x00,  0x18,  0x18,  0x18,  0x00,  0x18,  0x18,  0x18 },    // 124 : |
  1388.         //      |          |
  1389.         //      |    **    |
  1390.         //      |    **    |
  1391.         //      |    **    |
  1392.         //      |          |
  1393.         //      |    **    |
  1394.         //      |    **    |
  1395.         //      |    **    |
  1396.  
  1397.   { 0x00,  0x70,  0x18,  0x18,  0x0C,  0x18,  0x18,  0x70 },    // 125 : }
  1398.         //      |          |
  1399.         //      |  ***     |
  1400.         //      |    **    |
  1401.         //      |    **    |
  1402.         //      |     **   |
  1403.         //      |    **    |
  1404.         //      |    **    |
  1405.         //      |  ***     |
  1406.  
  1407.   { 0x00,  0x00,  0x00,  0x3A,  0x6C,  0x00,  0x00,  0x00 },    // 126 : ~
  1408.         //      |          |
  1409.         //      |          |
  1410.         //      |          |
  1411.         //      |   *** *  |
  1412.         //      |  ** **   |
  1413.         //      |          |
  1414.         //      |          |
  1415.         //      |          |
  1416.  
  1417.   { 0x00,  0x08,  0x1C,  0x36,  0x63,  0x41,  0x41,  0x7F }    // 127 : 
  1418.         //      |          |
  1419.         //      |     *    |
  1420.         //      |    ***   |
  1421.         //      |   ** **  |
  1422.         //      |  **   ** |
  1423.         //      |  *     * |
  1424.         //      |  *     * |
  1425.         //      |  ******* |
  1426.  
  1427.  
  1428. };
  1429.  
  1430. // Define display string here
  1431. const int charNum = 15;
  1432. char string[charNum] = {'A','R','D','U','I','N','O',' ','R','U','L','E','S','!',' '};
  1433.  
  1434. void effect_text(int delayt){
  1435.   fill(0x00);
  1436.   for (int ltr = 0; ltr < charNum; ltr++){// For each letter in string array
  1437.     for(int dist = 0; dist < 8; dist++) { //bring letter forward
  1438.       fill(0x00);//blank last row
  1439.       int rev = 0;
  1440.       for (int rw = 7; rw >= 0; rw--) {//copy rows
  1441.          cube[rev][dist] = bitswap(font_data[string[ltr]][rw]);
  1442.          rev++;
  1443.       }
  1444.       delay_ms(delayt);
  1445.     }
  1446.   }
  1447. }
  1448.  
  1449. unsigned char bitswap (unsigned char x)//Reverses a byte (so letters aren't backwards);
  1450. {  byte result;
  1451.  
  1452.     asm("mov __tmp_reg__, %[in] \n\t"
  1453.       "lsl __tmp_reg__  \n\t"   /* shift out high bit to carry */
  1454.       "ror %[out] \n\t"  /* rotate carry __tmp_reg__to low bit (eventually) */
  1455.       "lsl __tmp_reg__  \n\t"   /* 2 */
  1456.       "ror %[out] \n\t"
  1457.       "lsl __tmp_reg__  \n\t"   /* 3 */
  1458.       "ror %[out] \n\t"
  1459.       "lsl __tmp_reg__  \n\t"   /* 4 */
  1460.       "ror %[out] \n\t"
  1461.      
  1462.       "lsl __tmp_reg__  \n\t"   /* 5 */
  1463.       "ror %[out] \n\t"
  1464.       "lsl __tmp_reg__  \n\t"   /* 6 */
  1465.       "ror %[out] \n\t"
  1466.       "lsl __tmp_reg__  \n\t"   /* 7 */
  1467.       "ror %[out] \n\t"
  1468.       "lsl __tmp_reg__  \n\t"   /* 8 */
  1469.       "ror %[out] \n\t"
  1470.       : [out] "=r" (result) : [in] "r" (x));
  1471.       return(result);
  1472. }
  1473.  
  1474. // ==========================================================================================
  1475. //   Effect functions
  1476. // ==========================================================================================
  1477.  
  1478. void effect_box_wamp(int delayt)
  1479. {
  1480.   for(int k = 0; k < 3; k++){
  1481.    for(int i = 0; i < 4; i++){
  1482.      fill(0x00);
  1483.     box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1484.     delay_ms(delayt);
  1485.    }
  1486.    for(int i = 3; i >= 0; i--){
  1487.      fill(0x00);
  1488.     box_filled(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1489.     delay_ms(delayt);
  1490.    }
  1491.   }
  1492.  
  1493.   for(int k = 0; k < 3; k++){
  1494.    for(int i = 0; i < 4; i++){
  1495.      fill(0x00);
  1496.     box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1497.     delay_ms(delayt);
  1498.    }
  1499.    for(int i = 3; i >= 0; i--){
  1500.      fill(0x00);
  1501.     box_walls(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1502.     delay_ms(delayt);
  1503.    }
  1504.   }
  1505.  
  1506.   for(int k = 0; k < 3; k++){
  1507.    for(int i = 0; i < 4; i++){
  1508.      fill(0x00);
  1509.     box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1510.     delay_ms(delayt);
  1511.    }
  1512.    for(int i = 3; i >= 0; i--){
  1513.      fill(0x00);
  1514.     box_wireframe(3 - i, 3 - i, 3 - i, 4 + i, 4 + i, 4 + i);
  1515.     delay_ms(delayt);
  1516.    }
  1517.   }
  1518. }
  1519.  
  1520. void draw_positions_axis (char axis, unsigned char positions[64], int invert)
  1521. {
  1522.     int x, y, p;
  1523.    
  1524.     fill(0x00);
  1525.    
  1526.     for (x=0; x<8; x++)
  1527.     {
  1528.         for (y=0; y<8; y++)
  1529.         {
  1530.             if (invert)
  1531.             {
  1532.                 p = (7-positions[(x*8)+y]);
  1533.             } else
  1534.             {
  1535.                 p = positions[(x*8)+y];
  1536.             }
  1537.        
  1538.             if (axis == AXIS_Z)
  1539.                 setvoxel(x,y,p);
  1540.                
  1541.             if (axis == AXIS_Y)
  1542.                 setvoxel(x,p,y);
  1543.                
  1544.             if (axis == AXIS_X)
  1545.                 setvoxel(p,y,x);
  1546.         }
  1547.     }
  1548.    
  1549. }
  1550.  
  1551.  
  1552. void effect_boxside_randsend_parallel (char axis, int origin, int delayt, int mode)
  1553. {
  1554.     int i;
  1555.     int done;
  1556.     unsigned char cubepos[64];
  1557.     unsigned char pos[64];
  1558.     int notdone = 1;
  1559.     int notdone2 = 1;
  1560.     int sent = 0;
  1561.    
  1562.     for (i=0;i<64;i++)
  1563.     {
  1564.         pos[i] = 0;
  1565.     }
  1566.    
  1567.     while (notdone)
  1568.     {
  1569.         if (mode == 1)
  1570.         {
  1571.             notdone2 = 1;
  1572.             while (notdone2 && sent<64)
  1573.             {
  1574.                 i = rand()%64;
  1575.                 if (pos[i] == 0)
  1576.                 {
  1577.                     sent++;
  1578.                     pos[i] += 1;
  1579.                     notdone2 = 0;
  1580.                 }
  1581.             }
  1582.         } else if (mode == 2)
  1583.         {
  1584.             if (sent<64)
  1585.             {
  1586.                 pos[sent] += 1;
  1587.                 sent++;
  1588.             }
  1589.         }
  1590.        
  1591.         done = 0;
  1592.         for (i=0;i<64;i++)
  1593.         {
  1594.             if (pos[i] > 0 && pos[i] <7)
  1595.             {
  1596.                 pos[i] += 1;
  1597.             }
  1598.                
  1599.             if (pos[i] == 7)
  1600.                 done++;
  1601.         }
  1602.        
  1603.         if (done == 64)
  1604.             notdone = 0;
  1605.        
  1606.         for (i=0;i<64;i++)
  1607.         {
  1608.             if (origin == 0)
  1609.             {
  1610.                 cubepos[i] = pos[i];
  1611.             } else
  1612.             {
  1613.                 cubepos[i] = (7-pos[i]);
  1614.             }
  1615.         }
  1616.        
  1617.        
  1618.         delay_ms(delayt);
  1619.         draw_positions_axis(axis,cubepos,0);
  1620.  
  1621.     }
  1622.    
  1623. }
  1624.  
  1625.  
  1626. void effect_rain (int iterations)
  1627. {
  1628.     int i, ii;
  1629.     int rnd_x;
  1630.     int rnd_y;
  1631.     int rnd_num;
  1632.    
  1633.     for (ii=0;ii<iterations;ii++)
  1634.     {
  1635.         rnd_num = rand()%4;
  1636.        
  1637.         for (i=0; i < rnd_num;i++)
  1638.         {
  1639.             rnd_x = rand()%8;
  1640.             rnd_y = rand()%8;
  1641.             setvoxel(rnd_x,rnd_y,7);
  1642.         }
  1643.        
  1644.         delay_ms(1000);
  1645.         shift(AXIS_Z,-1);
  1646.     }
  1647. }
  1648.  
  1649. // Set or clear exactly 512 voxels in a random order.
  1650. void effect_random_filler (int delayt, int state)
  1651. {
  1652.     int x,y,z;
  1653.     int loop = 0;
  1654.    
  1655.    
  1656.     if (state == 1)
  1657.     {
  1658.         fill(0x00);
  1659.     } else
  1660.     {
  1661.         fill(0xff);
  1662.     }
  1663.    
  1664.     while (loop<511)
  1665.     {
  1666.         x = rand()%8;
  1667.         y = rand()%8;
  1668.         z = rand()%8;
  1669.  
  1670.         if ((state == 0 && getvoxel(x,y,z) == 0x01) || (state == 1 && getvoxel(x,y,z) == 0x00))
  1671.         {
  1672.             altervoxel(x,y,z,state);
  1673.             delay_ms(delayt);
  1674.             loop++;
  1675.         }  
  1676.     }
  1677. }
  1678.  
  1679.  
  1680. void effect_blinky2()
  1681. {
  1682.     int i,r;
  1683.     fill(0x00);
  1684.    
  1685.     for (r=0;r<2;r++)
  1686.     {
  1687.         i = 750;
  1688.         while (i>0)
  1689.         {
  1690.             fill(0x00);
  1691.             delay_ms(i);
  1692.            
  1693.             fill(0xff);
  1694.             delay_ms(100);
  1695.            
  1696.             i = i - (15+(1000/(i/10)));
  1697.         }
  1698.        
  1699.         delay_ms(1000);
  1700.        
  1701.         i = 750;
  1702.         while (i>0)
  1703.         {
  1704.             fill(0x00);
  1705.             delay_ms(751-i);
  1706.            
  1707.             fill(0xff);
  1708.             delay_ms(100);
  1709.            
  1710.             i = i - (15+(1000/(i/10)));
  1711.         }
  1712.     }
  1713.  
  1714. }
  1715.  
  1716. // Draw a plane on one axis and send it back and forth once.
  1717. void effect_planboing (int plane, int speedd)
  1718. {
  1719.     int i;
  1720.     for (i=0;i<8;i++)
  1721.     {
  1722.         fill(0x00);
  1723.         setplane(plane, i);
  1724.         delay_ms(speedd);
  1725.     }
  1726.    
  1727.     for (i=7;i>=0;i--)
  1728.     {
  1729.         fill(0x00);
  1730.         setplane(plane,i);
  1731.         delay_ms(speedd);
  1732.     }
  1733. }
  1734.  
  1735.  
  1736. // ==========================================================================================
  1737. //   Draw functions
  1738. // ==========================================================================================
  1739.  
  1740.  
  1741. // Set a single voxel to ON
  1742. void setvoxel(int x, int y, int z)
  1743. {
  1744.     if (inrange(x,y,z))
  1745.         cube[z][y] |= (1 << x);
  1746. }
  1747.  
  1748.  
  1749. // Set a single voxel to ON
  1750. void clrvoxel(int x, int y, int z)
  1751. {
  1752.     if (inrange(x,y,z))
  1753.         cube[z][y] &= ~(1 << x);
  1754. }
  1755.  
  1756.  
  1757.  
  1758. // This function validates that we are drawing inside the cube.
  1759. unsigned char inrange(int x, int y, int z)
  1760. {
  1761.     if (x >= 0 && x < 8 && y >= 0 && y < 8 && z >= 0 && z < 8)
  1762.     {
  1763.         return 0x01;
  1764.     } else
  1765.     {
  1766.         // One of the coordinates was outside the cube.
  1767.         return 0x00;
  1768.     }
  1769. }
  1770.  
  1771. // Get the current status of a voxel
  1772. unsigned char getvoxel(int x, int y, int z)
  1773. {
  1774.     if (inrange(x,y,z))
  1775.     {
  1776.         if (cube[z][y] & (1 << x))
  1777.         {
  1778.             return 0x01;
  1779.         } else
  1780.         {
  1781.             return 0x00;
  1782.         }
  1783.     } else
  1784.     {
  1785.         return 0x00;
  1786.     }
  1787. }
  1788.  
  1789. // In some effect we want to just take bool and write it to a voxel
  1790. // this function calls the apropriate voxel manipulation function.
  1791. void altervoxel(int x, int y, int z, int state)
  1792. {
  1793.     if (state == 1)
  1794.     {
  1795.         setvoxel(x,y,z);
  1796.     } else
  1797.     {
  1798.         clrvoxel(x,y,z);
  1799.     }
  1800. }
  1801.  
  1802. // Flip the state of a voxel.
  1803. // If the voxel is 1, its turned into a 0, and vice versa.
  1804. void flpvoxel(int x, int y, int z)
  1805. {
  1806.     if (inrange(x, y, z))
  1807.         cube[z][y] ^= (1 << x);
  1808. }
  1809.  
  1810. // Makes sure x1 is alwas smaller than x2
  1811. // This is usefull for functions that uses for loops,
  1812. // to avoid infinite loops
  1813. void argorder(int ix1, int ix2, int *ox1, int *ox2)
  1814. {
  1815.     if (ix1>ix2)
  1816.     {
  1817.         int tmp;
  1818.         tmp = ix1;
  1819.         ix1= ix2;
  1820.         ix2 = tmp;
  1821.     }
  1822.     *ox1 = ix1;
  1823.     *ox2 = ix2;
  1824. }
  1825.  
  1826. // Sets all voxels along a X/Y plane at a given point
  1827. // on axis Z
  1828. void setplane_z (int z)
  1829. {
  1830.     int i;
  1831.     if (z>=0 && z<8)
  1832.     {
  1833.         for (i=0;i<8;i++)
  1834.             cube[z][i] = 0xff;
  1835.     }
  1836. }
  1837.  
  1838. // Clears voxels in the same manner as above
  1839. void clrplane_z (int z)
  1840. {
  1841.     int i;
  1842.     if (z>=0 && z<8)
  1843.     {
  1844.         for (i=0;i<8;i++)
  1845.             cube[z][i] = 0x00;
  1846.     }
  1847. }
  1848.  
  1849. void setplane_x (int x)
  1850. {
  1851.     int z;
  1852.     int y;
  1853.     if (x>=0 && x<8)
  1854.     {
  1855.         for (z=0;z<8;z++)
  1856.         {
  1857.             for (y=0;y<8;y++)
  1858.             {
  1859.                 cube[z][y] |= (1 << x);
  1860.             }
  1861.         }
  1862.     }
  1863. }
  1864.  
  1865. void clrplane_x (int x)
  1866. {
  1867.     int z;
  1868.     int y;
  1869.     if (x>=0 && x<8)
  1870.     {
  1871.         for (z=0;z<8;z++)
  1872.         {
  1873.             for (y=0;y<8;y++)
  1874.             {
  1875.                 cube[z][y] &= ~(1 << x);
  1876.             }
  1877.         }
  1878.     }
  1879. }
  1880.  
  1881. void setplane_y (int y)
  1882. {
  1883.     int z;
  1884.     if (y>=0 && y<8)
  1885.     {
  1886.         for (z=0;z<8;z++)
  1887.             cube[z][y] = 0xff;
  1888.     }
  1889. }
  1890.  
  1891. void clrplane_y (int y)
  1892. {
  1893.     int z;
  1894.     if (y>=0 && y<8)
  1895.     {
  1896.         for (z=0;z<8;z++)
  1897.             cube[z][y] = 0x00;
  1898.     }
  1899. }
  1900.  
  1901. void setplane (char axis, unsigned char i)
  1902. {
  1903.     switch (axis)
  1904.     {
  1905.         case AXIS_X:
  1906.             setplane_x(i);
  1907.             break;
  1908.        
  1909.        case AXIS_Y:
  1910.             setplane_y(i);
  1911.             break;
  1912.  
  1913.        case AXIS_Z:
  1914.             setplane_z(i);
  1915.             break;
  1916.     }
  1917. }
  1918.  
  1919. void clrplane (char axis, unsigned char i)
  1920. {
  1921.     switch (axis)
  1922.     {
  1923.         case AXIS_X:
  1924.             clrplane_x(i);
  1925.             break;
  1926.        
  1927.        case AXIS_Y:
  1928.             clrplane_y(i);
  1929.             break;
  1930.  
  1931.        case AXIS_Z:
  1932.             clrplane_z(i);
  1933.             break;
  1934.     }
  1935. }
  1936.  
  1937. // Fill a value into all 64 byts of the cube buffer
  1938. // Mostly used for clearing. fill(0x00)
  1939. // or setting all on. fill(0xff)
  1940. void fill (unsigned char pattern)
  1941. {
  1942.     int z;
  1943.     int y;
  1944.     for (z=0;z<8;z++)
  1945.     {
  1946.         for (y=0;y<8;y++)
  1947.         {
  1948.             cube[z][y] = pattern;
  1949.         }
  1950.     }
  1951. }
  1952.  
  1953.  
  1954.  
  1955. // Draw a box with all walls drawn and all voxels inside set
  1956. void box_filled(int x1, int y1, int z1, int x2, int y2, int z2)
  1957. {
  1958.     int iy;
  1959.     int iz;
  1960.  
  1961.     argorder(x1, x2, &x1, &x2);
  1962.     argorder(y1, y2, &y1, &y2);
  1963.     argorder(z1, z2, &z1, &z2);
  1964.  
  1965.     for (iz=z1;iz<=z2;iz++)
  1966.     {
  1967.         for (iy=y1;iy<=y2;iy++)
  1968.         {
  1969.             cube[iz][iy] |= byteline(x1,x2);
  1970.         }
  1971.     }
  1972.  
  1973. }
  1974.  
  1975. // Darw a hollow box with side walls.
  1976. void box_walls(int x1, int y1, int z1, int x2, int y2, int z2)
  1977. {
  1978.     int iy;
  1979.     int iz;
  1980.    
  1981.     argorder(x1, x2, &x1, &x2);
  1982.     argorder(y1, y2, &y1, &y2);
  1983.     argorder(z1, z2, &z1, &z2);
  1984.  
  1985.     for (iz=z1;iz<=z2;iz++)
  1986.     {
  1987.         for (iy=y1;iy<=y2;iy++)
  1988.         {  
  1989.             if (iy == y1 || iy == y2 || iz == z1 || iz == z2)
  1990.             {
  1991.                 cube[iz][iy] = byteline(x1,x2);
  1992.             } else
  1993.             {
  1994.                 cube[iz][iy] |= ((0x01 << x1) | (0x01 << x2));
  1995.             }
  1996.         }
  1997.     }
  1998.  
  1999. }
  2000.  
  2001. // Draw a wireframe box. This only draws the corners and edges,
  2002. // no walls.
  2003. void box_wireframe(int x1, int y1, int z1, int x2, int y2, int z2)
  2004. {
  2005.     int iy;
  2006.     int iz;
  2007.  
  2008.     argorder(x1, x2, &x1, &x2);
  2009.     argorder(y1, y2, &y1, &y2);
  2010.     argorder(z1, z2, &z1, &z2);
  2011.  
  2012.     // Lines along X axis
  2013.     cube[z1][y1] = byteline(x1,x2);
  2014.     cube[z1][y2] = byteline(x1,x2);
  2015.     cube[z2][y1] = byteline(x1,x2);
  2016.     cube[z2][y2] = byteline(x1,x2);
  2017.  
  2018.     // Lines along Y axis
  2019.     for (iy=y1;iy<=y2;iy++)
  2020.     {
  2021.         setvoxel(x1,iy,z1);
  2022.         setvoxel(x1,iy,z2);
  2023.         setvoxel(x2,iy,z1);
  2024.         setvoxel(x2,iy,z2);
  2025.     }
  2026.  
  2027.     // Lines along Z axis
  2028.     for (iz=z1;iz<=z2;iz++)
  2029.     {
  2030.         setvoxel(x1,y1,iz);
  2031.         setvoxel(x1,y2,iz);
  2032.         setvoxel(x2,y1,iz);
  2033.         setvoxel(x2,y2,iz);
  2034.     }
  2035.  
  2036. }
  2037.  
  2038. // Returns a byte with a row of 1's drawn in it.
  2039. // byteline(2,5) gives 0b00111100
  2040. char byteline (int start, int end)
  2041. {
  2042.     return ((0xff<<start) & ~(0xff<<(end+1)));
  2043. }
  2044.  
  2045. // Flips a byte 180 degrees.
  2046. // MSB becomes LSB, LSB becomes MSB.
  2047. char flipbyte (char byte)
  2048. {
  2049.     char flop = 0x00;
  2050.  
  2051.     flop = (flop & 0b11111110) | (0b00000001 & (byte >> 7));
  2052.     flop = (flop & 0b11111101) | (0b00000010 & (byte >> 5));
  2053.     flop = (flop & 0b11111011) | (0b00000100 & (byte >> 3));
  2054.     flop = (flop & 0b11110111) | (0b00001000 & (byte >> 1));
  2055.     flop = (flop & 0b11101111) | (0b00010000 & (byte << 1));
  2056.     flop = (flop & 0b11011111) | (0b00100000 & (byte << 3));
  2057.     flop = (flop & 0b10111111) | (0b01000000 & (byte << 5));
  2058.     flop = (flop & 0b01111111) | (0b10000000 & (byte << 7));
  2059.     return flop;
  2060. }
  2061.  
  2062. // Draw a line between any coordinates in 3d space.
  2063. // Uses integer values for input, so dont expect smooth animations.
  2064. void line(int x1, int y1, int z1, int x2, int y2, int z2)
  2065. {
  2066.     float xy;   // how many voxels do we move on the y axis for each step on the x axis
  2067.     float xz;   // how many voxels do we move on the y axis for each step on the x axis
  2068.     unsigned char x,y,z;
  2069.     unsigned char lasty,lastz;
  2070.  
  2071.     // We always want to draw the line from x=0 to x=7.
  2072.     // If x1 is bigget than x2, we need to flip all the values.
  2073.     if (x1>x2)
  2074.     {
  2075.         int tmp;
  2076.         tmp = x2; x2 = x1; x1 = tmp;
  2077.         tmp = y2; y2 = y1; y1 = tmp;
  2078.         tmp = z2; z2 = z1; z1 = tmp;
  2079.     }
  2080.  
  2081.    
  2082.     if (y1>y2)
  2083.     {
  2084.         xy = (float)(y1-y2)/(float)(x2-x1);
  2085.         lasty = y2;
  2086.     } else
  2087.     {
  2088.         xy = (float)(y2-y1)/(float)(x2-x1);
  2089.         lasty = y1;
  2090.     }
  2091.  
  2092.     if (z1>z2)
  2093.     {
  2094.         xz = (float)(z1-z2)/(float)(x2-x1);
  2095.         lastz = z2;
  2096.     } else
  2097.     {
  2098.         xz = (float)(z2-z1)/(float)(x2-x1);
  2099.         lastz = z1;
  2100.     }
  2101.  
  2102.  
  2103.  
  2104.     // For each step of x, y increments by:
  2105.     for (x = x1; x<=x2;x++)
  2106.     {
  2107.         y = (xy*(x-x1))+y1;
  2108.         z = (xz*(x-x1))+z1;
  2109.         setvoxel(x,y,z);
  2110.     }
  2111.    
  2112. }
  2113.  
  2114. // Delay loop.
  2115. // This is not calibrated to milliseconds,
  2116. // but we had allready made to many effects using this
  2117. // calibration when we figured it might be a good idea
  2118. // to calibrate it.
  2119. void delay_ms(uint16_t x)
  2120. {
  2121.   uint8_t y, z;
  2122.   for ( ; x > 0 ; x--){
  2123.     for ( y = 0 ; y < 90 ; y++){
  2124.       for ( z = 0 ; z < 6 ; z++){
  2125.         asm volatile ("nop");
  2126.       }
  2127.     }
  2128.   }
  2129. }
  2130.  
  2131.  
  2132.  
  2133. // Shift the entire contents of the cube along an axis
  2134. // This is great for effects where you want to draw something
  2135. // on one side of the cube and have it flow towards the other
  2136. // side. Like rain flowing down the Z axiz.
  2137. void shift (char axis, int direction)
  2138. {
  2139.     int i, x ,y;
  2140.     int ii, iii;
  2141.     int state;
  2142.  
  2143.     for (i = 0; i < 8; i++)
  2144.     {
  2145.         if (direction == -1)
  2146.         {
  2147.             ii = i;
  2148.         } else
  2149.         {
  2150.             ii = (7-i);
  2151.         }  
  2152.    
  2153.    
  2154.         for (x = 0; x < 8; x++)
  2155.         {
  2156.             for (y = 0; y < 8; y++)
  2157.             {
  2158.                 if (direction == -1)
  2159.                 {
  2160.                     iii = ii+1;
  2161.                 } else
  2162.                 {
  2163.                     iii = ii-1;
  2164.                 }
  2165.                
  2166.                 if (axis == AXIS_Z)
  2167.                 {
  2168.                     state = getvoxel(x,y,iii);
  2169.                     altervoxel(x,y,ii,state);
  2170.                 }
  2171.                
  2172.                 if (axis == AXIS_Y)
  2173.                 {
  2174.                     state = getvoxel(x,iii,y);
  2175.                     altervoxel(x,ii,y,state);
  2176.                 }
  2177.                
  2178.                 if (axis == AXIS_X)
  2179.                 {
  2180.                     state = getvoxel(iii,y,x);
  2181.                     altervoxel(ii,y,x,state);
  2182.                 }
  2183.             }
  2184.         }
  2185.     }
  2186.    
  2187.     if (direction == -1)
  2188.     {
  2189.         i = 7;
  2190.     } else
  2191.     {
  2192.         i = 0;
  2193.     }  
  2194.    
  2195.     for (x = 0; x < 8; x++)
  2196.     {
  2197.         for (y = 0; y < 8; y++)
  2198.         {
  2199.             if (axis == AXIS_Z)
  2200.                 clrvoxel(x,y,i);
  2201.                
  2202.             if (axis == AXIS_Y)
  2203.                 clrvoxel(x,i,y);
  2204.            
  2205.             if (axis == AXIS_X)
  2206.                 clrvoxel(i,y,x);
  2207.         }
  2208.     }
  2209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement