source: thomson/code/C/meatracker/display.c@ 90b6d4b

main
Last change on this file since 90b6d4b was 90b6d4b, checked in by Adrien Destugues <pulkomandy@…>, 11 years ago

Work on MEATrakcer continues with some input and cursor handling.

git-svn-id: svn://localhost/thomson@44 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "display.h"
2
3#include <text.h>
4
5char music[8][16];
6
7static const char* notes = "C C#D D#E F F#G G#A A#B --";
8
9const char FM1[] = {
102,'3', 4,'3', 5,'3', 6,'3', 7,'3', 9,'3', 10,'3', 11,'3',
110,'4', 2,'4', 3,'4', 4,'4', 5,'4', 6,'4', 7,'4', 8,'4',
12// >> FM2
139,'4', 10,'4', 11,'4', 0,'5', 1,'5', 2,'5', 3,'5', 4,'5',
145,'5', 6,'5', 7,'5', 8,'5', 9,'5', 10,'5', 11,'5', 0,'6'
15};
16
17const char FM2[] = {
189,'4', 10,'4', 11,'4', 0,'5', 1,'5', 2,'5', 3,'5', 4,'5',
195,'5', 6,'5', 7,'5', 8,'5', 9,'5', 10,'5', 11,'5', 0,'6',
20// << FM1
211,'6', 2,'6', 3,'6', 5,'6', 6,'6', 7,'6', 8,'6', 9,'6',
2210,'6', 0,'7', 1,'7', 2,'7', 4,'7', 5,'7', 7,'7', 8,'7'
23};
24
25const char FM3[] = {
262,'6', 4,'6', 7,'6', 9,'6', 0,'7', 2,'7', 5,'7', 8,'7'
27};
28
29static const char FM4[] = { 9,'7' };
30
31void printnote(unsigned char channel, unsigned char pos)
32{
33 if (channel > 6) return;
34
35 uint8_t note = music[channel][pos];
36 char fbw = '1' + music[channel+1][pos];
37
38 uint8_t n = 12, o = '?';
39 if (note >= 0)
40 {
41 note *= 2;
42 switch (channel)
43 {
44 case 0:
45 n = FM1[note]; o = FM1[note+1];
46 break;
47 case 2:
48 n = FM2[note]; o = FM2[note+1];
49 break;
50 case 4:
51 n = FM3[note]; o = FM3[note+1];
52 break;
53 case 6:
54 n = FM4[note]; o = FM4[note+1];
55 break;
56 }
57 }
58
59
60 pos *= 8;
61
62 if(channel == 2) channel = 5;
63 else if(channel == 4) channel = 10;
64 else if(channel == 6) channel = 15;
65
66 n *= 2;
67
68 drawchar(notes[n], channel++, pos);
69 drawchar(notes[n + 1], channel++, pos);
70 drawchar(o, channel++, pos);
71 drawchar(fbw, channel, pos);
72}
73
74void refreshchannels()
75{
76 int x,y;
77
78 for(x = 0; x < 8; x+=2)
79 for(y = 0; y < 16; y++)
80 {
81 printnote(x, y);
82 }
83
84 // TODO HEADER
85 // FM1 FM2 FM3 FM4 GEN
86 // nnnW nnnW nnnW nnnW sldCRVD
87 // --- --- --- --- nnnCR
88
89 cursor(cursorx, cursory);
90}
91
92void cursor(uint8_t x, uint8_t y)
93{
94 uint8_t* destp = (uint8_t*)(x*2) + y * 8 * 40;
95
96 if(x>1) ++destp;
97 if(x>3) ++destp;
98 if(x>5) ++destp;
99 if(x>7) ++destp;
100
101 int val = 0xFFFF;
102 if(x == 1 || x == 3 || x == 5 || x == 7) val = 0xFF;
103 uint16_t* dest = (uint16_t*)destp;
104 *dest ^= val; dest +=20;
105 *dest ^= val; dest +=20;
106 *dest ^= val; dest +=20;
107 *dest ^= val; dest +=20;
108 *dest ^= val; dest +=20;
109 *dest ^= val; dest +=20;
110 *dest ^= val; dest +=20;
111 *dest ^= val; dest +=20;
112}
Note: See TracBrowser for help on using the repository browser.