Adrien Destugues | 1180ce9 | 2013-03-17 07:49:36 +0000 | [diff] [blame^] | 1 | #include "effect.h" |
| 2 | #include "../libdemo/trig.h" |
| 3 | |
| 4 | uint8_t* screen = 0; |
| 5 | |
| 6 | enum timings |
| 7 | { |
| 8 | WAVES = 300, |
| 9 | TWISTER = WAVES + 400, |
| 10 | POISCAIE = TWISTER + 200, |
| 11 | PLASMA = POISCAIE + 800 |
| 12 | }; |
| 13 | |
| 14 | #define MEA_CMD *(volatile unsigned char*)(0xA7CF) |
| 15 | #define MEA_DATA *(volatile unsigned char*)(0xA7CE) |
| 16 | |
| 17 | static const unsigned char patterns[] = |
| 18 | { |
| 19 | 0,0,0,1,0,0,0,1,0,2,0,1,2,2,1,1 |
| 20 | }; |
| 21 | |
| 22 | static const unsigned char music[] = |
| 23 | { |
| 24 | |
| 25 | // 0000 |
| 26 | 0xFF, 0xD0, 0x87, 0x80, // A |
| 27 | 0xF0, 0xD0, 0x87, 0x80, // A |
| 28 | 0xF0, 0xD0, 0x87, 0x80, // A |
| 29 | 0xF0, 0xD5, 0xAF, 0x80, // D |
| 30 | |
| 31 | 0xFF, 0xD0, 0x87, 0x80, // A |
| 32 | 0xF0, 0xD3, 0x9F, 0x80, // C |
| 33 | 0xF0, 0xD5, 0xAF, 0x80, // D |
| 34 | 0xF0, 0xD5, 0xAF, 0x80, // D |
| 35 | // 0001 |
| 36 | 0xFF, 0xD0, 0x87, 0x80, // A |
| 37 | 0xF1, 0xD0, 0x87, 0x80, // A |
| 38 | 0xF1, 0xD0, 0x87, 0x80, // A |
| 39 | 0xF1, 0xD5, 0xAF, 0x80, // D |
| 40 | |
| 41 | 0xFF, 0xD0, 0x87, 0x80, // A |
| 42 | 0xF0, 0xD3, 0x9F, 0x80, // C |
| 43 | 0xF3, 0xD5, 0xAF, 0x89, // D |
| 44 | 0x00, 0xD3, 0x91, 0x80, // --- |
| 45 | // 0002 |
| 46 | 0xFF, 0xD3, 0x9F, 0x80, // C |
| 47 | 0xF1, 0xD3, 0x9F, 0x80, // C |
| 48 | 0xF1, 0xD3, 0x9F, 0x80, // C |
| 49 | 0xF1, 0xD5, 0xAF, 0x80, // D |
| 50 | |
| 51 | 0xFF, 0xD0, 0x87, 0x80, // A |
| 52 | 0xF0, 0xD3, 0x9F, 0x80, // C |
| 53 | 0xF0, 0xD5, 0xAF, 0x86, // D |
| 54 | 0x00, 0xD3, 0x91, 0x80, // --- |
| 55 | }; |
| 56 | |
| 57 | void p_music(void) |
| 58 | { |
| 59 | static int i = 0; |
| 60 | static int pos = 0; |
| 61 | static int pat = 0; |
| 62 | |
| 63 | |
| 64 | i++; |
| 65 | if (i > 4) { |
| 66 | if ((pos & 0x3) == 0) |
| 67 | { |
| 68 | MEA_CMD = 16 + 12; |
| 69 | switch(patterns[pat]) { |
| 70 | case 0: |
| 71 | MEA_DATA = 220; |
| 72 | break; |
| 73 | case 1: |
| 74 | MEA_DATA = 131; |
| 75 | break; |
| 76 | case 2: |
| 77 | MEA_DATA = 147; |
| 78 | break; |
| 79 | default: |
| 80 | MEA_DATA = 0xFF; |
| 81 | break; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | for (int j = 0; j < 4; j++) |
| 86 | { |
| 87 | MEA_DATA = music[(patterns[pat] * 8*4) | j | (pos<<2)]; |
| 88 | } |
| 89 | i = 0; |
| 90 | pos ++; |
| 91 | if (pos >= 8) |
| 92 | { |
| 93 | pos = 0; |
| 94 | |
| 95 | pat++; |
| 96 | if(pat >= sizeof(patterns)) pat = 0; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | } |
| 101 | |
| 102 | int main(void) |
| 103 | { |
| 104 | int frame = 0; |
| 105 | |
| 106 | asm(" ORCC #$50"); // Disable interrupts (cursor blink) |
| 107 | |
| 108 | polysine(); |
| 109 | |
| 110 | // show SHR&JFF logo + ondulations |
| 111 | init_L(); |
| 112 | for(;frame < WAVES;) { |
| 113 | p_music(); |
| 114 | draw_L(frame++); |
| 115 | p_music(); |
| 116 | frame++; |
| 117 | } |
| 118 | |
| 119 | // TODO clear screen, put on some nice background for the twister |
| 120 | couleur(); |
| 121 | for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++) |
| 122 | *i = 0; |
| 123 | |
| 124 | // TWISTER !!! |
| 125 | init_T(); |
| 126 | for(;frame < TWISTER;) { |
| 127 | p_music(); |
| 128 | p_music(); |
| 129 | draw_T(frame++); |
| 130 | } |
| 131 | |
| 132 | // TODO clear color ram to some nice color while we prepare the picture |
| 133 | couleur(); |
| 134 | for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++) |
| 135 | *i = 0; |
| 136 | |
| 137 | // POISCAIE |
| 138 | init_P(); |
| 139 | for(;frame < POISCAIE;) { |
| 140 | p_music(); |
| 141 | asm("\n" |
| 142 | "w TST 0xA7E7 \n" |
| 143 | " BMI w \n" |
| 144 | "q TST 0xA7E7 \n" |
| 145 | " BPL q \n" |
| 146 | ); |
| 147 | frame++; |
| 148 | } |
| 149 | |
| 150 | // TODO, again, clear the the color ram while we setup the plasma |
| 151 | couleur(); |
| 152 | for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++) |
| 153 | *i = 0; |
| 154 | |
| 155 | init(); |
| 156 | for(;frame < PLASMA;) { |
| 157 | p_music(); |
| 158 | p_music(); |
| 159 | p_music(); |
| 160 | draw(frame++); |
| 161 | } |
| 162 | |
| 163 | // TODO and finally, clear the picture to setup the greetings |
| 164 | couleur(); |
| 165 | for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++) |
| 166 | *i = 0; |
| 167 | |
| 168 | // note: may be interesting to darken the plasma colorpalette to nicely |
| 169 | // fade to black (or white), while the plasma is still moving |
| 170 | init_G(); |
| 171 | for(;;) { |
| 172 | p_music(); |
| 173 | draw_G(frame++); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // FIXME use libthomson ! |
| 178 | void forme(void) |
| 179 | { |
| 180 | asm(" SWI \n" |
| 181 | " FCB 6" |
| 182 | ); |
| 183 | } |
| 184 | |
| 185 | void couleur(void) |
| 186 | { |
| 187 | asm(" SWI \n" |
| 188 | " FCB 4" |
| 189 | ); |
| 190 | } |