Advertisement
Guest User

takehito.c

a guest
Aug 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.70 KB | None | 0 0
  1. // Takehito Koyasu Counterthingymaschine.
  2.  
  3. // Version 5.7,12
  4. // This monstrosity was created by the following people:
  5. // Markus Hiienkari, Johan Strandman, Sampo Vartiala, Ville Sinkkonen
  6. // This software is distributed under the DWFYWSL (Do-Whatever-The-Fuck-You-Want-Software license)
  7. // It can not be distributed under any other license than DWFYWSL.
  8. // By opening this file you accept the terms and conditions.
  9.  
  10. #include <string.h>
  11. #include <avr/io.h>
  12. #include <util/delay.h>
  13. #include <avr/pgmspace.h>
  14.  
  15. /*
  16. PB0
  17. PD7
  18. PD6
  19. PD5
  20. PB7
  21.  
  22. PB6
  23. PD4
  24. PD3
  25. PD2
  26. PB1
  27.  
  28. PB2
  29. PB3
  30. PB4
  31. PB5
  32. PC5
  33.  
  34. PC0
  35. PC1
  36. PC2
  37. PC3
  38. PC4
  39.  
  40. */
  41.  
  42. #define F_CPU 1000000UL
  43. //#define SCROLL_DELAY 1 /* ms */
  44. #define SCROLL_DELAY 100 /* ms */
  45. //#define SCROLL_STEP() _delay_ms(SCROLL_DELAY);
  46. #define SCROLL_STEP() _delay_us(SCROLL_DELAY);
  47.  
  48. #define BTN_BIT     (1<<1)
  49.  
  50. #define COL0_PORT PORTC
  51. #define COL1_PORT PORTB
  52. #define COL2_PORT PORTB
  53. #define COL3_PORT PORTB
  54. #define COL4_PORT PORTB
  55.  
  56. #define COL5_PORT PORTB
  57. #define COL6_PORT PORTD
  58. #define COL7_PORT PORTD
  59. #define COL8_PORT PORTD
  60. #define COL9_PORT PORTB
  61.  
  62. #define COL0_BIT (1<<5)  // PB5  
  63. #define COL1_BIT (1<<5)  // PB5
  64. #define COL2_BIT (1<<4)  // PB4
  65. #define COL3_BIT (1<<3)  // PB3
  66. #define COL4_BIT (1<<2)  // PC2
  67.  
  68. #define COL5_BIT (1<<1)  // PB1
  69. #define COL6_BIT (1<<2)  // PD2
  70. #define COL7_BIT (1<<3)  // PD3
  71. #define COL8_BIT (1<<4)  // PD4
  72. #define COL9_BIT (1<<6)  // PB6
  73.  
  74.  
  75.  
  76. #define ROW0_PORT PORTC
  77. #define ROW1_PORT PORTC
  78. #define ROW2_PORT PORTC
  79. #define ROW3_PORT PORTC
  80. #define ROW4_PORT PORTC
  81.  
  82. #define ROW5_PORT PORTB
  83. #define ROW6_PORT PORTD
  84. #define ROW7_PORT PORTD
  85. #define ROW8_PORT PORTD
  86. #define ROW9_PORT PORTB
  87.  
  88. #define ROW0_BIT (1<<0)  // PC0
  89. #define ROW1_BIT (1<<1)  // PC1
  90. #define ROW2_BIT (1<<2)  // PC2
  91. #define ROW3_BIT (1<<3)  // PC3
  92. #define ROW4_BIT (1<<4)  // PC4
  93.  
  94. #define ROW5_BIT (1<<7)  // PB7
  95. #define ROW6_BIT (1<<5)  // PD5
  96. #define ROW7_BIT (1<<6)  // PD6
  97. #define ROW8_BIT (1<<7)  // PD7
  98. #define ROW9_BIT (1<<0)  // PB0
  99.  
  100. // strings stored in flash
  101. const char str_0[] PROGMEM = "DAT BAT";
  102. const char str_1[] PROGMEM = "ILPALAZZO";
  103. const char str_2[] PROGMEM = "HARUHI'S MOM";
  104. const char str_3[] PROGMEM = "OLIVIER";
  105. const char str_4[] PROGMEM = "ZECHS";    
  106. const char str_5[] PROGMEM = "THE FOOL";
  107. const char str_6[] PROGMEM = "MU LA FLAGA";
  108. const char str_7[] PROGMEM = "REZO";
  109. const char str_8[] PROGMEM = "HOTOHORI";
  110. const char str_9[] PROGMEM = "TAKAHASHI RYOUSUKE";
  111. const char str_10[] PROGMEM = "KEIKI";
  112. const char str_11[] PROGMEM = "KUROYANAGI";
  113. const char str_12[] PROGMEM = "HONDA SHIGEHARU";
  114. const char str_13[] PROGMEM = "JADE CURTISS";
  115. const char str_14[] PROGMEM = "KRAFT";
  116. const char str_15[] PROGMEM = "DIO";
  117. const char str_16[] PROGMEM = "ABURATSUBO";
  118. const char str_17[] PROGMEM = "KIRYUU";
  119. const char str_18[] PROGMEM = "THE OTHER EINBERG";
  120. const char str_19[] PROGMEM = "KAYAMA YUUICHI";
  121. const char str_20[] PROGMEM = "EXCALIBUR";
  122. const char str_21[] PROGMEM = "THAT DORSSIAN POPE";
  123. const char str_22[] PROGMEM = "  SORSA%DSM WAS HERE  }}}DESUDESU}DESUDESU}DESUDESU}DESUDESU}DESUDESUDESU_";
  124. const char str_23[] PROGMEM = "  TAKEHITO-COUNTER (2014-2016), BROUGHT TO YOU BY MURSU, SORSA%DSM, ARB AND MARQS^   AND { STILL{ NEEDS{ MOAR {DESU _";
  125. const char str_24[] PROGMEM = "  TEAM TAKEHITO-COUNTER: PRO{{{{{{{{D}}}}}}}}}}UCING QUA{}{}{{{{{L{{IT}}Y}}}}} CO{{{DE}}} SINC{{}}E 2014}}...._";
  126. const char str_25[] PROGMEM = "  THEY SEE MEE ROLLIN..._";
  127. const char str_26[] PROGMEM = "  RURI-CHAAAAN NOT}I}C}E }}M}EEEEEEEEEEEEEEEEE!!!!!!!!_";
  128. // note to self: you might want to look into PSTR()
  129.  
  130. const char* const str_table[] PROGMEM = {
  131.     str_0, str_1, str_2, str_3, str_4, str_5, str_6, str_7, str_8, str_9,
  132.     str_10, str_11, str_12, str_13, str_14, str_15, str_16, str_17, str_18, str_19,
  133.     str_20, str_21, str_22, str_23, str_24, str_25, str_26
  134. };
  135.  
  136. //fishy number used in magic
  137. unsigned char turska = 0;
  138.  
  139. char buffer[150];
  140.  
  141. // get string to buffer (called buffer)
  142. void get_str(int i) {
  143.     // worse than hitler
  144.     strcpy_P(buffer, (char*) pgm_read_word(&(str_table[i])));
  145. }
  146.  
  147.  
  148. // This is a bright idea...let's use ASCII!
  149. char letter[59+4][5] = {
  150.                     {0x00, 0x00, 0x00, 0x00, 0x00}, //NBSP
  151.                     {0x00, 0x00, 0x17, 0x00, 0x00}, //!
  152.                     {0x00, 0x03, 0x00, 0x03, 0x00}, //"
  153.                     {0x0A, 0x1F, 0x0A, 0x1F, 0x0A}, //#
  154.                     {0x00, 0x1C, 0x14, 0x1C, 0x00}, //$ Nope, o
  155.                     {0x10, 0x10, 0x10, 0x10, 0x00}, //% Nope, _
  156.                     {0x00, 0x00, 0x00, 0x00, 0x00}, //& Nope
  157.                     {0x00, 0x03, 0x00, 0x00, 0x00}, //'
  158.                     {0x00, 0x00, 0x0E, 0x11, 0x00}, //(
  159.                     {0x00, 0x00, 0x11, 0x0E, 0x00}, //)
  160.                     {0x00, 0x00, 0x00, 0x00, 0x00}, //* nope
  161.                     {0x04, 0x04, 0x1F, 0x04, 0x04}, //+
  162.                     {0x00, 0x00, 0x10, 0x08, 0x00}, //,
  163.                     {0x00, 0x04, 0x04, 0x04, 0x00}, //-
  164.                     {0x00, 0x00, 0x00, 0x10, 0x00}, //.
  165.                     {0x00, 0x18, 0x04, 0x03, 0x00}, ///
  166.                     {0x0E, 0x11, 0x11, 0x0E, 0x00}, //0
  167.                     {0x00, 0x12, 0x1F, 0x10, 0x00}, //1
  168.                     {0x12, 0x19, 0x15, 0x12, 0x00}, //2
  169.                     {0x11, 0x15, 0x15, 0x1F, 0x00}, //3
  170.                     {0x07, 0x04, 0x04, 0x1F, 0x00}, //4
  171.                     {0x17, 0x15, 0x15, 0x0D, 0x00}, //5
  172.                     {0x1F, 0x15, 0x15, 0x1D, 0x00}, //6
  173.                     {0x11, 0x09, 0x05, 0x03, 0x00}, //7
  174.                     {0x1B, 0x15, 0x15, 0x1B, 0x00}, //8
  175.                     {0x17, 0x15, 0x15, 0x1F, 0x00}, //9
  176.                     {0x00, 0x00, 0x00, 0x12, 0x00}, //:
  177.                     {0x00, 0x00, 0x10, 0x0A, 0x00}, //;
  178.                     {0x00, 0x04, 0x0A, 0x11, 0x00}, //<
  179.                     {0x00, 0x0A, 0x0A, 0x0A, 0x00}, //=
  180.                     {0x00, 0x11, 0x0A, 0x04, 0x00}, //>
  181.                     {0x00, 0x15, 0x05, 0x07, 0x00}, //?
  182.                     {0x00, 0x00, 0x00, 0x00, 0x00}, //@ nope, also magic
  183.                     {0x1F, 0x05, 0x05, 0x1F, 0x00}, //A
  184.                     {0x1F, 0X15, 0x15, 0x0E, 0x00}, //B
  185.                     {0x1F, 0x11, 0x11, 0x11, 0x00}, //C
  186.                     {0x1F, 0x11, 0x11, 0x0E, 0x00}, //D
  187.                     {0x1f, 0x15, 0x15, 0x11, 0x00}, //E
  188.                     {0x1F, 0x05, 0x05, 0x01, 0x00}, //F
  189.                     {0x1F, 0x11, 0x15, 0x1D, 0x00}, //G
  190.                     {0x1F, 0x04, 0x04, 0x1F, 0x00}, //H
  191.                     {0x00, 0x11, 0x1F, 0x11, 0x00}, //I
  192.                     {0x19, 0x11, 0x1F, 0x01, 0x00}, //J
  193.                     {0x1F, 0x04, 0x0A, 0x11, 0x00}, //K
  194.                     {0x1F, 0x10, 0x10, 0x10, 0x00}, //L
  195.                     {0x1F, 0x02, 0x04, 0x02, 0x1F}, //M
  196.                     {0x1F, 0x02, 0x04, 0x1F, 0x00}, //N
  197.                     {0x1F, 0x11, 0x11, 0x1F, 0x00}, //O
  198.                     {0x1F, 0x05, 0x05, 0x07, 0x00}, //P
  199.                     {0x1F, 0x11, 0x19, 0x1F ,0x00}, //Q
  200.                     {0x1F, 0x05, 0x0D, 0x17, 0x00}, //R
  201.                     {0x17, 0x15, 0x15, 0x1D, 0x00}, //S
  202.                     {0x01, 0x01, 0x1F, 0x01, 0x01}, //T
  203.                     {0x1F, 0x10, 0x10, 0x1F, 0x00}, //U
  204.                     {0x1F, 0x08, 0x04, 0x03, 0x00}, //V
  205.                     {0x1F, 0x08, 0x04, 0x08, 0x1F}, //W
  206.                     {0x11, 0x0A, 0x04, 0x0A, 0x11}, //X
  207.                     {0x01, 0x02, 0x1C, 0x02, 0x01}, //Y
  208.                     {0x11, 0x19, 0x15, 0x13, 0x00}, //Z
  209.                     {0x00, 0x1F, 0x11, 0x11, 0x00}, //[
  210.                     {0x00, 0x03, 0x04, 0x18, 0x00}, ///
  211.                     {0x00, 0x11, 0x11, 0x1F, 0x00}, //]
  212.                     {0x00, 0x02, 0x01, 0x02, 0x00} //^
  213.                    };
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220. void io_setup () {
  221.     DDRB = 0xff;    // 8
  222.     DDRC = 0x3f;    // 6
  223.     DDRD = 0xfc;    // 6
  224.    
  225.     PORTB = 0xff;   // 0b11111111
  226.     PORTC = 0x3f;   // 0b00111111
  227.     PORTD = 0xfc;   // 0b11111100
  228.    
  229.     _delay_ms(1000);
  230.    
  231.     COL0_PORT &= ~COL0_BIT;
  232.     COL1_PORT &= ~COL1_BIT;
  233.     COL2_PORT &= ~COL2_BIT;
  234.     COL3_PORT &= ~COL3_BIT;
  235.     COL4_PORT &= ~COL4_BIT;
  236.     COL5_PORT &= ~COL5_BIT;
  237.     COL6_PORT &= ~COL6_BIT;
  238.     COL7_PORT &= ~COL7_BIT;
  239.     COL8_PORT &= ~COL8_BIT;
  240.     COL9_PORT &= ~COL9_BIT;
  241. }
  242.  
  243. void activate_col(int x, int matrix) {
  244.    
  245.     if (matrix == 1) {
  246.    
  247.         switch (x) {
  248.             case 0:
  249.                 COL0_PORT |= COL0_BIT;
  250.                 break;
  251.             case 1:
  252.                 COL1_PORT |= COL1_BIT;
  253.                 break;
  254.             case 2:
  255.                 COL2_PORT |= COL2_BIT;
  256.                 break;
  257.             case 3:
  258.                 COL3_PORT |= COL3_BIT;
  259.                 break; 
  260.             case 4:
  261.                 COL4_PORT |= COL4_BIT;
  262.                 break;
  263.         }
  264.     } else {
  265.         switch (x) {
  266.             case 0:
  267.                 COL5_PORT |= COL5_BIT;
  268.                 break;
  269.             case 1:
  270.                 COL6_PORT |= COL6_BIT;
  271.                 break;
  272.             case 2:
  273.                 COL7_PORT |= COL7_BIT;
  274.                 break;
  275.             case 3:
  276.                 COL8_PORT |= COL8_BIT;
  277.                 break; 
  278.             case 4:
  279.                 COL9_PORT |= COL9_BIT;
  280.                 break;
  281.         }
  282.     }
  283. }
  284.  
  285. /*
  286. void enable_all_rows() {
  287.     PORTB = 0xff;
  288.     PORTC = 0x3f;
  289.     PORTD = 0xfc;
  290.  
  291.     //disable all cols
  292.     COL0_PORT &= ~COL0_BIT;
  293.     COL1_PORT &= ~COL1_BIT;
  294.     COL2_PORT &= ~COL2_BIT;
  295.     COL3_PORT &= ~COL3_BIT;
  296.     COL4_PORT &= ~COL4_BIT;
  297.     COL5_PORT &= ~COL5_BIT;
  298.     COL6_PORT &= ~COL6_BIT;
  299.     COL7_PORT &= ~COL7_BIT;
  300.     COL8_PORT &= ~COL8_BIT;
  301.     COL9_PORT &= ~COL9_BIT;
  302. }
  303.  
  304. void enable_all_cols() {
  305.     PORTB = 0xff;
  306.     PORTC = 0x3f;
  307.     PORTD = 0xfc;
  308.  
  309.     //disable all rows
  310.     ROW0_PORT &= ~ROW0_BIT;
  311.     ROW1_PORT &= ~ROW1_BIT;
  312.     ROW2_PORT &= ~ROW2_BIT;
  313.     ROW3_PORT &= ~ROW3_BIT;
  314.     ROW4_PORT &= ~ROW4_BIT;
  315.     ROW5_PORT &= ~ROW5_BIT;
  316.     ROW6_PORT &= ~ROW6_BIT;
  317.     ROW7_PORT &= ~ROW7_BIT;
  318.     ROW8_PORT &= ~ROW8_BIT;
  319.     ROW9_PORT &= ~ROW9_BIT;
  320. }
  321. */
  322.  
  323. void disable_all_damn_shit_crap() {
  324.     PORTB = 0x00;
  325.     PORTC = 0x00;
  326.     PORTD = 0x00;
  327. }
  328.  
  329.  
  330.  
  331. void update_matrices(char row1, char col1, char row2, char col2) {
  332.     // row1 = five bits for row in matrix 1
  333.     // row2 = five bits for row in matrix 2
  334.     // col1 = column in matrix 1
  335.     // col2 = column in matrix 2
  336.    
  337.     // Set values for given column on matrix 1
  338.  
  339.    
  340.     if ( row1 & (0x01 << 0) ) {
  341.         ROW0_PORT |= ROW0_BIT;
  342.     }
  343.     if ( row1 & (0x01 << 1) ) {
  344.         ROW1_PORT |= ROW1_BIT;
  345.         }
  346.     if ( row1 & (0x01 << 2) ) {
  347.         ROW2_PORT |= ROW2_BIT;
  348.     }
  349.     if ( row1 & (0x01 << 3) ) {
  350.         ROW3_PORT |= ROW3_BIT;
  351.     }
  352.     if ( row1 & (0x01 << 4) ) {
  353.         ROW4_PORT |= ROW4_BIT;
  354.     }
  355.    
  356.    
  357.     // Set values for given column on matrix 2
  358.     if ( row2 & (0x01 << 0) ) {
  359.         ROW5_PORT |= ROW5_BIT;
  360.     }
  361.     if ( row2 & (0x01 << 1) ) {
  362.         ROW6_PORT |= ROW6_BIT;
  363.         }
  364.     if ( row2 & (0x01 << 2) ) {
  365.         ROW7_PORT |= ROW7_BIT;
  366.     }
  367.     if ( row2 & (0x01 << 3) ) {
  368.         ROW8_PORT |= ROW8_BIT;
  369.     }
  370.     if ( row2 & (0x01 << 4) ) {
  371.         ROW9_PORT |= ROW9_BIT;
  372.     }
  373.  
  374.     activate_col(col1, 1);
  375.     activate_col(col2, 2);
  376.            
  377.     // Sleep for a while
  378.     SCROLL_STEP();
  379.        
  380.     // Disable all goddammit   
  381.     disable_all_damn_shit_crap();
  382. }
  383.  
  384. void write_character(char chr1, char chr2, int time) {
  385.     for (int phase = 0; phase < time; phase++){
  386.         for (int col = 0; col < 5; col++){
  387.             update_matrices(letter[chr1 - 32][col], col, letter[chr2 - 32][col], col);
  388.         }
  389.     }
  390. }
  391.  
  392. void write_scroll_character(char chr1, char chr2, char chr3, int time) {
  393.    
  394.     char data[17];
  395.    
  396.     for (int p = 0; p < 17; p++){
  397.         if (p < 5){
  398.             data[p] = letter[chr1 - 32][p];
  399.         }else if (p == 5) {
  400.             data[p] = 0x00;
  401.         }else if (p < 11){
  402.             data[p] = letter[chr2 - 32][(p - 1) % 5];
  403.         }else if (p == 11) {
  404.             data[p] = 0x00;
  405.         }else {
  406.             data[p] = letter[chr3 - 32][(p - 2) % 5];
  407.         }
  408.        
  409.     }
  410.     for (int shift = 0; shift < 6; shift++){
  411.         for (int phase = 0; phase < time; phase++){
  412.             for (int col = 0; col < 5; col++){
  413.                 update_matrices(data[col + shift], col, data[col + 5 + shift], col);
  414.             }
  415.         }
  416.     }
  417. }
  418.  
  419. // scroll text
  420. void scroll_text(const char *text, int speed) {
  421.     int cursor1 = 0;
  422.     int cursor2 = 1;
  423.     int cursor3 = 2;
  424.     while(1) { 
  425.         // change speed with { and }
  426.         while(text[cursor3] == '{' || text[cursor3] == '}'){
  427.             if (text[cursor3] == '}'){
  428.                 speed -= 10;
  429.                 if (speed < 1){
  430.                     speed = 10;
  431.                 }
  432.                 cursor3++;            
  433.             }if (text[cursor3] == '{'){
  434.                 speed += 10;
  435.                 cursor3++;
  436.             }
  437.         }
  438.         while (text[cursor2] == '{' || text[cursor2] == '}'){
  439.             cursor2++;
  440.         }
  441.         while (text[cursor1] == '{' || text[cursor1] == '}'){
  442.             cursor1++;
  443.         }
  444.        
  445.         write_scroll_character(text[cursor1], text[cursor2], text[cursor3], speed);
  446.        
  447.         cursor1++;
  448.         cursor2++;
  449.         cursor3++;
  450.         // sorsa_DSM was here
  451.         if ( text[cursor1] == '_'){
  452.             break;
  453.         }
  454.         if ( text[cursor2] == '_'){
  455.             cursor2 = 0;
  456.         }
  457.         if ( text[cursor3] == '_'){
  458.             cursor3 = 0;
  459.         }                      
  460.     }
  461. }
  462.  
  463. // this is where magic happens
  464. void magic(char ch1, char ch2, int p9) {
  465.     char kala[150] = "";
  466.     char k[] = "@@@@@";
  467.     if (p9) {
  468.         k[0] = ch1;
  469.         k[1] = ch2;
  470.     } else {
  471.         k[0] = ch1;
  472.     }
  473.     strcat(kala, k);
  474.     strcat(kala, PSTR("   KALA  "));
  475.     get_str((turska % 5) + 22);
  476.     strcat(kala, buffer);
  477.     scroll_text(kala, 95);
  478. }
  479.  
  480.  
  481. int main() {
  482.     io_setup();
  483.     disable_all_damn_shit_crap();
  484.    
  485.     char chr1 = '0';
  486.     char chr2 = '0';
  487.    
  488.     unsigned long time = 0; //...'cause why not?
  489.     int time_div = 0;
  490.     //scroll_text("  KALA}}KEITTOON}} TULEE}} KALAA}} JA}} KEITTOA_", 100);
  491.     const char jee[] = "  DAYS SINCE TAKEHITO KOYASU :_"; //"  ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 !\"#$%&'()*=,-./:;<=>?@[\\]__"; //
  492.     const char resetjee[] = " EVERYWHERE!!! ^^_";
  493.         if (resetjee[0] == 0){}
  494.     //int shift = 0;
  495.     int plus9 = 0;
  496.     int r = 0; // index for name
  497.    
  498.     //magic(chr1, chr2, plus9);
  499.    
  500.     while (1) {
  501.      
  502.         if (!(PIND & BTN_BIT)) {
  503.             char reset = 0;
  504.             int timer = 0;
  505.             get_str(r);
  506.             char out[127];
  507.             strcpy(out, "  ");
  508.             strcat(out, buffer);
  509.             strcat(out, ", ");
  510.             strcat(out, buffer);
  511.             strcat(out, resetjee);
  512.             r++;
  513.             r = r % 22; // plz no overflow
  514.  
  515.             while (!(PIND & BTN_BIT)){
  516.                 timer++;
  517.                 _delay_ms(10);
  518.                
  519.                 if (timer > 150){
  520.                    
  521.                     scroll_text(out, 100);
  522.                     time = 0;
  523.                     chr1 = '0';
  524.                     //this is good. vahennetaan "kirjaimesta" at 32 ja sijoitetann siihen binaaridataa...
  525.                     letter['@' - 32][4] = letter['@' - 32][3] = letter['@' - 32][2] = letter['@' - 32][1] = 0x00;  // count4
  526.                     reset = 2;
  527.                     plus9 = 0;
  528.                     chr2 = '0';
  529.                 }
  530.             }
  531.             if (reset == 0) {
  532.                 scroll_text(jee, 100);
  533.                 // funktion parametreina space...
  534.                 write_scroll_character(' ', ' ', chr1, 90);
  535.                 if (!plus9) {
  536.                     write_scroll_character(' ', chr1, '@', 90);
  537.                 } else {
  538.                     write_scroll_character(' ', chr2, chr1, 90);
  539.                 }          
  540.                    
  541.             }
  542.            
  543.         } else {
  544.  
  545.             if (!plus9) {
  546.                 // Magic number 893 = 47 * 19  893 = one second-ish. Maybe
  547.                 write_character(chr1, '@', 47);
  548.             }
  549.             else {
  550.                 write_character(chr2, chr1, 47);
  551.             }
  552.            
  553.             time_div++;
  554.             if (time_div == 19){
  555.                 time++;
  556.                 turska++;
  557.                
  558.                 letter['@' - 32][4] = (time & 0x1F);           // count1
  559.                 letter['@' - 32][3] = ( (time >> 5)  & 0x1F);  // count2
  560.                 letter['@' - 32][2] = ( (time >> 10) & 0x1F);  // count3
  561.                 letter['@' - 32][1] = ( (time >> 15) & 0x1F);  // count4
  562.                
  563.                 //14400
  564.                 if (time % 14400 == 0) {
  565.                     magic(chr1, chr2, plus9);
  566.                 }
  567.                
  568.                 //86400 s = 24 h
  569.                 if (time == 86320){
  570.                     time = 0;
  571.                     chr1++;
  572.                     scroll_text(jee, 100);
  573.                 }
  574.                 if (chr1 > '9'){
  575.                     chr1 = '0';
  576.                     chr2++;
  577.                     if (chr2 > '9') {
  578.                         time = 86401;
  579.                         chr1 = '=';
  580.                         chr2 = 'D';
  581.                     }
  582.                     plus9 = 1;
  583.                      
  584.                 }
  585.                 time_div = 0;
  586.             }      
  587.         }
  588.     }
  589. }
  590.  
  591.  
  592. /*
  593.                 MINUTE COUNTER
  594.                 if (count == 0x1F){
  595.                     count = 0x00;
  596.                     count2++;
  597.                 }
  598.                 if (count2 == 0x01){
  599.                     if (count == 0x1C){
  600.                         count = 0;
  601.                         count2 = 0;
  602.                     }
  603.                 }
  604.  
  605.  
  606. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement