1 | #include "display.h"
|
---|
2 |
|
---|
3 | unsigned char cursorx = 0, cursory = 7;
|
---|
4 |
|
---|
5 | extern const char FM1[], FM2[], FM3[];
|
---|
6 | extern unsigned char music[8][16];
|
---|
7 | void printnote(unsigned char x, unsigned char y);
|
---|
8 |
|
---|
9 | // maps keycodes to notes
|
---|
10 | static const unsigned char notemap[] =
|
---|
11 | {
|
---|
12 | [0x60] = 0, // W
|
---|
13 | [0x50] = 2, // X
|
---|
14 | [0x64] = 4, // C
|
---|
15 | [0x54] = 6, // V
|
---|
16 | [0x44] = 8, // B
|
---|
17 | [0x00] = 10, // N
|
---|
18 | [0x10] = 12, // ,
|
---|
19 | [0x20] = 14, // .
|
---|
20 | [0x30] = 16, // @
|
---|
21 | [0x22] = 18, // back
|
---|
22 | [0x56] = 20, // Q
|
---|
23 | [0x46] = 22, // S
|
---|
24 | [0x36] = 24, // D
|
---|
25 | [0x26] = 26, // F
|
---|
26 | [0x16] = 28, // G
|
---|
27 | [0x06] = 30, // H
|
---|
28 | [0x04] = 32, // J
|
---|
29 | [0x14] = 34, // K
|
---|
30 | [0X24] = 36, // L
|
---|
31 | [0x34] = 38, // M
|
---|
32 | [0x5A] = 40, // A
|
---|
33 | [0x4A] = 42, // Z
|
---|
34 | [0x3A] = 44, // E
|
---|
35 | [0x2A] = 46, // R
|
---|
36 | [0x1A] = 48, // T
|
---|
37 | [0x0A] = 50, // Y
|
---|
38 | [0x08] = 52, // U
|
---|
39 | [0x18] = 54, // I
|
---|
40 | [0x28] = 56, // O
|
---|
41 | [0x38] = 58, // P
|
---|
42 | [0x48] = 60, // /
|
---|
43 | [0x58] = 61, // *
|
---|
44 | // JKLM AZERTY UIOP/*
|
---|
45 | };
|
---|
46 |
|
---|
47 | void input()
|
---|
48 | {
|
---|
49 | // scan keyboard
|
---|
50 | volatile unsigned char* volatile PIA_B = (volatile unsigned char* volatile)0xA7C1;
|
---|
51 |
|
---|
52 | for(unsigned char k = 0; k < 127; k+= 2)
|
---|
53 | {
|
---|
54 | *PIA_B = k;
|
---|
55 |
|
---|
56 | if(!(*PIA_B & 0x80))
|
---|
57 | {
|
---|
58 | // We have a keypress !
|
---|
59 | switch(k)
|
---|
60 | {
|
---|
61 | case 0x32: //RIGHT
|
---|
62 | if(cursorx == 11) break;
|
---|
63 | cursor(cursorx,cursory);
|
---|
64 | cursorx ++;
|
---|
65 | cursor(cursorx,cursory);
|
---|
66 | break;
|
---|
67 | case 0x42: //DOWN
|
---|
68 | if(cursory == 15) break;
|
---|
69 | cursor(cursorx,cursory);
|
---|
70 | cursory ++;
|
---|
71 | cursor(cursorx,cursory);
|
---|
72 | break;
|
---|
73 | case 0x52: //LEFT
|
---|
74 | if(cursorx == 0) break;
|
---|
75 | cursor(cursorx,cursory);
|
---|
76 | cursorx --;
|
---|
77 | cursor(cursorx,cursory);
|
---|
78 | break;
|
---|
79 | case 0x62: //UP
|
---|
80 | if (cursory == 0) break;
|
---|
81 | cursor(cursorx,cursory);
|
---|
82 | cursory --;
|
---|
83 | cursor(cursorx,cursory);
|
---|
84 | break;
|
---|
85 |
|
---|
86 | // TODO handle octave / width / more ?
|
---|
87 | default:
|
---|
88 | {
|
---|
89 | // direclty assigning from array to array generates buggy code
|
---|
90 | uint8_t note = notemap[k];
|
---|
91 | switch(cursorx)
|
---|
92 | {
|
---|
93 | case 0:
|
---|
94 | case 2:
|
---|
95 | case 4:
|
---|
96 | case 6:
|
---|
97 | music[cursorx][cursory] = note;
|
---|
98 | printnote(cursorx, cursory);
|
---|
99 | cursor(cursorx, cursory);
|
---|
100 | break;
|
---|
101 |
|
---|
102 | case 1:
|
---|
103 | case 3:
|
---|
104 | case 5:
|
---|
105 | case 7:
|
---|
106 | {
|
---|
107 | uint8_t channel = cursorx - 1;
|
---|
108 | if(k == 0x5E)
|
---|
109 | music[channel + 1][cursory] = 0;
|
---|
110 | else if (k == 0x4E)
|
---|
111 | music[channel + 1][cursory] = 1;
|
---|
112 | else if (k == 0x3E)
|
---|
113 | music[channel + 1][cursory] = 2;
|
---|
114 | else if (k == 0x2E)
|
---|
115 | music[channel + 1][cursory] = 3;
|
---|
116 | printnote(cursorx - 1, cursory);
|
---|
117 | cursor(cursorx, cursory);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | break;
|
---|
121 | }
|
---|
122 | }
|
---|
123 | }
|
---|
124 | }
|
---|
125 |
|
---|
126 | // TODO extra widgets besides the tracker ? diskop, etc ?
|
---|
127 | }
|
---|